From a5974bc8a547eff929f954d9e5ddb9af37d485d8 Mon Sep 17 00:00:00 2001 From: dotasek Date: Mon, 21 Mar 2022 11:19:54 -0400 Subject: [PATCH] Add tests + changes for 30_50 direct conversion --- .../primitivetypes30_50/Decimal30_50.java | 2 +- .../primitivetypes30_50/String30_50.java | 2 +- .../VersionConvertorPrimitiveTypeTests.java | 21 +++++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/datatypes30_50/primitivetypes30_50/Decimal30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/datatypes30_50/primitivetypes30_50/Decimal30_50.java index 691163ea2..c772d387e 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/datatypes30_50/primitivetypes30_50/Decimal30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/datatypes30_50/primitivetypes30_50/Decimal30_50.java @@ -17,7 +17,7 @@ public class Decimal30_50 { } public static org.hl7.fhir.dstu3.model.DecimalType convertInteger64(org.hl7.fhir.r5.model.Integer64Type src) throws FHIRException { - org.hl7.fhir.dstu3.model.DecimalType tgt = new org.hl7.fhir.dstu3.model.DecimalType(src.getValue().toString()); + org.hl7.fhir.dstu3.model.DecimalType tgt = new org.hl7.fhir.dstu3.model.DecimalType(src.getValueAsString()); ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/datatypes30_50/primitivetypes30_50/String30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/datatypes30_50/primitivetypes30_50/String30_50.java index 3dfd45652..a92bad3da 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/datatypes30_50/primitivetypes30_50/String30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/datatypes30_50/primitivetypes30_50/String30_50.java @@ -17,7 +17,7 @@ public class String30_50 { } public static org.hl7.fhir.r5.model.MarkdownType convertStringToMarkdown(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); + org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValueAsString()) : new org.hl7.fhir.r5.model.MarkdownType(); ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); return tgt; } diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveTypeTests.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveTypeTests.java index 0afb26704..680b8ce46 100644 --- a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveTypeTests.java +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveTypeTests.java @@ -1,14 +1,12 @@ package org.hl7.fhir.convertors; -import org.hl7.fhir.convertors.context.ConversionContext10_30; -import org.hl7.fhir.convertors.context.ConversionContext10_40; -import org.hl7.fhir.convertors.context.ConversionContext10_50; -import org.hl7.fhir.convertors.context.ConversionContext14_50; +import org.hl7.fhir.convertors.context.*; import org.hl7.fhir.convertors.conv10_30.VersionConvertor_10_30; import org.hl7.fhir.convertors.conv10_40.VersionConvertor_10_40; import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Canonical10_40; import org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50; import org.hl7.fhir.convertors.conv14_50.VersionConvertor_14_50; +import org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50; import org.hl7.fhir.convertors.factory.*; import org.hl7.fhir.r4.model.CanonicalType; import org.junit.jupiter.api.Assertions; @@ -925,7 +923,20 @@ public class VersionConvertorPrimitiveTypeTests { org.hl7.fhir.dstu2016may.model.StringType.class, org.hl7.fhir.r5.model.MarkdownType.class, (Function) org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.String14_50::convertStringToMarkdown, STRING_STRINGS, STRING_STRINGS + ), + + //30_50 + Arguments.of( + org.hl7.fhir.r5.model.Integer64Type.class, org.hl7.fhir.dstu3.model.DecimalType.class, + (Function) org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Decimal30_50::convertInteger64, + POSITIVE_INT_STRINGS, POSITIVE_INT_STRINGS + ), + Arguments.of( + org.hl7.fhir.dstu3.model.StringType.class, org.hl7.fhir.r5.model.MarkdownType.class, + (Function) org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50::convertStringToMarkdown, + STRING_STRINGS, STRING_STRINGS ) + ); } @@ -940,6 +951,7 @@ public class VersionConvertorPrimitiveTypeTests { ConversionContext10_40.INSTANCE.init(mock(VersionConvertor_10_40.class), CONTEXT_PATH); ConversionContext10_50.INSTANCE.init(mock(VersionConvertor_10_50.class), CONTEXT_PATH); ConversionContext14_50.INSTANCE.init(mock(VersionConvertor_14_50.class), CONTEXT_PATH); + ConversionContext30_50.INSTANCE.init(mock(VersionConvertor_30_50.class), CONTEXT_PATH); Method srcSetValueAsStringMethod = srcTypeClazz.getMethod("setValueAsString", String.class); @@ -974,5 +986,6 @@ public class VersionConvertorPrimitiveTypeTests { ConversionContext10_40.INSTANCE.close(CONTEXT_PATH); ConversionContext10_50.INSTANCE.close(CONTEXT_PATH); ConversionContext14_50.INSTANCE.close(CONTEXT_PATH); + ConversionContext30_50.INSTANCE.close(CONTEXT_PATH); } }