From 72e88cb12f4def6e0f8bf67df2dab96f5e906f05 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Wed, 18 Aug 2021 21:43:39 -0400 Subject: [PATCH] Adding proper null checks for convertor factories. (#579) * wip * wip * sdjkhfakjsdhllkjsdhfsdkh --- .../factory/VersionConvertorFactory.java | 25 +++++ .../VersionConvertorFactory_10_30.java | 14 ++- .../VersionConvertorFactory_10_40.java | 14 ++- .../VersionConvertorFactory_10_50.java | 14 ++- .../VersionConvertorFactory_14_30.java | 14 ++- .../VersionConvertorFactory_14_40.java | 14 ++- .../VersionConvertorFactory_14_50.java | 14 ++- .../VersionConvertorFactory_30_40.java | 14 ++- .../VersionConvertorFactory_30_50.java | 14 ++- .../VersionConvertorFactory_40_50.java | 14 ++- ...onvertorFactory_10_30NullHandlingTest.java | 103 ++++++++++++++++++ ...onvertorFactory_10_40NullHandlingTest.java | 103 ++++++++++++++++++ ...onvertorFactory_10_50NullHandlingTest.java | 103 ++++++++++++++++++ ...onvertorFactory_14_30NullHandlingTest.java | 103 ++++++++++++++++++ ...onvertorFactory_14_40NullHandlingTest.java | 103 ++++++++++++++++++ ...onvertorFactory_14_50NullHandlingTest.java | 103 ++++++++++++++++++ ...onvertorFactory_30_40NullHandlingTest.java | 103 ++++++++++++++++++ ...onvertorFactory_30_50NullHandlingTest.java | 103 ++++++++++++++++++ ...onvertorFactory_40_50NullHandlingTest.java | 103 ++++++++++++++++++ 19 files changed, 1033 insertions(+), 45 deletions(-) create mode 100644 org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory.java create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_30NullHandlingTest.java create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_40NullHandlingTest.java create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_50NullHandlingTest.java create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_30NullHandlingTest.java create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_40NullHandlingTest.java create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_50NullHandlingTest.java create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_40NullHandlingTest.java create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_50NullHandlingTest.java create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_40_50NullHandlingTest.java diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory.java new file mode 100644 index 000000000..0978cb759 --- /dev/null +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory.java @@ -0,0 +1,25 @@ +package org.hl7.fhir.convertors.factory; + +import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.instance.model.api.IBaseDatatype; +import org.hl7.fhir.instance.model.api.IBaseResource; + +public abstract class VersionConvertorFactory { + public static void cleanInputs(IBaseResource res, BaseAdvisor advisor) { + checkDataAndAdvisor(res, advisor); + } + + public static void cleanInputs(IBaseDatatype res, BaseAdvisor advisor) { + checkDataAndAdvisor(res, advisor); + } + + private static void checkDataAndAdvisor(Object o, BaseAdvisor advisor) { + if (advisor == null) { + throw new FHIRException("Null conversion advisor passed to factory method."); + } + if (advisor.failFastOnNullOrUnknownEntry() && o == null) { + throw new FHIRException("ConversionFactory received null input. Conversion advisor set to failFastOnNullInput."); + } + } +} diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_30.java index ee165c3c6..a579df93a 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_30.java @@ -5,14 +5,15 @@ import org.hl7.fhir.convertors.conv10_30.VersionConvertor_10_30; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.utilities.Utilities; -public final class VersionConvertorFactory_10_30 { +public final class VersionConvertorFactory_10_30 extends VersionConvertorFactory { public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src) throws FHIRException { return convertResource(src, new BaseAdvisor_10_30()); } public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, BaseAdvisor_10_30 advisor) throws FHIRException { - return new VersionConvertor_10_30(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_10_30(advisor).convertResource(src) : null; } public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException { @@ -20,7 +21,8 @@ public final class VersionConvertorFactory_10_30 { } public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, BaseAdvisor_10_30 advisor) throws FHIRException { - return new VersionConvertor_10_30(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_10_30(advisor).convertResource(src) : null; } public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.dstu2.model.Type src) throws FHIRException { @@ -28,7 +30,8 @@ public final class VersionConvertorFactory_10_30 { } public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.dstu2.model.Type src, BaseAdvisor_10_30 advisor) throws FHIRException { - return new VersionConvertor_10_30(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_10_30(advisor).convertType(src) : null; } public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { @@ -36,7 +39,8 @@ public final class VersionConvertorFactory_10_30 { } public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.dstu3.model.Type src, BaseAdvisor_10_30 advisor) throws FHIRException { - return new VersionConvertor_10_30(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_10_30(advisor).convertType(src) : null; } public static boolean convertsResource(String rt) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_40.java index bcde07ed9..392def5ff 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_40.java @@ -5,14 +5,15 @@ import org.hl7.fhir.convertors.conv10_40.VersionConvertor_10_40; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.utilities.Utilities; -public final class VersionConvertorFactory_10_40 { +public final class VersionConvertorFactory_10_40 extends VersionConvertorFactory { public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src) throws FHIRException { return convertResource(src, new BaseAdvisor_10_40()); } public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, BaseAdvisor_10_40 advisor) throws FHIRException { - return new VersionConvertor_10_40(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_10_40(advisor).convertResource(src) : null; } public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException { @@ -20,7 +21,8 @@ public final class VersionConvertorFactory_10_40 { } public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, BaseAdvisor_10_40 advisor) throws FHIRException { - return new VersionConvertor_10_40(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_10_40(advisor).convertResource(src) : null; } public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu2.model.Type src) throws FHIRException { @@ -28,7 +30,8 @@ public final class VersionConvertorFactory_10_40 { } public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu2.model.Type src, BaseAdvisor_10_40 advisor) throws FHIRException { - return new VersionConvertor_10_40(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_10_40(advisor).convertType(src) : null; } public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { @@ -36,7 +39,8 @@ public final class VersionConvertorFactory_10_40 { } public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.r4.model.Type src, BaseAdvisor_10_40 advisor) throws FHIRException { - return new VersionConvertor_10_40(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_10_40(advisor).convertType(src) : null; } public static boolean convertsResource(String rt) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_50.java index b675198c8..6fb9f4578 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_50.java @@ -5,14 +5,15 @@ import org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.utilities.Utilities; -public final class VersionConvertorFactory_10_50 { +public final class VersionConvertorFactory_10_50 extends VersionConvertorFactory { public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src) throws FHIRException { return convertResource(src, new BaseAdvisor_10_50()); } public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, BaseAdvisor_10_50 advisor) throws FHIRException { - return new VersionConvertor_10_50(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_10_50(advisor).convertResource(src) : null; } public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException { @@ -20,7 +21,8 @@ public final class VersionConvertorFactory_10_50 { } public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, BaseAdvisor_10_50 advisor) throws FHIRException { - return new VersionConvertor_10_50(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_10_50(advisor).convertResource(src) : null; } public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.dstu2.model.Type src) throws FHIRException { @@ -28,7 +30,8 @@ public final class VersionConvertorFactory_10_50 { } public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.dstu2.model.Type src, BaseAdvisor_10_50 advisor) throws FHIRException { - return new VersionConvertor_10_50(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_10_50(advisor).convertType(src) : null; } public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.r5.model.DataType src) throws FHIRException { @@ -36,7 +39,8 @@ public final class VersionConvertorFactory_10_50 { } public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.r5.model.DataType src, BaseAdvisor_10_50 advisor) throws FHIRException { - return new VersionConvertor_10_50(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_10_50(advisor).convertType(src) : null; } public static boolean convertsResource(String rt) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_30.java index 98c469922..8eb2ba3ae 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_30.java @@ -5,14 +5,15 @@ import org.hl7.fhir.convertors.conv14_30.VersionConvertor_14_30; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.utilities.Utilities; -public final class VersionConvertorFactory_14_30 { +public final class VersionConvertorFactory_14_30 extends VersionConvertorFactory { public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src) throws FHIRException { return convertResource(src, new BaseAdvisor_14_30()); } public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src, BaseAdvisor_14_30 advisor) throws FHIRException { - return new VersionConvertor_14_30(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_14_30(advisor).convertResource(src) : null; } public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException { @@ -20,7 +21,8 @@ public final class VersionConvertorFactory_14_30 { } public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, BaseAdvisor_14_30 advisor) throws FHIRException { - return new VersionConvertor_14_30(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_14_30(advisor).convertResource(src) : null; } public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.dstu2016may.model.Type src) throws FHIRException { @@ -28,7 +30,8 @@ public final class VersionConvertorFactory_14_30 { } public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.dstu2016may.model.Type src, BaseAdvisor_14_30 advisor) throws FHIRException { - return new VersionConvertor_14_30(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_14_30(advisor).convertType(src) : null; } public static org.hl7.fhir.dstu2016may.model.Type convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { @@ -36,7 +39,8 @@ public final class VersionConvertorFactory_14_30 { } public static org.hl7.fhir.dstu2016may.model.Type convertType(org.hl7.fhir.dstu3.model.Type src, BaseAdvisor_14_30 advisor) throws FHIRException { - return new VersionConvertor_14_30(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_14_30(advisor).convertType(src) : null; } public static boolean convertsResource(String rt) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_40.java index bbba58616..80013fedf 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_40.java @@ -5,14 +5,15 @@ import org.hl7.fhir.convertors.conv14_40.VersionConvertor_14_40; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.utilities.Utilities; -public final class VersionConvertorFactory_14_40 { +public final class VersionConvertorFactory_14_40 extends VersionConvertorFactory { public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src) throws FHIRException { return convertResource(src, new BaseAdvisor_14_40()); } public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src, BaseAdvisor_14_40 advisor) throws FHIRException { - return new VersionConvertor_14_40(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_14_40(advisor).convertResource(src) : null; } public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException { @@ -20,7 +21,8 @@ public final class VersionConvertorFactory_14_40 { } public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, BaseAdvisor_14_40 advisor) throws FHIRException { - return new VersionConvertor_14_40(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_14_40(advisor).convertResource(src) : null; } public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu2016may.model.Type src) throws FHIRException { @@ -28,7 +30,8 @@ public final class VersionConvertorFactory_14_40 { } public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu2016may.model.Type src, BaseAdvisor_14_40 advisor) throws FHIRException { - return new VersionConvertor_14_40(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_14_40(advisor).convertType(src) : null; } public static org.hl7.fhir.dstu2016may.model.Type convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { @@ -36,7 +39,8 @@ public final class VersionConvertorFactory_14_40 { } public static org.hl7.fhir.dstu2016may.model.Type convertType(org.hl7.fhir.r4.model.Type src, BaseAdvisor_14_40 advisor) throws FHIRException { - return new VersionConvertor_14_40(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_14_40(advisor).convertType(src) : null; } public static boolean convertsResource(String rt) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_50.java index 34c8b0774..d1ea81c6d 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_50.java @@ -5,14 +5,15 @@ import org.hl7.fhir.convertors.conv14_50.VersionConvertor_14_50; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.utilities.Utilities; -public final class VersionConvertorFactory_14_50 { +public final class VersionConvertorFactory_14_50 extends VersionConvertorFactory { public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src) throws FHIRException { return convertResource(src, new BaseAdvisor_14_50()); } public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src, BaseAdvisor_14_50 advisor) throws FHIRException { - return new VersionConvertor_14_50(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_14_50(advisor).convertResource(src) : null; } public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException { @@ -20,7 +21,8 @@ public final class VersionConvertorFactory_14_50 { } public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, BaseAdvisor_14_50 advisor) throws FHIRException { - return new VersionConvertor_14_50(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_14_50(advisor).convertResource(src) : null; } public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.dstu2016may.model.Type src) throws FHIRException { @@ -28,7 +30,8 @@ public final class VersionConvertorFactory_14_50 { } public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.dstu2016may.model.Type src, BaseAdvisor_14_50 advisor) throws FHIRException { - return new VersionConvertor_14_50(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_14_50(advisor).convertType(src) : null; } public static org.hl7.fhir.dstu2016may.model.Type convertType(org.hl7.fhir.r5.model.DataType src) throws FHIRException { @@ -36,7 +39,8 @@ public final class VersionConvertorFactory_14_50 { } public static org.hl7.fhir.dstu2016may.model.Type convertType(org.hl7.fhir.r5.model.DataType src, BaseAdvisor_14_50 advisor) throws FHIRException { - return new VersionConvertor_14_50(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_14_50(advisor).convertType(src) : null; } public static boolean convertsResource(String rt) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_40.java index fc343cf34..86070124b 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_40.java @@ -5,14 +5,15 @@ import org.hl7.fhir.convertors.conv30_40.VersionConvertor_30_40; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.utilities.Utilities; -public final class VersionConvertorFactory_30_40 { +public final class VersionConvertorFactory_30_40 extends VersionConvertorFactory { public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException { return convertResource(src, new BaseAdvisor_30_40()); } public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, BaseAdvisor_30_40 advisor) throws FHIRException { - return new VersionConvertor_30_40(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_30_40(advisor).convertResource(src) : null; } public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException { @@ -20,7 +21,8 @@ public final class VersionConvertorFactory_30_40 { } public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, BaseAdvisor_30_40 advisor) throws FHIRException { - return new VersionConvertor_30_40(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_30_40(advisor).convertResource(src) : null; } public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { @@ -28,7 +30,8 @@ public final class VersionConvertorFactory_30_40 { } public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu3.model.Type src, BaseAdvisor_30_40 advisor) throws FHIRException { - return new VersionConvertor_30_40(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_30_40(advisor).convertType(src) : null; } public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { @@ -36,7 +39,8 @@ public final class VersionConvertorFactory_30_40 { } public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.r4.model.Type src, BaseAdvisor_30_40 advisor) throws FHIRException { - return new VersionConvertor_30_40(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_30_40(advisor).convertType(src) : null; } public static boolean convertsResource(String rt) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_50.java index 7252ffbf6..d15b2fdfe 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_50.java @@ -4,14 +4,15 @@ import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50; import org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50; import org.hl7.fhir.exceptions.FHIRException; -public final class VersionConvertorFactory_30_50 { +public final class VersionConvertorFactory_30_50 extends VersionConvertorFactory { public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException { return convertResource(src, new BaseAdvisor_30_50()); } public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, BaseAdvisor_30_50 advisor) throws FHIRException { - return new VersionConvertor_30_50(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_30_50(advisor).convertResource(src) : null; } public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException { @@ -19,7 +20,8 @@ public final class VersionConvertorFactory_30_50 { } public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, BaseAdvisor_30_50 advisor) throws FHIRException { - return new VersionConvertor_30_50(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_30_50(advisor).convertResource(src) : null; } public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { @@ -27,7 +29,8 @@ public final class VersionConvertorFactory_30_50 { } public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.dstu3.model.Type src, BaseAdvisor_30_50 advisor) throws FHIRException { - return new VersionConvertor_30_50(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_30_50(advisor).convertType(src) : null; } public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.r5.model.DataType src) throws FHIRException { @@ -35,6 +38,7 @@ public final class VersionConvertorFactory_30_50 { } public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.r5.model.DataType src, BaseAdvisor_30_50 advisor) throws FHIRException { - return new VersionConvertor_30_50(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_30_50(advisor).convertType(src) : null; } } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_40_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_40_50.java index 6eaf55c71..c1dcdf900 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_40_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_40_50.java @@ -4,14 +4,15 @@ import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50; import org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50; import org.hl7.fhir.exceptions.FHIRException; -public final class VersionConvertorFactory_40_50 { +public final class VersionConvertorFactory_40_50 extends VersionConvertorFactory { public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException { return convertResource(src, new BaseAdvisor_40_50()); } public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, BaseAdvisor_40_50 advisor) throws FHIRException { - return new VersionConvertor_40_50(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_40_50(advisor).convertResource(src) : null; } public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException { @@ -19,7 +20,8 @@ public final class VersionConvertorFactory_40_50 { } public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, BaseAdvisor_40_50 advisor) throws FHIRException { - return new VersionConvertor_40_50(advisor).convertResource(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_40_50(advisor).convertResource(src) : null; } public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { @@ -27,7 +29,8 @@ public final class VersionConvertorFactory_40_50 { } public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.r4.model.Type src, BaseAdvisor_40_50 advisor) throws FHIRException { - return new VersionConvertor_40_50(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_40_50(advisor).convertType(src) : null; } public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.r5.model.DataType src) throws FHIRException { @@ -35,6 +38,7 @@ public final class VersionConvertorFactory_40_50 { } public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.r5.model.DataType src, BaseAdvisor_40_50 advisor) throws FHIRException { - return new VersionConvertor_40_50(advisor).convertType(src); + cleanInputs(src, advisor); + return src != null ? new VersionConvertor_40_50(advisor).convertType(src) : null; } } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_30NullHandlingTest.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_30NullHandlingTest.java new file mode 100644 index 000000000..6302d7a3e --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_30NullHandlingTest.java @@ -0,0 +1,103 @@ +package org.hl7.fhir.convertors.factory; + +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_30; +import org.hl7.fhir.exceptions.FHIRException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class VersionConvertorFactory_10_30NullHandlingTest { + + @Test + @DisplayName("Check null DSTU2 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorDSTU2() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_30.convertResource((org.hl7.fhir.dstu2.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null DSTU2 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastDSTU2() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_30.convertResource((org.hl7.fhir.dstu2.model.Resource) null, new BaseAdvisor_10_30(true)); + }); + } + + @Test + @DisplayName("Check null DSTU2 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastDSTU2() { + Assertions.assertNull(VersionConvertorFactory_10_30.convertResource((org.hl7.fhir.dstu2.model.Resource) null, + new BaseAdvisor_10_30(false))); + } + + @Test + @DisplayName("Check null DSTU3 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_30.convertResource((org.hl7.fhir.dstu3.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null DSTU3 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_30.convertResource((org.hl7.fhir.dstu3.model.Resource) null, new BaseAdvisor_10_30(true)); + }); + } + + @Test + @DisplayName("Check null DSTU3 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastDSTU3() { + Assertions.assertNull(VersionConvertorFactory_10_30.convertResource((org.hl7.fhir.dstu3.model.Resource) null, + new BaseAdvisor_10_30(false))); + } + + @Test + @DisplayName("Check null DSTU2 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorDSTU2() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_30.convertType((org.hl7.fhir.dstu2.model.Type) null); + }); + } + + @Test + @DisplayName("Check null DSTU2 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastDSTU2() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_30.convertType((org.hl7.fhir.dstu2.model.Type) null, new BaseAdvisor_10_30(true)); + }); + } + + @Test + @DisplayName("Check null DSTU2 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastDSTU2() { + Assertions.assertNull(VersionConvertorFactory_10_30.convertType((org.hl7.fhir.dstu2.model.Type) null, + new BaseAdvisor_10_30(false))); + } + + @Test + @DisplayName("Check null DSTU3 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_30.convertType((org.hl7.fhir.dstu3.model.Type) null); + }); + } + + @Test + @DisplayName("Check null DSTU3 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_30.convertType((org.hl7.fhir.dstu3.model.Type) null, new BaseAdvisor_10_30(true)); + }); + } + + @Test + @DisplayName("Check null DSTU3 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastDSTU3() { + Assertions.assertNull(VersionConvertorFactory_10_30.convertType((org.hl7.fhir.dstu3.model.Type) null, + new BaseAdvisor_10_30(false))); + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_40NullHandlingTest.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_40NullHandlingTest.java new file mode 100644 index 000000000..566e1b216 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_40NullHandlingTest.java @@ -0,0 +1,103 @@ +package org.hl7.fhir.convertors.factory; + +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40; +import org.hl7.fhir.exceptions.FHIRException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class VersionConvertorFactory_10_40NullHandlingTest { + + @Test + @DisplayName("Check null DSTU2 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorDSTU2() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_40.convertResource((org.hl7.fhir.dstu2.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null DSTU2 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastDSTU2() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_40.convertResource((org.hl7.fhir.dstu2.model.Resource) null, new BaseAdvisor_10_40(true)); + }); + } + + @Test + @DisplayName("Check null DSTU2 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastDSTU2() { + Assertions.assertNull(VersionConvertorFactory_10_40.convertResource((org.hl7.fhir.dstu2.model.Resource) null, + new BaseAdvisor_10_40(false))); + } + + @Test + @DisplayName("Check null R4 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_40.convertResource((org.hl7.fhir.r4.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null R4 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_40.convertResource((org.hl7.fhir.r4.model.Resource) null, new BaseAdvisor_10_40(true)); + }); + } + + @Test + @DisplayName("Check null R4 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastR4() { + Assertions.assertNull(VersionConvertorFactory_10_40.convertResource((org.hl7.fhir.r4.model.Resource) null, + new BaseAdvisor_10_40(false))); + } + + @Test + @DisplayName("Check null DSTU2 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorDSTU2() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_40.convertType((org.hl7.fhir.dstu2.model.Type) null); + }); + } + + @Test + @DisplayName("Check null DSTU2 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastDSTU2() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_40.convertType((org.hl7.fhir.dstu2.model.Type) null, new BaseAdvisor_10_40(true)); + }); + } + + @Test + @DisplayName("Check null DSTU2 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastDSTU2() { + Assertions.assertNull(VersionConvertorFactory_10_40.convertType((org.hl7.fhir.dstu2.model.Type) null, + new BaseAdvisor_10_40(false))); + } + + @Test + @DisplayName("Check null R4 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_40.convertType((org.hl7.fhir.r4.model.Type) null); + }); + } + + @Test + @DisplayName("Check null R4 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_40.convertType((org.hl7.fhir.r4.model.Type) null, new BaseAdvisor_10_40(true)); + }); + } + + @Test + @DisplayName("Check null R4 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastR4() { + Assertions.assertNull(VersionConvertorFactory_10_40.convertType((org.hl7.fhir.r4.model.Type) null, + new BaseAdvisor_10_40(false))); + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_50NullHandlingTest.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_50NullHandlingTest.java new file mode 100644 index 000000000..208e04485 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_10_50NullHandlingTest.java @@ -0,0 +1,103 @@ +package org.hl7.fhir.convertors.factory; + +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50; +import org.hl7.fhir.exceptions.FHIRException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class VersionConvertorFactory_10_50NullHandlingTest { + + @Test + @DisplayName("Check null DSTU2 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorDSTU2() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_50.convertResource((org.hl7.fhir.dstu2.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null DSTU2 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastDSTU2() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_50.convertResource((org.hl7.fhir.dstu2.model.Resource) null, new BaseAdvisor_10_50(true)); + }); + } + + @Test + @DisplayName("Check null DSTU2 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastDSTU2() { + Assertions.assertNull(VersionConvertorFactory_10_50.convertResource((org.hl7.fhir.dstu2.model.Resource) null, + new BaseAdvisor_10_50(false))); + } + + @Test + @DisplayName("Check null R5 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_50.convertResource((org.hl7.fhir.r5.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null R5 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_50.convertResource((org.hl7.fhir.r5.model.Resource) null, new BaseAdvisor_10_50(true)); + }); + } + + @Test + @DisplayName("Check null R5 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastR5() { + Assertions.assertNull(VersionConvertorFactory_10_50.convertResource((org.hl7.fhir.r5.model.Resource) null, + new BaseAdvisor_10_50(false))); + } + + @Test + @DisplayName("Check null DSTU2 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorDSTU2() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_50.convertType((org.hl7.fhir.dstu2.model.Type) null); + }); + } + + @Test + @DisplayName("Check null DSTU2 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastDSTU2() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_50.convertType((org.hl7.fhir.dstu2.model.Type) null, new BaseAdvisor_10_50(true)); + }); + } + + @Test + @DisplayName("Check null DSTU2 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastDSTU2() { + Assertions.assertNull(VersionConvertorFactory_10_50.convertType((org.hl7.fhir.dstu2.model.Type) null, + new BaseAdvisor_10_50(false))); + } + + @Test + @DisplayName("Check null R5 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_50.convertType((org.hl7.fhir.r5.model.DataType) null); + }); + } + + @Test + @DisplayName("Check null R5 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_10_50.convertType((org.hl7.fhir.r5.model.DataType) null, new BaseAdvisor_10_50(true)); + }); + } + + @Test + @DisplayName("Check null R5 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastR5() { + Assertions.assertNull(VersionConvertorFactory_10_50.convertType((org.hl7.fhir.r5.model.DataType) null, + new BaseAdvisor_10_50(false))); + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_30NullHandlingTest.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_30NullHandlingTest.java new file mode 100644 index 000000000..6d83580ae --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_30NullHandlingTest.java @@ -0,0 +1,103 @@ +package org.hl7.fhir.convertors.factory; + +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_30; +import org.hl7.fhir.exceptions.FHIRException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class VersionConvertorFactory_14_30NullHandlingTest { + + @Test + @DisplayName("Check null DSTU2016MAY resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorDSTU2016MAY() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_30.convertResource((org.hl7.fhir.dstu2016may.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null DSTU2016MAY resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastDSTU2016MAY() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_30.convertResource((org.hl7.fhir.dstu2016may.model.Resource) null, new BaseAdvisor_14_30(true)); + }); + } + + @Test + @DisplayName("Check null DSTU2016MAY resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastDSTU2016MAY() { + Assertions.assertNull(VersionConvertorFactory_14_30.convertResource((org.hl7.fhir.dstu2016may.model.Resource) null, + new BaseAdvisor_14_30(false))); + } + + @Test + @DisplayName("Check null DSTU3 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_30.convertResource((org.hl7.fhir.dstu3.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null DSTU3 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_30.convertResource((org.hl7.fhir.dstu3.model.Resource) null, new BaseAdvisor_14_30(true)); + }); + } + + @Test + @DisplayName("Check null DSTU3 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastDSTU3() { + Assertions.assertNull(VersionConvertorFactory_14_30.convertResource((org.hl7.fhir.dstu3.model.Resource) null, + new BaseAdvisor_14_30(false))); + } + + @Test + @DisplayName("Check null DSTU2016MAY type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorDSTU2016MAY() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_30.convertType((org.hl7.fhir.dstu2016may.model.Type) null); + }); + } + + @Test + @DisplayName("Check null DSTU2016MAY type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastDSTU2016MAY() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_30.convertType((org.hl7.fhir.dstu2016may.model.Type) null, new BaseAdvisor_14_30(true)); + }); + } + + @Test + @DisplayName("Check null DSTU2016MAY type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastDSTU2016MAY() { + Assertions.assertNull(VersionConvertorFactory_14_30.convertType((org.hl7.fhir.dstu2016may.model.Type) null, + new BaseAdvisor_14_30(false))); + } + + @Test + @DisplayName("Check null DSTU3 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_30.convertType((org.hl7.fhir.dstu3.model.Type) null); + }); + } + + @Test + @DisplayName("Check null DSTU3 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_30.convertType((org.hl7.fhir.dstu3.model.Type) null, new BaseAdvisor_14_30(true)); + }); + } + + @Test + @DisplayName("Check null DSTU3 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastDSTU3() { + Assertions.assertNull(VersionConvertorFactory_14_30.convertType((org.hl7.fhir.dstu3.model.Type) null, + new BaseAdvisor_14_30(false))); + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_40NullHandlingTest.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_40NullHandlingTest.java new file mode 100644 index 000000000..14e94ea63 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_40NullHandlingTest.java @@ -0,0 +1,103 @@ +package org.hl7.fhir.convertors.factory; + +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_40; +import org.hl7.fhir.exceptions.FHIRException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class VersionConvertorFactory_14_40NullHandlingTest { + + @Test + @DisplayName("Check null DSTU2016MAY resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorDSTU2016MAY() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_40.convertResource((org.hl7.fhir.dstu2016may.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null DSTU2016MAY resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastDSTU2016MAY() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_40.convertResource((org.hl7.fhir.dstu2016may.model.Resource) null, new BaseAdvisor_14_40(true)); + }); + } + + @Test + @DisplayName("Check null DSTU2016MAY resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastDSTU2016MAY() { + Assertions.assertNull(VersionConvertorFactory_14_40.convertResource((org.hl7.fhir.dstu2016may.model.Resource) null, + new BaseAdvisor_14_40(false))); + } + + @Test + @DisplayName("Check null R4 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_40.convertResource((org.hl7.fhir.r4.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null R4 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_40.convertResource((org.hl7.fhir.r4.model.Resource) null, new BaseAdvisor_14_40(true)); + }); + } + + @Test + @DisplayName("Check null R4 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastR4() { + Assertions.assertNull(VersionConvertorFactory_14_40.convertResource((org.hl7.fhir.r4.model.Resource) null, + new BaseAdvisor_14_40(false))); + } + + @Test + @DisplayName("Check null DSTU2016MAY type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorDSTU2016MAY() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_40.convertType((org.hl7.fhir.dstu2016may.model.Type) null); + }); + } + + @Test + @DisplayName("Check null DSTU2016MAY type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastDSTU2016MAY() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_40.convertType((org.hl7.fhir.dstu2016may.model.Type) null, new BaseAdvisor_14_40(true)); + }); + } + + @Test + @DisplayName("Check null DSTU2016MAY type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastDSTU2016MAY() { + Assertions.assertNull(VersionConvertorFactory_14_40.convertType((org.hl7.fhir.dstu2016may.model.Type) null, + new BaseAdvisor_14_40(false))); + } + + @Test + @DisplayName("Check null R4 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_40.convertType((org.hl7.fhir.r4.model.Type) null); + }); + } + + @Test + @DisplayName("Check null R4 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_40.convertType((org.hl7.fhir.r4.model.Type) null, new BaseAdvisor_14_40(true)); + }); + } + + @Test + @DisplayName("Check null R4 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastR4() { + Assertions.assertNull(VersionConvertorFactory_14_40.convertType((org.hl7.fhir.r4.model.Type) null, + new BaseAdvisor_14_40(false))); + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_50NullHandlingTest.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_50NullHandlingTest.java new file mode 100644 index 000000000..7f54c4491 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_14_50NullHandlingTest.java @@ -0,0 +1,103 @@ +package org.hl7.fhir.convertors.factory; + +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_50; +import org.hl7.fhir.exceptions.FHIRException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class VersionConvertorFactory_14_50NullHandlingTest { + + @Test + @DisplayName("Check null DSTU2016MAY resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorDSTU2016MAY() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null DSTU2016MAY resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastDSTU2016MAY() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) null, new BaseAdvisor_14_50(true)); + }); + } + + @Test + @DisplayName("Check null DSTU2016MAY resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastDSTU2016MAY() { + Assertions.assertNull(VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) null, + new BaseAdvisor_14_50(false))); + } + + @Test + @DisplayName("Check null R5 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.r5.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null R5 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.r5.model.Resource) null, new BaseAdvisor_14_50(true)); + }); + } + + @Test + @DisplayName("Check null R5 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastR5() { + Assertions.assertNull(VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.r5.model.Resource) null, + new BaseAdvisor_14_50(false))); + } + + @Test + @DisplayName("Check null DSTU2016MAY type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorDSTU2016MAY() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_50.convertType((org.hl7.fhir.dstu2016may.model.Type) null); + }); + } + + @Test + @DisplayName("Check null DSTU2016MAY type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastDSTU2016MAY() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_50.convertType((org.hl7.fhir.dstu2016may.model.Type) null, new BaseAdvisor_14_50(true)); + }); + } + + @Test + @DisplayName("Check null DSTU2016MAY type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastDSTU2016MAY() { + Assertions.assertNull(VersionConvertorFactory_14_50.convertType((org.hl7.fhir.dstu2016may.model.Type) null, + new BaseAdvisor_14_50(false))); + } + + @Test + @DisplayName("Check null R5 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_50.convertType((org.hl7.fhir.r5.model.DataType) null); + }); + } + + @Test + @DisplayName("Check null R5 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_14_50.convertType((org.hl7.fhir.r5.model.DataType) null, new BaseAdvisor_14_50(true)); + }); + } + + @Test + @DisplayName("Check null R5 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastR5() { + Assertions.assertNull(VersionConvertorFactory_14_50.convertType((org.hl7.fhir.r5.model.DataType) null, + new BaseAdvisor_14_50(false))); + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_40NullHandlingTest.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_40NullHandlingTest.java new file mode 100644 index 000000000..4b9f548f6 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_40NullHandlingTest.java @@ -0,0 +1,103 @@ +package org.hl7.fhir.convertors.factory; + +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40; +import org.hl7.fhir.exceptions.FHIRException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class VersionConvertorFactory_30_40NullHandlingTest { + + @Test + @DisplayName("Check null DSTU3 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_40.convertResource((org.hl7.fhir.dstu3.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null DSTU3 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_40.convertResource((org.hl7.fhir.dstu3.model.Resource) null, new BaseAdvisor_30_40(true)); + }); + } + + @Test + @DisplayName("Check null DSTU3 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastDSTU3() { + Assertions.assertNull(VersionConvertorFactory_30_40.convertResource((org.hl7.fhir.dstu3.model.Resource) null, + new BaseAdvisor_30_40(false))); + } + + @Test + @DisplayName("Check null R4 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_40.convertResource((org.hl7.fhir.r4.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null R4 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_40.convertResource((org.hl7.fhir.r4.model.Resource) null, new BaseAdvisor_30_40(true)); + }); + } + + @Test + @DisplayName("Check null R4 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastR4() { + Assertions.assertNull(VersionConvertorFactory_30_40.convertResource((org.hl7.fhir.r4.model.Resource) null, + new BaseAdvisor_30_40(false))); + } + + @Test + @DisplayName("Check null DSTU3 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_40.convertType((org.hl7.fhir.dstu3.model.Type) null); + }); + } + + @Test + @DisplayName("Check null DSTU3 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_40.convertType((org.hl7.fhir.dstu3.model.Type) null, new BaseAdvisor_30_40(true)); + }); + } + + @Test + @DisplayName("Check null DSTU3 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastDSTU3() { + Assertions.assertNull(VersionConvertorFactory_30_40.convertType((org.hl7.fhir.dstu3.model.Type) null, + new BaseAdvisor_30_40(false))); + } + + @Test + @DisplayName("Check null R4 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_40.convertType((org.hl7.fhir.r4.model.Type) null); + }); + } + + @Test + @DisplayName("Check null R4 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_40.convertType((org.hl7.fhir.r4.model.Type) null, new BaseAdvisor_30_40(true)); + }); + } + + @Test + @DisplayName("Check null R4 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastR4() { + Assertions.assertNull(VersionConvertorFactory_30_40.convertType((org.hl7.fhir.r4.model.Type) null, + new BaseAdvisor_30_40(false))); + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_50NullHandlingTest.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_50NullHandlingTest.java new file mode 100644 index 000000000..7e3069e76 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_30_50NullHandlingTest.java @@ -0,0 +1,103 @@ +package org.hl7.fhir.convertors.factory; + +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50; +import org.hl7.fhir.exceptions.FHIRException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class VersionConvertorFactory_30_50NullHandlingTest { + + @Test + @DisplayName("Check null DSTU3 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null DSTU3 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) null, new BaseAdvisor_30_50(true)); + }); + } + + @Test + @DisplayName("Check null DSTU3 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastDSTU3() { + Assertions.assertNull(VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) null, + new BaseAdvisor_30_50(false))); + } + + @Test + @DisplayName("Check null R5 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.r5.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null R5 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.r5.model.Resource) null, new BaseAdvisor_30_50(true)); + }); + } + + @Test + @DisplayName("Check null R5 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastR5() { + Assertions.assertNull(VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.r5.model.Resource) null, + new BaseAdvisor_30_50(false))); + } + + @Test + @DisplayName("Check null DSTU3 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_50.convertType((org.hl7.fhir.dstu3.model.Type) null); + }); + } + + @Test + @DisplayName("Check null DSTU3 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastDSTU3() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_50.convertType((org.hl7.fhir.dstu3.model.Type) null, new BaseAdvisor_30_50(true)); + }); + } + + @Test + @DisplayName("Check null DSTU3 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastDSTU3() { + Assertions.assertNull(VersionConvertorFactory_30_50.convertType((org.hl7.fhir.dstu3.model.Type) null, + new BaseAdvisor_30_50(false))); + } + + @Test + @DisplayName("Check null R5 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_50.convertType((org.hl7.fhir.r5.model.DataType) null); + }); + } + + @Test + @DisplayName("Check null R5 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_30_50.convertType((org.hl7.fhir.r5.model.DataType) null, new BaseAdvisor_30_50(true)); + }); + } + + @Test + @DisplayName("Check null R5 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastR5() { + Assertions.assertNull(VersionConvertorFactory_30_50.convertType((org.hl7.fhir.r5.model.DataType) null, + new BaseAdvisor_30_50(false))); + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_40_50NullHandlingTest.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_40_50NullHandlingTest.java new file mode 100644 index 000000000..331d10a1e --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/factory/VersionConvertorFactory_40_50NullHandlingTest.java @@ -0,0 +1,103 @@ +package org.hl7.fhir.convertors.factory; + +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50; +import org.hl7.fhir.exceptions.FHIRException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class VersionConvertorFactory_40_50NullHandlingTest { + + @Test + @DisplayName("Check null R4 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r4.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null R4 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r4.model.Resource) null, new BaseAdvisor_40_50(true)); + }); + } + + @Test + @DisplayName("Check null R4 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastR4() { + Assertions.assertNull(VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r4.model.Resource) null, + new BaseAdvisor_40_50(false))); + } + + @Test + @DisplayName("Check null R5 resource with default advisor throws FHIRException.") + void convertResourceWithDefaultAdvisorR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r5.model.Resource) null); + }); + } + + @Test + @DisplayName("Check null R5 resource with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertResourceWithCustomAdvisorSetToFailFastR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r5.model.Resource) null, new BaseAdvisor_40_50(true)); + }); + } + + @Test + @DisplayName("Check null R5 resource with custom advisor returns null when advisor set to not fail fast.") + void convertResourceWithCustomAdvisorSetToNotFailFastR5() { + Assertions.assertNull(VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r5.model.Resource) null, + new BaseAdvisor_40_50(false))); + } + + @Test + @DisplayName("Check null R4 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_40_50.convertType((org.hl7.fhir.r4.model.Type) null); + }); + } + + @Test + @DisplayName("Check null R4 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastR4() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_40_50.convertType((org.hl7.fhir.r4.model.Type) null, new BaseAdvisor_40_50(true)); + }); + } + + @Test + @DisplayName("Check null R4 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastR4() { + Assertions.assertNull(VersionConvertorFactory_40_50.convertType((org.hl7.fhir.r4.model.Type) null, + new BaseAdvisor_40_50(false))); + } + + @Test + @DisplayName("Check null R5 type with default advisor throws FHIRException.") + void convertTypeWithDefaultAdvisorR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_40_50.convertType((org.hl7.fhir.r5.model.DataType) null); + }); + } + + @Test + @DisplayName("Check null R5 type with custom advisor throws FHIRException when advisor is set to fail fast.") + void convertTypeWithCustomAdvisorSetToFailFastR5() { + Assertions.assertThrows(FHIRException.class, () -> { + VersionConvertorFactory_40_50.convertType((org.hl7.fhir.r5.model.DataType) null, new BaseAdvisor_40_50(true)); + }); + } + + @Test + @DisplayName("Check null R5 type with custom advisor returns null when advisor set to not fail fast.") + void convertTypeWithCustomAdvisorSetToNotFailFastR5() { + Assertions.assertNull(VersionConvertorFactory_40_50.convertType((org.hl7.fhir.r5.model.DataType) null, + new BaseAdvisor_40_50(false))); + } + +} \ No newline at end of file