Null value check for primitive type conversions.

This commit is contained in:
markiantorno 2020-04-20 15:13:42 -04:00
parent bd17bc716b
commit 8093524f4b
7 changed files with 383 additions and 50 deletions

View File

@ -5,7 +5,6 @@ import org.hl7.fhir.dstu2.model.CodeType;
import org.hl7.fhir.dstu2.model.DateType; import org.hl7.fhir.dstu2.model.DateType;
import org.hl7.fhir.dstu2.model.DateTimeType; import org.hl7.fhir.dstu2.model.DateTimeType;
import org.hl7.fhir.dstu2.model.DecimalType; import org.hl7.fhir.dstu2.model.DecimalType;
import org.hl7.fhir.dstu2.model.IdType;
import org.hl7.fhir.dstu2.model.InstantType; import org.hl7.fhir.dstu2.model.InstantType;
import org.hl7.fhir.dstu2.model.PositiveIntType; import org.hl7.fhir.dstu2.model.PositiveIntType;
import org.hl7.fhir.dstu2.model.UnsignedIntType; import org.hl7.fhir.dstu2.model.UnsignedIntType;
@ -20,57 +19,66 @@ import org.hl7.fhir.dstu2.model.Base64BinaryType;
import org.hl7.fhir.dstu2.model.UriType; import org.hl7.fhir.dstu2.model.UriType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
import java.io.Serializable;
import java.util.stream.Stream; import java.util.stream.Stream;
public class VersionConvertorPrimitiveType10_30Test { public class VersionConvertorPrimitiveType10_30Test {
@ParameterizedTest(name = "Testing dstu2 -> dstu3 conversion of null value {0}.")
@MethodSource("dstu2PrimitiveTypes")
@Test public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) {
@DisplayName("Test 10_30 UnsignedIntType preserves value on conversion.") obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value"));
public void testConvertUnsignedInt() {
org.hl7.fhir.dstu3.model.UnsignedIntType output;
output = (org.hl7.fhir.dstu3.model.UnsignedIntType)VersionConvertor_10_30.convertType(new org.hl7.fhir.dstu2.model.UnsignedIntType(33));
Assertions.assertEquals(33, output.getValue().intValue());
}
// @Test
// @DisplayName("Test 10_30 conversion has null safety for UnsignedIntType value.")
// public void testConvertEmptyValuedUnsignedInt() {
// org.hl7.fhir.dstu2.model.UnsignedIntType input = new org.hl7.fhir.dstu2.model.UnsignedIntType();
// input.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.dstu2.model.StringType("A value"));
// org.hl7.fhir.dstu3.model.UnsignedIntType output;
// output = (org.hl7.fhir.dstu3.model.UnsignedIntType)VersionConvertor_10_30.convertType(input);
// Assertions.assertNull(output.getValue());
// }
//
// @Test
// @DisplayName("Test 10_30 conversion has null safety for UnsignedIntType value.")
// public void testConvertEmptyValuedUnsignedInt() {
// UnsignedIntType input = new UnsignedIntType();
// input.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value"));
//
// Assertions.assertNull(((org.hl7.fhir.dstu3.model.PrimitiveType) VersionConvertor_10_30.convertType(input)).getValue(););
// }
@ParameterizedTest(name = "{0} converstion")
@MethodSource("PrimitiveTypes")
public <T extends PrimitiveType> void testNullValuePrimitive(T obj) {
obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.dstu3.model.StringType("A value"));
Assertions.assertNull(((org.hl7.fhir.dstu3.model.PrimitiveType) VersionConvertor_10_30.convertType(obj)).getValue()); Assertions.assertNull(((org.hl7.fhir.dstu3.model.PrimitiveType) VersionConvertor_10_30.convertType(obj)).getValue());
} }
public Stream<? extends PrimitiveType> PrimitiveTypes() { @ParameterizedTest(name = "Testing dstu3 -> dstu2 conversion of null value {0}.")
return Stream.of(new UnsignedIntType(), new Base64BinaryType()); @MethodSource("Dstu3PrimitiveTypes")
public <T extends org.hl7.fhir.dstu3.model.PrimitiveType> void testNullValueDstu3Primitive(String classname, T obj) {
obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.dstu3.model.StringType("A value"));
Assertions.assertNull(((org.hl7.fhir.dstu2.model.PrimitiveType) VersionConvertor_10_30.convertType(obj)).getValue());
} }
public static Stream<Arguments> dstu2PrimitiveTypes() {
return Stream.of(
Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()),
Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()),
Arguments.arguments(DateType.class.getSimpleName(), new DateType()),
Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()),
Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()),
Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()),
Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()),
Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()),
Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()),
Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()),
Arguments.arguments(OidType.class.getSimpleName(), new OidType()),
Arguments.arguments(StringType.class.getSimpleName(), new StringType()),
Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()),
Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()),
Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()),
Arguments.arguments(UriType.class.getSimpleName(), new UriType()));
}
public static Stream<Arguments> Dstu3PrimitiveTypes() {
return Stream.of(
Arguments.arguments(org.hl7.fhir.dstu3.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.BooleanType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.CodeType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.CodeType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.DateType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.DateType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.DateTimeType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.DecimalType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.InstantType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.InstantType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.PositiveIntType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.UnsignedIntType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.IntegerType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.MarkdownType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.OidType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.OidType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.StringType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.StringType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.TimeType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.TimeType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.UuidType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.UuidType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.Base64BinaryType()),
Arguments.arguments(org.hl7.fhir.dstu3.model.UriType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.UriType()));
}
} }

