diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_30Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_30Test.java index 1f08808a9..1b1accf9a 100644 --- a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_30Test.java +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_30Test.java @@ -5,7 +5,6 @@ import org.hl7.fhir.dstu2.model.CodeType; import org.hl7.fhir.dstu2.model.DateType; import org.hl7.fhir.dstu2.model.DateTimeType; 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.PositiveIntType; 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.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.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import java.io.Serializable; import java.util.stream.Stream; public class VersionConvertorPrimitiveType10_30Test { - - - @Test - @DisplayName("Test 10_30 UnsignedIntType preserves value on conversion.") - 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 void testNullValuePrimitive(T obj) { - obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.dstu3.model.StringType("A value")); + @ParameterizedTest(name = "Testing dstu2 -> dstu3 conversion of null value {0}.") + @MethodSource("dstu2PrimitiveTypes") + public void testNullValueDstu2Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value")); Assertions.assertNull(((org.hl7.fhir.dstu3.model.PrimitiveType) VersionConvertor_10_30.convertType(obj)).getValue()); } - public Stream PrimitiveTypes() { - return Stream.of(new UnsignedIntType(), new Base64BinaryType()); + @ParameterizedTest(name = "Testing dstu3 -> dstu2 conversion of null value {0}.") + @MethodSource("Dstu3PrimitiveTypes") + public 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 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 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())); + } } diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_40Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_40Test.java new file mode 100644 index 000000000..d6c04a959 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_40Test.java @@ -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 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 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 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 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())); + } +} + diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_50Test.java new file mode 100644 index 000000000..aba2d717f --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_50Test.java @@ -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 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 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 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 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())); + } +} + diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType30_40Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType30_40Test.java new file mode 100644 index 000000000..58bb89d35 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType30_40Test.java @@ -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 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 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 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 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())); + } +} + diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType30_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType30_50Test.java new file mode 100644 index 000000000..385a46d10 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType30_50Test.java @@ -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 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 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 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 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())); + } +} + diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType40_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType40_50Test.java new file mode 100644 index 000000000..53e8a1767 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType40_50Test.java @@ -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 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 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 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 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())); + } +} + diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertor_10_30Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertor_10_30Test.java index f9134d1c5..f16b5a3c8 100644 --- a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertor_10_30Test.java +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertor_10_30Test.java @@ -14,15 +14,5 @@ public class VersionConvertor_10_30Test { 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()); - } - }