Add tests and changes for Instant

This commit is contained in:
dotasek 2022-03-15 15:59:22 -04:00
parent 3cc8affbdf
commit 6730275277
7 changed files with 55 additions and 19 deletions

View File

@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
public class Instant10_40 { public class Instant10_40 {
public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu2.model.InstantType src) throws FHIRException { public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu2.model.InstantType src) throws FHIRException {
org.hl7.fhir.r4.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.InstantType(src.getValue()) : new org.hl7.fhir.r4.model.InstantType(); org.hl7.fhir.r4.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r4.model.InstantType();
ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
return tgt; return tgt;
} }
public static org.hl7.fhir.dstu2.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { public static org.hl7.fhir.dstu2.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException {
org.hl7.fhir.dstu2.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.InstantType(src.getValue()) : new org.hl7.fhir.dstu2.model.InstantType(); org.hl7.fhir.dstu2.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.InstantType();
ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
return tgt; return tgt;
} }

View File

@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
public class Instant10_50 { public class Instant10_50 {
public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.dstu2.model.InstantType src) throws FHIRException { public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.dstu2.model.InstantType src) throws FHIRException {
org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValue()) : new org.hl7.fhir.r5.model.InstantType(); org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r5.model.InstantType();
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
return tgt; return tgt;
} }
public static org.hl7.fhir.dstu2.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { public static org.hl7.fhir.dstu2.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException {
org.hl7.fhir.dstu2.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.InstantType(src.getValue()) : new org.hl7.fhir.dstu2.model.InstantType(); org.hl7.fhir.dstu2.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.InstantType();
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
return tgt; return tgt;
} }

View File

@ -5,15 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
public class Instant14_30 { public class Instant14_30 {
public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException { public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException {
org.hl7.fhir.dstu3.model.InstantType tgt = new org.hl7.fhir.dstu3.model.InstantType(); org.hl7.fhir.dstu3.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.InstantType();
if (src.hasValue()) tgt.setValue(src.getValue());
ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt); ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
return tgt; return tgt;
} }
public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException { public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException {
org.hl7.fhir.dstu2016may.model.InstantType tgt = new org.hl7.fhir.dstu2016may.model.InstantType(); org.hl7.fhir.dstu2016may.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2016may.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu2016may.model.InstantType();
if (src.hasValue()) tgt.setValue(src.getValue());
ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt); ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
return tgt; return tgt;
} }

View File

@ -5,15 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
public class Instant14_40 { public class Instant14_40 {
public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException { public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException {
org.hl7.fhir.r4.model.InstantType tgt = new org.hl7.fhir.r4.model.InstantType(); org.hl7.fhir.r4.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r4.model.InstantType();
if (src.hasValue()) tgt.setValue(src.getValue());
ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt); ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt);
return tgt; return tgt;
} }
public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException {
org.hl7.fhir.dstu2016may.model.InstantType tgt = new org.hl7.fhir.dstu2016may.model.InstantType(); org.hl7.fhir.dstu2016may.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2016may.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu2016may.model.InstantType();
if (src.hasValue()) tgt.setValue(src.getValue());
ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt); ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt);
return tgt; return tgt;
} }

View File