View File

@ -0,0 +1,67 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.dstu2.model.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
public class VersionConvertorPrimitiveType10_40Test {
@ParameterizedTest(name = "Testing dstu2 -> r4 conversion of null value {0}.")
@MethodSource("dstu2PrimitiveTypes")
public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) {
obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value"));
Assertions.assertNull(((org.hl7.fhir.r4.model.PrimitiveType) VersionConvertor_10_40.convertType(obj)).getValue());
}
@ParameterizedTest(name = "Testing r4 -> dstu2 conversion of null value {0}.")
@MethodSource("r4PrimitiveTypes")
public <T extends org.hl7.fhir.r4.model.PrimitiveType> void testNullValueR4Primitive(String classname, T obj) {
obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.r4.model.StringType("A value"));
Assertions.assertNull(((PrimitiveType) VersionConvertor_10_40.convertType(obj)).getValue());
}
public static Stream<Arguments> dstu2PrimitiveTypes() {
return Stream.of(
Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()),
Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()),
Arguments.arguments(DateType.class.getSimpleName(), new DateType()),
Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()),
Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()),
Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()),
Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()),
Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()),
Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()),
Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()),
Arguments.arguments(OidType.class.getSimpleName(), new OidType()),
Arguments.arguments(StringType.class.getSimpleName(), new StringType()),
Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()),
Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()),
Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()),
Arguments.arguments(UriType.class.getSimpleName(), new UriType()));
}
public static Stream<Arguments> r4PrimitiveTypes() {
return Stream.of(
Arguments.arguments(org.hl7.fhir.r4.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.r4.model.BooleanType()),
Arguments.arguments(org.hl7.fhir.r4.model.CodeType.class.getSimpleName(), new org.hl7.fhir.r4.model.CodeType()),
Arguments.arguments(org.hl7.fhir.r4.model.DateType.class.getSimpleName(), new org.hl7.fhir.r4.model.DateType()),
Arguments.arguments(org.hl7.fhir.r4.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.r4.model.DateTimeType()),
Arguments.arguments(org.hl7.fhir.r4.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.r4.model.DecimalType()),
Arguments.arguments(org.hl7.fhir.r4.model.InstantType.class.getSimpleName(), new org.hl7.fhir.r4.model.InstantType()),
Arguments.arguments(org.hl7.fhir.r4.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.r4.model.PositiveIntType()),
Arguments.arguments(org.hl7.fhir.r4.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.r4.model.UnsignedIntType()),
Arguments.arguments(org.hl7.fhir.r4.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.r4.model.IntegerType()),
Arguments.arguments(org.hl7.fhir.r4.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.r4.model.MarkdownType()),
Arguments.arguments(org.hl7.fhir.r4.model.OidType.class.getSimpleName(), new org.hl7.fhir.r4.model.OidType()),
Arguments.arguments(org.hl7.fhir.r4.model.StringType.class.getSimpleName(), new org.hl7.fhir.r4.model.StringType()),
Arguments.arguments(org.hl7.fhir.r4.model.TimeType.class.getSimpleName(), new org.hl7.fhir.r4.model.TimeType()),
Arguments.arguments(org.hl7.fhir.r4.model.UuidType.class.getSimpleName(), new org.hl7.fhir.r4.model.UuidType()),
Arguments.arguments(org.hl7.fhir.r4.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.r4.model.Base64BinaryType()),
Arguments.arguments(org.hl7.fhir.r4.model.UriType.class.getSimpleName(), new org.hl7.fhir.r4.model.UriType()));
}
}

View File

@ -0,0 +1,67 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.dstu2.model.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
public class VersionConvertorPrimitiveType10_50Test {
@ParameterizedTest(name = "Testing dstu2 -> r5 conversion of null value {0}.")
@MethodSource("dstu2PrimitiveTypes")
public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) {
obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value"));
Assertions.assertNull(((org.hl7.fhir.r4.model.PrimitiveType) VersionConvertor_10_40.convertType(obj)).getValue());
}
@ParameterizedTest(name = "Testing r5 -> dstu2 conversion of null value {0}.")
@MethodSource("r5PrimitiveTypes")
public <T extends org.hl7.fhir.r5.model.PrimitiveType> void testNullValueR5Primitive(String classname, T obj) {
obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.r5.model.StringType("A value"));
Assertions.assertNull(((PrimitiveType) VersionConvertor_10_50.convertType(obj)).getValue());
}
public static Stream<Arguments> dstu2PrimitiveTypes() {
return Stream.of(
Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()),
Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()),
Arguments.arguments(DateType.class.getSimpleName(), new DateType()),
Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()),
Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()),
Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()),
Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()),
Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()),
Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()),
Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()),
Arguments.arguments(OidType.class.getSimpleName(), new OidType()),
Arguments.arguments(StringType.class.getSimpleName(), new StringType()),
Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()),
Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()),
Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()),
Arguments.arguments(UriType.class.getSimpleName(), new UriType()));
}
public static Stream<Arguments> r5PrimitiveTypes() {
return Stream.of(
Arguments.arguments(org.hl7.fhir.r5.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.r5.model.BooleanType()),
Arguments.arguments(org.hl7.fhir.r5.model.CodeType.class.getSimpleName(), new org.hl7.fhir.r5.model.CodeType()),
Arguments.arguments(org.hl7.fhir.r5.model.DateType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateType()),
Arguments.arguments(org.hl7.fhir.r5.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateTimeType()),
Arguments.arguments(org.hl7.fhir.r5.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.r5.model.DecimalType()),
Arguments.arguments(org.hl7.fhir.r5.model.InstantType.class.getSimpleName(), new org.hl7.fhir.r5.model.InstantType()),
Arguments.arguments(org.hl7.fhir.r5.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.PositiveIntType()),
Arguments.arguments(org.hl7.fhir.r5.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.UnsignedIntType()),
Arguments.arguments(org.hl7.fhir.r5.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.r5.model.IntegerType()),
Arguments.arguments(org.hl7.fhir.r5.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.r5.model.MarkdownType()),
Arguments.arguments(org.hl7.fhir.r5.model.OidType.class.getSimpleName(), new org.hl7.fhir.r5.model.OidType()),
Arguments.arguments(org.hl7.fhir.r5.model.StringType.class.getSimpleName(), new org.hl7.fhir.r5.model.StringType()),
Arguments.arguments(org.hl7.fhir.r5.model.TimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.TimeType()),
Arguments.arguments(org.hl7.fhir.r5.model.UuidType.class.getSimpleName(), new org.hl7.fhir.r5.model.UuidType()),
Arguments.arguments(org.hl7.fhir.r5.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.r5.model.Base64BinaryType()),
Arguments.arguments(org.hl7.fhir.r5.model.UriType.class.getSimpleName(), new org.hl7.fhir.r5.model.UriType()));
}
}