@ -5,15 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
public class Instant14_50 { public class Instant14_50 {
public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException { public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException {
org.hl7.fhir.r5.model.InstantType tgt = new org.hl7.fhir.r5.model.InstantType(); org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r5.model.InstantType();
if (src.hasValue()) tgt.setValue(src.getValue());
ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
return tgt; return tgt;
} }
public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException {
org.hl7.fhir.dstu2016may.model.InstantType tgt = new org.hl7.fhir.dstu2016may.model.InstantType(); org.hl7.fhir.dstu2016may.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2016may.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu2016may.model.InstantType();
if (src.hasValue()) tgt.setValue(src.getValue());
ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
return tgt; return tgt;
} }

View File

@ -5,7 +5,7 @@ import org.hl7.fhir.exceptions.FHIRException;
public class Instant40_50 { public class Instant40_50 {
public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException {
org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValue()) : new org.hl7.fhir.r5.model.InstantType(); org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r5.model.InstantType();
ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
return tgt; return tgt;
} }

View File

@ -27,6 +27,10 @@ public class VersionConvertorPrimitiveTypeTests {
Stream.concat(Arrays.stream(SECOND_DATE_PRECISION_STRINGS),Stream.of("1933-01-02T13:45:12.3", "1933-01-02T13:45:12.3456")) Stream.concat(Arrays.stream(SECOND_DATE_PRECISION_STRINGS),Stream.of("1933-01-02T13:45:12.3", "1933-01-02T13:45:12.3456"))
.toArray(size -> (String[]) Array.newInstance(String.class, size)); .toArray(size -> (String[]) Array.newInstance(String.class, size));
private static String[] INSTANT_PRECISION_STRINGS = {
"1933-01-02T13:45:12", "1933-01-02T13:45:12.3", "1933-01-02T13:45:12.3456"
};
private static <K,L> Stream<Arguments> getDateTimeArgs(Class<? extends VersionConvertorFactory> versionConverterFactoryClazz, Class<K> firstTypeClazz, Class<?> firstTypeMethodClazz, Class<L> secondTypeClazz, Class<?> secondTypeMethodClazz, String[] testStrings) { private static <K,L> Stream<Arguments> getDateTimeArgs(Class<? extends VersionConvertorFactory> versionConverterFactoryClazz, Class<K> firstTypeClazz, Class<?> firstTypeMethodClazz, Class<L> secondTypeClazz, Class<?> secondTypeMethodClazz, String[] testStrings) {
return Arrays.stream(testStrings).map( it -> Arguments.of(versionConverterFactoryClazz, return Arrays.stream(testStrings).map( it -> Arguments.of(versionConverterFactoryClazz,
@ -137,8 +141,46 @@ public class VersionConvertorPrimitiveTypeTests {
getDateTimeArgs(VersionConvertorFactory_40_50.class, getDateTimeArgs(VersionConvertorFactory_40_50.class,
org.hl7.fhir.r4.model.DateTimeType.class, org.hl7.fhir.r4.model.Type.class, org.hl7.fhir.r4.model.DateTimeType.class, org.hl7.fhir.r4.model.Type.class,
org.hl7.fhir.r5.model.DateTimeType.class, org.hl7.fhir.r5.model.DataType.class, org.hl7.fhir.r5.model.DateTimeType.class, org.hl7.fhir.r5.model.DataType.class,
MILLISECOND_DATE_PRECISION_STRINGS) MILLISECOND_DATE_PRECISION_STRINGS),
//Instant
getDateTimeArgs(VersionConvertorFactory_10_30.class,
org.hl7.fhir.dstu2.model.InstantType.class, org.hl7.fhir.dstu2.model.Type.class,
org.hl7.fhir.dstu3.model.InstantType.class, org.hl7.fhir.dstu3.model.Type.class,
INSTANT_PRECISION_STRINGS),
getDateTimeArgs(VersionConvertorFactory_10_40.class,
org.hl7.fhir.dstu2.model.InstantType.class, org.hl7.fhir.dstu2.model.Type.class,
org.hl7.fhir.r4.model.InstantType.class, org.hl7.fhir.r4.model.Type.class,
INSTANT_PRECISION_STRINGS),
getDateTimeArgs(VersionConvertorFactory_10_50.class,
org.hl7.fhir.dstu2.model.InstantType.class, org.hl7.fhir.dstu2.model.Type.class,
org.hl7.fhir.r5.model.InstantType.class, org.hl7.fhir.r5.model.DataType.class,
INSTANT_PRECISION_STRINGS),
getDateTimeArgs(VersionConvertorFactory_14_30.class,
org.hl7.fhir.dstu2016may.model.InstantType.class, org.hl7.fhir.dstu2016may.model.Type.class,
org.hl7.fhir.dstu3.model.InstantType.class, org.hl7.fhir.dstu3.model.Type.class,
INSTANT_PRECISION_STRINGS),
getDateTimeArgs(VersionConvertorFactory_14_40.class,
org.hl7.fhir.dstu2016may.model.InstantType.class, org.hl7.fhir.dstu2016may.model.Type.class,
org.hl7.fhir.r4.model.InstantType.class, org.hl7.fhir.r4.model.Type.class,
INSTANT_PRECISION_STRINGS),
getDateTimeArgs(VersionConvertorFactory_14_50.class,
org.hl7.fhir.dstu2016may.model.InstantType.class, org.hl7.fhir.dstu2016may.model.Type.class,
org.hl7.fhir.r5.model.InstantType.class, org.hl7.fhir.r5.model.DataType.class,
INSTANT_PRECISION_STRINGS),
getDateTimeArgs(VersionConvertorFactory_30_40.class,
org.hl7.fhir.dstu3.model.InstantType.class, org.hl7.fhir.dstu3.model.Type.class,
org.hl7.fhir.r4.model.InstantType.class, org.hl7.fhir.r4.model.Type.class,
INSTANT_PRECISION_STRINGS),
getDateTimeArgs(VersionConvertorFactory_30_50.class,
org.hl7.fhir.dstu3.model.InstantType.class, org.hl7.fhir.dstu3.model.Type.class,
org.hl7.fhir.r5.model.InstantType.class, org.hl7.fhir.r5.model.DataType.class,
INSTANT_PRECISION_STRINGS),
getDateTimeArgs(VersionConvertorFactory_40_50.class,
org.hl7.fhir.r4.model.InstantType.class, org.hl7.fhir.r4.model.Type.class,
org.hl7.fhir.r5.model.InstantType.class, org.hl7.fhir.r5.model.DataType.class,
INSTANT_PRECISION_STRINGS)
).flatMap(i -> i); ).flatMap(i -> i);
} }