View File

@ -0,0 +1,67 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.dstu3.model.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
public class VersionConvertorPrimitiveType30_40Test {
@ParameterizedTest(name = "Testing dstu3 -> r4 conversion of null value {0}.")
@MethodSource("dstu3PrimitiveTypes")
public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) {
obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value"));
Assertions.assertNull(((org.hl7.fhir.r4.model.PrimitiveType) VersionConvertor_30_40.convertType(obj)).getValue());
}
@ParameterizedTest(name = "Testing r4 -> dstu3 conversion of null value {0}.")
@MethodSource("r4PrimitiveTypes")
public <T extends org.hl7.fhir.r4.model.PrimitiveType> void testNullValueR4Primitive(String classname, T obj) {
obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.r4.model.StringType("A value"));
Assertions.assertNull(((PrimitiveType) VersionConvertor_30_40.convertType(obj)).getValue());
}
public static Stream<Arguments> dstu3PrimitiveTypes() {
return Stream.of(
Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()),
Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()),
Arguments.arguments(DateType.class.getSimpleName(), new DateType()),
Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()),
Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()),
Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()),
Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()),
Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()),
Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()),
Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()),
Arguments.arguments(OidType.class.getSimpleName(), new OidType()),
Arguments.arguments(StringType.class.getSimpleName(), new StringType()),
Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()),
Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()),
Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()),
Arguments.arguments(UriType.class.getSimpleName(), new UriType()));
}
public static Stream<Arguments> r4PrimitiveTypes() {
return Stream.of(
Arguments.arguments(org.hl7.fhir.r4.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.r4.model.BooleanType()),
Arguments.arguments(org.hl7.fhir.r4.model.CodeType.class.getSimpleName(), new org.hl7.fhir.r4.model.CodeType()),
Arguments.arguments(org.hl7.fhir.r4.model.DateType.class.getSimpleName(), new org.hl7.fhir.r4.model.DateType()),
Arguments.arguments(org.hl7.fhir.r4.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.r4.model.DateTimeType()),
Arguments.arguments(org.hl7.fhir.r4.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.r4.model.DecimalType()),
Arguments.arguments(org.hl7.fhir.r4.model.InstantType.class.getSimpleName(), new org.hl7.fhir.r4.model.InstantType()),
Arguments.arguments(org.hl7.fhir.r4.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.r4.model.PositiveIntType()),
Arguments.arguments(org.hl7.fhir.r4.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.r4.model.UnsignedIntType()),
Arguments.arguments(org.hl7.fhir.r4.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.r4.model.IntegerType()),
Arguments.arguments(org.hl7.fhir.r4.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.r4.model.MarkdownType()),
Arguments.arguments(org.hl7.fhir.r4.model.OidType.class.getSimpleName(), new org.hl7.fhir.r4.model.OidType()),
Arguments.arguments(org.hl7.fhir.r4.model.StringType.class.getSimpleName(), new org.hl7.fhir.r4.model.StringType()),
Arguments.arguments(org.hl7.fhir.r4.model.TimeType.class.getSimpleName(), new org.hl7.fhir.r4.model.TimeType()),
Arguments.arguments(org.hl7.fhir.r4.model.UuidType.class.getSimpleName(), new org.hl7.fhir.r4.model.UuidType()),
Arguments.arguments(org.hl7.fhir.r4.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.r4.model.Base64BinaryType()),
Arguments.arguments(org.hl7.fhir.r4.model.UriType.class.getSimpleName(), new org.hl7.fhir.r4.model.UriType()));
}
}

View File

@ -0,0 +1,67 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.dstu3.model.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
public class VersionConvertorPrimitiveType30_50Test {
@ParameterizedTest(name = "Testing dstu3 -> r5 conversion of null value {0}.")
@MethodSource("dstu3PrimitiveTypes")
public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) {
obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value"));
Assertions.assertNull(((org.hl7.fhir.r5.model.PrimitiveType) VersionConvertor_30_50.convertType(obj)).getValue());
}
@ParameterizedTest(name = "Testing r5 -> dstu3 conversion of null value {0}.")
@MethodSource("r5PrimitiveTypes")
public <T extends org.hl7.fhir.r5.model.PrimitiveType> void testNullValueR5Primitive(String classname, T obj) {
obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.r5.model.StringType("A value"));
Assertions.assertNull(((PrimitiveType) VersionConvertor_30_50.convertType(obj)).getValue());
}
public static Stream<Arguments> dstu3PrimitiveTypes() {
return Stream.of(
Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()),
Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()),
Arguments.arguments(DateType.class.getSimpleName(), new DateType()),
Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()),
Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()),
Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()),
Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()),
Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()),
Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()),
Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()),
Arguments.arguments(OidType.class.getSimpleName(), new OidType()),
Arguments.arguments(StringType.class.getSimpleName(), new StringType()),
Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()),
Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()),
Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()),
Arguments.arguments(UriType.class.getSimpleName(), new UriType()));
}
public static Stream<Arguments> r5PrimitiveTypes() {
return Stream.of(
Arguments.arguments(org.hl7.fhir.r5.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.r5.model.BooleanType()),
Arguments.arguments(org.hl7.fhir.r5.model.CodeType.class.getSimpleName(), new org.hl7.fhir.r5.model.CodeType()),
Arguments.arguments(org.hl7.fhir.r5.model.DateType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateType()),
Arguments.arguments(org.hl7.fhir.r5.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateTimeType()),
Arguments.arguments(org.hl7.fhir.r5.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.r5.model.DecimalType()),
Arguments.arguments(org.hl7.fhir.r5.model.InstantType.class.getSimpleName(), new org.hl7.fhir.r5.model.InstantType()),
Arguments.arguments(org.hl7.fhir.r5.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.PositiveIntType()),
Arguments.arguments(org.hl7.fhir.r5.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.UnsignedIntType()),
Arguments.arguments(org.hl7.fhir.r5.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.r5.model.IntegerType()),
Arguments.arguments(org.hl7.fhir.r5.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.r5.model.MarkdownType()),
Arguments.arguments(org.hl7.fhir.r5.model.OidType.class.getSimpleName(), new org.hl7.fhir.r5.model.OidType()),
Arguments.arguments(org.hl7.fhir.r5.model.StringType.class.getSimpleName(), new org.hl7.fhir.r5.model.StringType()),
Arguments.arguments(org.hl7.fhir.r5.model.TimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.TimeType()),
Arguments.arguments(org.hl7.fhir.r5.model.UuidType.class.getSimpleName(), new org.hl7.fhir.r5.model.UuidType()),
Arguments.arguments(org.hl7.fhir.r5.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.r5.model.Base64BinaryType()),
Arguments.arguments(org.hl7.fhir.r5.model.UriType.class.getSimpleName(), new org.hl7.fhir.r5.model.UriType()));
}
}

View File

@ -0,0 +1,67 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.r4.model.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
public class VersionConvertorPrimitiveType40_50Test {
@ParameterizedTest(name = "Testing r4 -> r5 conversion of null value {0}.")
@MethodSource("r4PrimitiveTypes")
public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) {
obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value"));
Assertions.assertNull(((org.hl7.fhir.r5.model.PrimitiveType) VersionConvertor_40_50.convertType(obj)).getValue());
}
@ParameterizedTest(name = "Testing r5 -> r4 conversion of null value {0}.")
@MethodSource("r5PrimitiveTypes")
public <T extends org.hl7.fhir.r5.model.PrimitiveType> void testNullValueR5Primitive(String classname, T obj) {
obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.r5.model.StringType("A value"));
Assertions.assertNull(((PrimitiveType) VersionConvertor_40_50.convertType(obj)).getValue());
}
public static Stream<Arguments> r4PrimitiveTypes() {
return Stream.of(
Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()),
Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()),
Arguments.arguments(DateType.class.getSimpleName(), new DateType()),
Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()),
Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()),
Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()),
Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()),
Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()),
Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()),
Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()),
Arguments.arguments(OidType.class.getSimpleName(), new OidType()),
Arguments.arguments(StringType.class.getSimpleName(), new StringType()),
Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()),
Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()),
Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()),
Arguments.arguments(UriType.class.getSimpleName(), new UriType()));
}
public static Stream<Arguments> r5PrimitiveTypes() {
return Stream.of(
Arguments.arguments(org.hl7.fhir.r5.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.r5.model.BooleanType()),
Arguments.arguments(org.hl7.fhir.r5.model.CodeType.class.getSimpleName(), new org.hl7.fhir.r5.model.CodeType()),
Arguments.arguments(org.hl7.fhir.r5.model.DateType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateType()),
Arguments.arguments(org.hl7.fhir.r5.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateTimeType()),
Arguments.arguments(org.hl7.fhir.r5.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.r5.model.DecimalType()),
Arguments.arguments(org.hl7.fhir.r5.model.InstantType.class.getSimpleName(), new org.hl7.fhir.r5.model.InstantType()),
Arguments.arguments(org.hl7.fhir.r5.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.PositiveIntType()),
Arguments.arguments(org.hl7.fhir.r5.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.UnsignedIntType()),
Arguments.arguments(org.hl7.fhir.r5.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.r5.model.IntegerType()),
Arguments.arguments(org.hl7.fhir.r5.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.r5.model.MarkdownType()),
Arguments.arguments(org.hl7.fhir.r5.model.OidType.class.getSimpleName(), new org.hl7.fhir.r5.model.OidType()),
Arguments.arguments(org.hl7.fhir.r5.model.StringType.class.getSimpleName(), new org.hl7.fhir.r5.model.StringType()),
Arguments.arguments(org.hl7.fhir.r5.model.TimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.TimeType()),
Arguments.arguments(org.hl7.fhir.r5.model.UuidType.class.getSimpleName(), new org.hl7.fhir.r5.model.UuidType()),
Arguments.arguments(org.hl7.fhir.r5.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.r5.model.Base64BinaryType()),
Arguments.arguments(org.hl7.fhir.r5.model.UriType.class.getSimpleName(), new org.hl7.fhir.r5.model.UriType()));
}
}

View File

@ -14,15 +14,5 @@ public class VersionConvertor_10_30Test {
Assertions.assertEquals(33, output.getValue().intValue()); Assertions.assertEquals(33, output.getValue().intValue());
} }
@Test
@DisplayName("Test 10_30 conversion does null check on UnsignedIntType.")
public void testConvertEmptyValuedUnsignedInt() {
org.hl7.fhir.dstu2.model.UnsignedIntType input = new org.hl7.fhir.dstu2.model.UnsignedIntType();
input.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.dstu2.model.StringType("A value"));
org.hl7.fhir.dstu3.model.UnsignedIntType output;
output = (org.hl7.fhir.dstu3.model.UnsignedIntType)VersionConvertor_10_30.convertType(input);
Assertions.assertNull(output.getValue());
}
} }