From 21479bffa78a9e2f73bdb06e254f038a54c6b822 Mon Sep 17 00:00:00 2001 From: Oliver Egger Date: Tue, 9 Jun 2020 22:50:16 +0200 Subject: [PATCH 01/16] don't escape umlaut in utf8 --- .../fhir/r5/test/ResourceRoundTripTests.java | 24 +++++++++++++++++++ .../org/hl7/fhir/utilities/xml/XMLWriter.java | 14 +---------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java index ba462e423..404afd102 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java @@ -1,13 +1,19 @@ package org.hl7.fhir.r5.test; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.List; import org.apache.commons.io.IOUtils; import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r5.elementmodel.Element; +import org.hl7.fhir.r5.elementmodel.Manager; +import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat; import org.hl7.fhir.r5.formats.IParser; import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.JsonParser; @@ -55,4 +61,22 @@ public class ResourceRoundTripTests { throw new FHIRException("Bundle was null"); } + @Test + /** + * verify that umlaut like äö etc are not encoded in UTF-8 in attributes + */ + public void testSerializeUmlaut() throws IOException { + Element xml = Manager.parse(TestingUtilities.context(), TestingUtilities.loadTestResourceStream("r5", "unicode.xml"), + FhirFormat.XML); + List concept = xml.getChildrenByName("concept"); + assertTrue(concept!=null && concept.size()==1); + List code = concept.get(0).getChildrenByName("code"); + assertTrue(code!=null && code.size()==1); + code.get(0).setValue("ö"); + ByteArrayOutputStream baosXml = new ByteArrayOutputStream(); + Manager.compose(TestingUtilities.context(), xml, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null); + String cdaSerialised = baosXml.toString(); + assertTrue(cdaSerialised.indexOf("0); + } + } \ No newline at end of file diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java index fd4fec5bc..8a2f7cd4b 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java @@ -246,7 +246,7 @@ public class XMLWriter extends OutputStreamWriter implements IXMLWriter { write(element[0]); write("=\""); if (element[1] != null) - write(xmlEscape(element[1])); + write(XMLUtil.escapeXML(element[1], charset, false)); write("\""); } } @@ -254,18 +254,6 @@ public class XMLWriter extends OutputStreamWriter implements IXMLWriter { return col; } - protected String xmlEscape(String s) { - StringBuilder b = new StringBuilder(); - for (char c : s.toCharArray()) { - if (c < ' ' || c > '~') { - b.append("&#x"); - b.append(Integer.toHexString(c).toUpperCase()); - b.append(";"); - } else - b.append(c); - } - return b.toString(); - } /* (non-Javadoc) * @see org.eclipse.ohf.utilities.xml.IXMLWriter#attribute(java.lang.String, java.lang.String, java.lang.String, boolean) */ From 101b1c7cde4c091e184252d3ae459362a40cf524 Mon Sep 17 00:00:00 2001 From: Oliver Egger Date: Wed, 10 Jun 2020 13:30:04 +0200 Subject: [PATCH 02/16] revert, but escape only < ' ' char --- .../org/hl7/fhir/utilities/xml/XMLWriter.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java index 8a2f7cd4b..4b30c125f 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java @@ -246,7 +246,7 @@ public class XMLWriter extends OutputStreamWriter implements IXMLWriter { write(element[0]); write("=\""); if (element[1] != null) - write(XMLUtil.escapeXML(element[1], charset, false)); + write(xmlEscape(element[1])); write("\""); } } @@ -254,7 +254,20 @@ public class XMLWriter extends OutputStreamWriter implements IXMLWriter { return col; } - /* (non-Javadoc) + protected String xmlEscape(String s) { + StringBuilder b = new StringBuilder(); + for (char c : s.toCharArray()) { + if (c < ' ') { + b.append("&#x"); + b.append(Integer.toHexString(c).toUpperCase()); + b.append(";"); + } else + b.append(c); + } + return b.toString(); + } + + /* (non-Javadoc) * @see org.eclipse.ohf.utilities.xml.IXMLWriter#attribute(java.lang.String, java.lang.String, java.lang.String, boolean) */ @Override From 47722ef63ca8e48126ecd17f56258a8d8bba3ca5 Mon Sep 17 00:00:00 2001 From: Oliver Egger Date: Wed, 10 Jun 2020 13:53:37 +0200 Subject: [PATCH 03/16] windows test fix --- .../java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java index 404afd102..4d4bcf27e 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java @@ -75,8 +75,8 @@ public class ResourceRoundTripTests { code.get(0).setValue("ö"); ByteArrayOutputStream baosXml = new ByteArrayOutputStream(); Manager.compose(TestingUtilities.context(), xml, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null); - String cdaSerialised = baosXml.toString(); - assertTrue(cdaSerialised.indexOf("0); + String cdaSerialised = baosXml.toString("UTF-8"); + assertTrue(cdaSerialised.indexOf("ö")>0); } } \ No newline at end of file From a9abd8f824e6eb5186fa2ac5c77efb01f2cb2a45 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Wed, 11 Aug 2021 10:07:43 -0400 Subject: [PATCH 04/16] https://github.com/hapifhir/org.hl7.fhir.core/issues/557 (#571) --- .../org/hl7/fhir/r4/utils/FHIRPathEngine.java | 60 +++++++++--------- .../org/hl7/fhir/r5/utils/FHIRPathEngine.java | 62 +++++++++---------- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/FHIRPathEngine.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/FHIRPathEngine.java index 31701df2f..67391afa3 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/FHIRPathEngine.java @@ -26,34 +26,34 @@ import org.hl7.fhir.utilities.Utilities; import java.math.BigDecimal; import java.util.*; -/* - Copyright (c) 2011+, HL7, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of HL7 nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - */ +/* + Copyright (c) 2011+, HL7, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + */ /** @@ -4291,11 +4291,11 @@ public class FHIRPathEngine { focus = sd.getSnapshot().getElementFirstRep(); } else if ("extension".equals(expr.getName())) { String targetUrl = expr.getParameters().get(0).getConstant().primitiveValue(); -// targetUrl = targetUrl.substring(1,targetUrl.length()-1); List childDefinitions = ProfileUtilities.getChildMap(sd, element); for (ElementDefinition t : childDefinitions) { if (t.getPath().endsWith(".extension") && t.hasSliceName()) { - StructureDefinition exsd = worker.fetchResource(StructureDefinition.class, t.getType().get(0).getProfile().get(0).getValue()); + StructureDefinition exsd = (t.getType() == null || t.getType().isEmpty()) ? + null : worker.fetchResource(StructureDefinition.class, t.getType().get(0).getProfile().get(0).getValue()); while (exsd!=null && !exsd.getBaseDefinition().equals("http://hl7.org/fhir/StructureDefinition/Extension")) exsd = worker.fetchResource(StructureDefinition.class, exsd.getBaseDefinition()); if (exsd.getUrl().equals(targetUrl)) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java index 8fe761030..928a86037 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java @@ -70,34 +70,34 @@ import org.hl7.fhir.utilities.xhtml.XhtmlNode; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import ca.uhn.fhir.util.ElementUtil; -/* - Copyright (c) 2011+, HL7, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of HL7 nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - */ +/* + Copyright (c) 2011+, HL7, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + */ /** @@ -5493,12 +5493,12 @@ public class FHIRPathEngine { focus = sd.getSnapshot().getElementFirstRep(); } else if ("extension".equals(expr.getName())) { String targetUrl = expr.getParameters().get(0).getConstant().primitiveValue(); - // targetUrl = targetUrl.substring(1,targetUrl.length()-1); List childDefinitions = profileUtilities.getChildMap(sd, element); for (ElementDefinition t : childDefinitions) { if (t.getPath().endsWith(".extension") && t.hasSliceName()) { - StructureDefinition exsd = worker.fetchResource(StructureDefinition.class, t.getType().get(0).getProfile().get(0).getValue()); - while (exsd!=null && !exsd.getBaseDefinition().equals("http://hl7.org/fhir/StructureDefinition/Extension")) { + StructureDefinition exsd = (t.getType() == null || t.getType().isEmpty()) ? + null : worker.fetchResource(StructureDefinition.class, t.getType().get(0).getProfile().get(0).getValue()); + while (exsd != null && !exsd.getBaseDefinition().equals("http://hl7.org/fhir/StructureDefinition/Extension")) { exsd = worker.fetchResource(StructureDefinition.class, exsd.getBaseDefinition()); } if (exsd != null && exsd.getUrl().equals(targetUrl)) { From 66b9e180e6749317db18998d75029750e5398697 Mon Sep 17 00:00:00 2001 From: jnmeijer Date: Wed, 11 Aug 2021 15:44:20 -0400 Subject: [PATCH 05/16] Improved performance of hashNWS (#570) (#573) Co-authored-by: Jonathan Meijer --- .../java/org/hl7/fhir/r4/context/TerminologyCache.java | 8 ++++++-- .../java/org/hl7/fhir/r5/context/TerminologyCache.java | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/TerminologyCache.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/TerminologyCache.java index fe21697f9..acd05391e 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/TerminologyCache.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/TerminologyCache.java @@ -41,6 +41,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r4.context.IWorkerContext.ValidationResult; import org.hl7.fhir.r4.formats.IParser.OutputStyle; @@ -59,12 +60,12 @@ import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; +import org.hl7.fhir.utilities.validation.ValidationOptions; import com.google.gson.JsonElement; import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; -import org.hl7.fhir.utilities.validation.ValidationOptions; /** * This implements a two level cache. @@ -393,7 +394,10 @@ public class TerminologyCache { } private String hashNWS(String s) { - return String.valueOf(s.replace("\r", "").replace("\n", "").replace(" ", "").hashCode()); + s = StringUtils.remove(s, ' '); + s = StringUtils.remove(s, '\n'); + s = StringUtils.remove(s, '\r'); + return String.valueOf(s.hashCode()); } // management diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/TerminologyCache.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/TerminologyCache.java index ae60d7fcc..cabac030d 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/TerminologyCache.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/TerminologyCache.java @@ -41,6 +41,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.context.IWorkerContext.ValidationResult; import org.hl7.fhir.r5.formats.IParser.OutputStyle; @@ -403,7 +404,10 @@ public class TerminologyCache { } private String hashNWS(String s) { - return String.valueOf(s.replace("\r", "").replace("\n", "").replace(" ", "").hashCode()); + s = StringUtils.remove(s, ' '); + s = StringUtils.remove(s, '\n'); + s = StringUtils.remove(s, '\r'); + return String.valueOf(s.hashCode()); } // management From 6e5108afcc98452da8d60a19bbafbb86d144d90d Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 18 Aug 2021 07:05:41 +1000 Subject: [PATCH 06/16] Fix tests for attack on packages2.fhir.org --- .../npm/FilesystemPackageCacheManager.java | 2 +- .../tests/CachingPackageClientTests.java | 28 +++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java index 985fce8ce..ddaccd08e 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java @@ -88,7 +88,7 @@ import java.util.Map.Entry; public class FilesystemPackageCacheManager extends BasePackageCacheManager implements IPackageCacheManager { public static final String PRIMARY_SERVER = "http://packages.fhir.org"; - public static final String SECONDARY_SERVER = "http://packages2.fhir.org/packages"; + public static final String SECONDARY_SERVER = "https://packages2.fhir.org/packages"; // private static final String SECONDARY_SERVER = "http://local.fhir.org:960/packages"; public static final String PACKAGE_REGEX = "^[a-zA-Z][A-Za-z0-9\\_\\-]*(\\.[A-Za-z0-9\\_\\-]+)+$"; public static final String PACKAGE_VERSION_REGEX = "^[A-Za-z][A-Za-z0-9\\_\\-]*(\\.[A-Za-z0-9\\_\\-]+)+\\#[A-Za-z0-9\\-\\_]+(\\.[A-Za-z0-9\\-\\_]+)*$"; diff --git a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/tests/CachingPackageClientTests.java b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/tests/CachingPackageClientTests.java index c4534d237..ae1a56bb6 100644 --- a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/tests/CachingPackageClientTests.java +++ b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/tests/CachingPackageClientTests.java @@ -10,9 +10,13 @@ import java.util.List; public class CachingPackageClientTests { + private static final String SERVER1 = "http://packages.fhir.org"; + private static final String SERVER2 = "https://packages2.fhir.org/packages"; +// private static final String SERVER2 = "http://local.fhir.org:960/packages"; + @Test public void testExists() throws IOException { - CachingPackageClient client = new CachingPackageClient("http://packages.fhir.org"); + CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER1); Assertions.assertTrue(client.exists("hl7.fhir.r4.core", "4.0.1")); Assertions.assertTrue(!client.exists("hl7.fhir.r4.core", "1.0.2")); Assertions.assertTrue(client.exists("HL7.fhir.r4.core", "4.0.1")); @@ -21,14 +25,14 @@ public class CachingPackageClientTests { @Test public void testCase() throws IOException { - CachingPackageClient client = new CachingPackageClient("http://packages.fhir.org"); + CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER1); Assertions.assertTrue(client.exists("kbv.basis", "1.1.3")); Assertions.assertTrue(client.exists("KBV.Basis", "1.1.3")); } @Test public void testSearch() throws IOException { - CachingPackageClient client = new CachingPackageClient("http://packages.fhir.org"); + CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER1); List matches = client.search("core", null, null, false); for (PackageInfo pi : matches) { System.out.println(pi.toString()); @@ -38,14 +42,14 @@ public class CachingPackageClientTests { @Test public void testSearchNoMatches() throws IOException { - CachingPackageClient client = new CachingPackageClient("http://packages.fhir.org"); + CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER1); List matches = client.search("corezxxx", null, null, false); Assertions.assertTrue(matches.size() == 0); } @Test public void testVersions() throws IOException { - CachingPackageClient client = new CachingPackageClient("http://packages.fhir.org"); + CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER1); List matches = client.getVersions("Simplifier.Core.STU3"); for (PackageInfo pi : matches) { System.out.println(pi.toString()); @@ -55,14 +59,14 @@ public class CachingPackageClientTests { @Test public void testVersionsNone() throws IOException { - CachingPackageClient client = new CachingPackageClient("http://packages.fhir.org"); + CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER1); List matches = client.getVersions("Simplifier.Core.STU3X"); Assertions.assertTrue(matches.size() == 0); } @Test public void testExists2() throws IOException { - CachingPackageClient client = new CachingPackageClient("http://packages2.fhir.org/packages"); + CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER2); Assertions.assertTrue(client.exists("hl7.fhir.r4.core", "4.0.1")); Assertions.assertTrue(!client.exists("hl7.fhir.r4.core", "1.0.2")); Assertions.assertTrue(!client.exists("hl7.fhir.nothing", "1.0.1")); @@ -71,7 +75,7 @@ public class CachingPackageClientTests { @Test public void testSearch2() throws IOException { - CachingPackageClient client = new CachingPackageClient("http://packages2.fhir.org/packages"); + CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER2); List matches = client.search("core", null, null, false); for (PackageInfo pi : matches) { System.out.println(pi.toString()); @@ -81,14 +85,14 @@ public class CachingPackageClientTests { @Test public void testSearchNoMatches2() throws IOException { - CachingPackageClient client = new CachingPackageClient("http://packages2.fhir.org/packages"); + CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER2); List matches = client.search("corezxxx", null, null, false); Assertions.assertTrue(matches.size() == 0); } @Test public void testVersions2() throws IOException { - CachingPackageClient client = new CachingPackageClient("http://packages2.fhir.org/packages"); + CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER2); List matches = client.getVersions("Simplifier.Core.STU3"); for (PackageInfo pi : matches) { System.out.println(pi.toString()); @@ -98,7 +102,7 @@ public class CachingPackageClientTests { @Test public void testVersions2A() throws IOException { - CachingPackageClient client = new CachingPackageClient("http://packages2.fhir.org/packages"); + CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER2); List matches = client.getVersions("hl7.fhir.us.core"); for (PackageInfo pi : matches) { System.out.println(pi.toString()); @@ -108,7 +112,7 @@ public class CachingPackageClientTests { @Test public void testVersionsNone2() throws IOException { - CachingPackageClient client = new CachingPackageClient("http://packages2.fhir.org/packages"); + CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER2); List matches = client.getVersions("Simplifier.Core.STU3X"); Assertions.assertTrue(matches.size() == 0); } From 3508a22b563bfc7f798de856bdf4c7a03ba48806 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Wed, 18 Aug 2021 21:15:05 -0400 Subject: [PATCH 07/16] Update pull-request-pipeline.yml for Azure Pipelines Upping java version to deal with ssl properly. --- pull-request-pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pull-request-pipeline.yml b/pull-request-pipeline.yml index d3bf9cc03..ebc0e522f 100644 --- a/pull-request-pipeline.yml +++ b/pull-request-pipeline.yml @@ -30,7 +30,7 @@ steps: mavenPomFile: 'pom.xml' mavenOptions: '-Xmx3072m' javaHomeOption: 'JDKVersion' - jdkVersionOption: '1.8' + jdkVersionOption: '1.11' jdkArchitectureOption: 'x64' publishJUnitResults: true testResultsFiles: '**/surefire-reports/TEST-*.xml' @@ -41,7 +41,7 @@ steps: mavenPomFile: 'pom.xml' mavenOptions: '-Xmx3072m' javaHomeOption: 'JDKVersion' - jdkVersionOption: '1.8' + jdkVersionOption: '1.11' jdkArchitectureOption: 'x64' options: '-pl org.hl7.fhir.validation.cli' publishJUnitResults: false From a02114e34d30f035584e2814a51fce5c5330f258 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Wed, 18 Aug 2021 21:37:23 -0400 Subject: [PATCH 08/16] Update master-branch-pipeline.yml for Azure Pipelines Upping java version to 11 for pipeline. --- master-branch-pipeline.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/master-branch-pipeline.yml b/master-branch-pipeline.yml index da4881cca..c19016493 100644 --- a/master-branch-pipeline.yml +++ b/master-branch-pipeline.yml @@ -86,6 +86,9 @@ steps: inputs: mavenPomFile: '$(System.DefaultWorkingDirectory)/pom.xml' goals: deploy + javaHomeOption: 'JDKVersion' + jdkVersionOption: '1.11' + jdkArchitectureOption: 'x64' options: '--settings $(System.DefaultWorkingDirectory)/settings.xml -pl "!org.hl7.fhir.report, !org.hl7.fhir.validation.cli" -DdeployToSonatype' publishJUnitResults: false @@ -96,5 +99,8 @@ steps: inputs: mavenPomFile: '$(System.DefaultWorkingDirectory)/pom.xml' goals: deploy + javaHomeOption: 'JDKVersion' + jdkVersionOption: '1.11' + jdkArchitectureOption: 'x64' options: '--settings $(System.DefaultWorkingDirectory)/settings.xml -pl "!org.hl7.fhir.report, !org.hl7.fhir.validation.cli" -Dmaven.test.skip -DdeployToGitHub' publishJUnitResults: false From 72e88cb12f4def6e0f8bf67df2dab96f5e906f05 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Wed, 18 Aug 2021 21:43:39 -0400 Subject: [PATCH 09/16] 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 From c06a3652caa5fd48622b8f552d099182ab17271e Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Wed, 18 Aug 2021 21:49:45 -0400 Subject: [PATCH 10/16] Update release-branch-pipeline.yml for Azure Pipelines Upping java sdk version to 11 to deal with TLS1.3 issue with packages2 server. --- release-branch-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-branch-pipeline.yml b/release-branch-pipeline.yml index 3fcf5dc3b..3b477a9a9 100644 --- a/release-branch-pipeline.yml +++ b/release-branch-pipeline.yml @@ -58,7 +58,7 @@ steps: mavenPomFile: 'pom.xml' mavenOptions: '-Xmx3072m' javaHomeOption: 'JDKVersion' - jdkVersionOption: '1.8' + jdkVersionOption: '1.11' jdkArchitectureOption: 'x64' publishJUnitResults: true testResultsFiles: '**/surefire-reports/TEST-*.xml' From 085312659717cdd1ad040e18b14140992de2d091 Mon Sep 17 00:00:00 2001 From: markiantorno Date: Thu, 19 Aug 2021 02:26:11 +0000 Subject: [PATCH 11/16] Release: v5.4.10 * Conversion context added to conversions process * Users can now define custom behavior for CodeSystems, Extensions, BundleEntries, and Types by extending BaseAdvisor. * Resource Conversions are now thread-safe, each using their own instance of the conversion context that is unique * ConversionFactory classes are statically accessed, to minimize changes downstream * I need to add more tests, there were very few to begin with, and it's my next task * All conversion libraries and no play makes Mark a dull boy ***NO_CI*** --- org.hl7.fhir.convertors/pom.xml | 2 +- org.hl7.fhir.dstu2/pom.xml | 2 +- org.hl7.fhir.dstu2016may/pom.xml | 2 +- org.hl7.fhir.dstu3/pom.xml | 2 +- org.hl7.fhir.r4/pom.xml | 2 +- org.hl7.fhir.r5/pom.xml | 2 +- org.hl7.fhir.report/pom.xml | 2 +- org.hl7.fhir.utilities/pom.xml | 2 +- org.hl7.fhir.validation.cli/pom.xml | 2 +- org.hl7.fhir.validation/pom.xml | 2 +- pom.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index e8429d0e7..36dae8fe2 100644 --- a/org.hl7.fhir.convertors/pom.xml +++ b/org.hl7.fhir.convertors/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10-SNAPSHOT + 5.4.10 ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index 6cd896893..2d84161f6 100644 --- a/org.hl7.fhir.dstu2/pom.xml +++ b/org.hl7.fhir.dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10-SNAPSHOT + 5.4.10 ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index 50842ac3e..9edc26e0d 100644 --- a/org.hl7.fhir.dstu2016may/pom.xml +++ b/org.hl7.fhir.dstu2016may/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10-SNAPSHOT + 5.4.10 ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index 7b2f02235..cf23406cd 100644 --- a/org.hl7.fhir.dstu3/pom.xml +++ b/org.hl7.fhir.dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10-SNAPSHOT + 5.4.10 ../pom.xml diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index 8e61e2a1b..c58d51dfc 100644 --- a/org.hl7.fhir.r4/pom.xml +++ b/org.hl7.fhir.r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10-SNAPSHOT + 5.4.10 ../pom.xml diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index 347eb1e56..1e12e6540 100644 --- a/org.hl7.fhir.r5/pom.xml +++ b/org.hl7.fhir.r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10-SNAPSHOT + 5.4.10 ../pom.xml diff --git a/org.hl7.fhir.report/pom.xml b/org.hl7.fhir.report/pom.xml index b2ae53d0b..e872848f8 100644 --- a/org.hl7.fhir.report/pom.xml +++ b/org.hl7.fhir.report/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10-SNAPSHOT + 5.4.10 ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index ceb2c511f..6e89b70f7 100644 --- a/org.hl7.fhir.utilities/pom.xml +++ b/org.hl7.fhir.utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10-SNAPSHOT + 5.4.10 ../pom.xml diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index ca7232039..d5406866a 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10-SNAPSHOT + 5.4.10 ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index 36ec34a97..15987f002 100644 --- a/org.hl7.fhir.validation/pom.xml +++ b/org.hl7.fhir.validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10-SNAPSHOT + 5.4.10 ../pom.xml diff --git a/pom.xml b/pom.xml index e0c8746b5..e32145dce 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ HAPI FHIR --> org.hl7.fhir.core - 5.4.10-SNAPSHOT + 5.4.10 pom From 9a66c87a053fc87b7b836b4c508456c66c292867 Mon Sep 17 00:00:00 2001 From: markiantorno Date: Thu, 19 Aug 2021 02:59:51 +0000 Subject: [PATCH 12/16] Updating version to: 5.4.11-SNAPSHOT and incrementing test cases dependency. --- RELEASE_NOTES.md | 6 ------ org.hl7.fhir.convertors/pom.xml | 2 +- org.hl7.fhir.dstu2/pom.xml | 2 +- org.hl7.fhir.dstu2016may/pom.xml | 2 +- org.hl7.fhir.dstu3/pom.xml | 2 +- org.hl7.fhir.r4/pom.xml | 2 +- org.hl7.fhir.r5/pom.xml | 2 +- org.hl7.fhir.report/pom.xml | 2 +- org.hl7.fhir.utilities/pom.xml | 2 +- org.hl7.fhir.validation.cli/pom.xml | 2 +- org.hl7.fhir.validation/pom.xml | 2 +- pom.xml | 2 +- 12 files changed, 11 insertions(+), 17 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 377191606..e69de29bb 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +0,0 @@ -* Conversion context added to conversions process -* Users can now define custom behavior for CodeSystems, Extensions, BundleEntries, and Types by extending BaseAdvisor. -* Resource Conversions are now thread-safe, each using their own instance of the conversion context that is unique -* ConversionFactory classes are statically accessed, to minimize changes downstream -* I need to add more tests, there were very few to begin with, and it's my next task -* All conversion libraries and no play makes Mark a dull boy diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index 36dae8fe2..7d9ff6293 100644 --- a/org.hl7.fhir.convertors/pom.xml +++ b/org.hl7.fhir.convertors/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10 + 5.4.11-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index 2d84161f6..dcf5f98b8 100644 --- a/org.hl7.fhir.dstu2/pom.xml +++ b/org.hl7.fhir.dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10 + 5.4.11-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index 9edc26e0d..df49729e8 100644 --- a/org.hl7.fhir.dstu2016may/pom.xml +++ b/org.hl7.fhir.dstu2016may/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10 + 5.4.11-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index cf23406cd..b5af82294 100644 --- a/org.hl7.fhir.dstu3/pom.xml +++ b/org.hl7.fhir.dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10 + 5.4.11-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index c58d51dfc..1833ddaba 100644 --- a/org.hl7.fhir.r4/pom.xml +++ b/org.hl7.fhir.r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10 + 5.4.11-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index 1e12e6540..a74b287b5 100644 --- a/org.hl7.fhir.r5/pom.xml +++ b/org.hl7.fhir.r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10 + 5.4.11-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.report/pom.xml b/org.hl7.fhir.report/pom.xml index e872848f8..277eaba70 100644 --- a/org.hl7.fhir.report/pom.xml +++ b/org.hl7.fhir.report/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10 + 5.4.11-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index 6e89b70f7..7502aaf29 100644 --- a/org.hl7.fhir.utilities/pom.xml +++ b/org.hl7.fhir.utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10 + 5.4.11-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index d5406866a..a3b7f1d61 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10 + 5.4.11-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index 15987f002..b149b619a 100644 --- a/org.hl7.fhir.validation/pom.xml +++ b/org.hl7.fhir.validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.4.10 + 5.4.11-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index e32145dce..621736b85 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ HAPI FHIR --> org.hl7.fhir.core - 5.4.10 + 5.4.11-SNAPSHOT pom From 968e6432ed4f12d4b2e4d8a99ce548554cd6a782 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 20 Aug 2021 08:27:45 +1000 Subject: [PATCH 13/16] Actually fix US Core 4.0.0 references --- .../src/main/java/org/hl7/fhir/utilities/npm/PackageHacker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageHacker.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageHacker.java index 928e7d0d3..ae63fbc85 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageHacker.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageHacker.java @@ -142,7 +142,7 @@ public class PackageHacker { // https://github.com/HL7/fhir-ig-publisher/issues/295 if (webref.contains("hl7.org/fhir/us/core/STU4.0.0")) { - webref.replace("hl7.org/fhir/us/core/STU4.0.0", "hl7.org/fhir/us/core/STU4"); + return webref.replace("hl7.org/fhir/us/core/STU4.0.0", "hl7.org/fhir/us/core/STU4"); } if (isUseSecureReferences()) { From 36413d55b80d9006d461837664a1603ff0fc84c5 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 20 Aug 2021 08:28:11 +1000 Subject: [PATCH 14/16] fix up isAbsoluteUrl check --- .../src/main/java/org/hl7/fhir/utilities/Utilities.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java index 4a4a53ea3..9a6d306ca 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java @@ -1095,7 +1095,9 @@ public class Utilities { public static boolean isAbsoluteUrl(String ref) { if (ref != null && ref.contains(":")) { String scheme = ref.substring(0, ref.indexOf(":")); - return existsInList(scheme, "http", "https", "urn") || isToken(scheme) || Utilities.startsWithInList(ref, "urn:iso:", "urn:iso-iec:", "urn:iso-cie:", "urn:iso-astm:", "urn:iso-ieee:", "urn:iec:"); // rfc5141 + String details = ref.substring(ref.indexOf(":")+1); + return (existsInList(scheme, "http", "https", "urn") || isToken(scheme) || Utilities.startsWithInList(ref, "urn:iso:", "urn:iso-iec:", "urn:iso-cie:", "urn:iso-astm:", "urn:iso-ieee:", "urn:iec:")) + && details != null && details.length() > 0 && !details.contains(" "); // rfc5141 } return false; } From 59902b6b9a496b198e2964434e6a9953624622cd Mon Sep 17 00:00:00 2001 From: Lloyd McKenzie Date: Fri, 20 Aug 2021 13:57:03 -0600 Subject: [PATCH 15/16] Expose showMessagesFromReferences on the CLI as it provides much more useful information when validating Bundles. --- .../org/hl7/fhir/validation/ValidationEngine.java | 2 ++ .../hl7/fhir/validation/cli/model/CliContext.java | 13 +++++++++++++ .../validation/cli/services/ValidationService.java | 1 + .../org/hl7/fhir/validation/cli/utils/Params.java | 3 +++ 4 files changed, 19 insertions(+) diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java index 8f08ad884..d03d0161f 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java @@ -149,6 +149,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IPackageInst @Getter @Setter private boolean securityChecks; @Getter @Setter private boolean crumbTrails; @Getter @Setter private boolean allowExampleUrls; + @Getter @Setter private boolean showMessagesFromReferences; @Getter @Setter private Locale locale; @Getter @Setter private List igs = new ArrayList<>(); @Getter @Setter private boolean showTimes; @@ -495,6 +496,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IPackageInst validator.setSecurityChecks(securityChecks); validator.setCrumbTrails(crumbTrails); validator.setAllowExamples(allowExampleUrls); + validator.setShowMessagesFromReferences(showMessagesFromReferences); validator.getContext().setLocale(locale); validator.setFetcher(this); validator.getImplementationGuides().addAll(igs); diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java index 606c11ec5..ea44a9eca 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java @@ -26,6 +26,8 @@ public class CliContext { private boolean hintAboutNonMustSupport = false; @JsonProperty("recursive") private boolean recursive = false; + @JsonProperty("showMessagesFromReferences") + private boolean showMessagesFromReferences = false; @JsonProperty("doDebug") private boolean doDebug = false; @JsonProperty("assumeValidRestReferences") @@ -200,6 +202,17 @@ public class CliContext { return this; } + @JsonProperty("showMessagesFromReferences") + public boolean isShowMessagesFromReferences() { + return showMessagesFromReferences; + } + + @JsonProperty("showMessagesFromReferences") + public CliContext setShowMessagesFromReferences(boolean showMessagesFromReferences) { + this.showMessagesFromReferences = showMessagesFromReferences; + return this; + } + @JsonProperty("locale") public String getLanguageCode() { return locale; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java index 66d34c653..703be35cf 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java @@ -242,6 +242,7 @@ public class ValidationService { validator.setLocale(cliContext.getLocale()); validator.setSnomedExtension(cliContext.getSnomedCTCode()); validator.setAssumeValidRestReferences(cliContext.isAssumeValidRestReferences()); + validator.setShowMessagesFromReferences(cliContext.isShowMessagesFromReferences()); validator.setNoExtensibleBindingMessages(cliContext.isNoExtensibleBindingMessages()); validator.setNoInvariantChecks(cliContext.isNoInvariants()); validator.setWantInvariantInMessage(cliContext.isWantInvariantsInMessages()); diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java index 650803ce1..63948d855 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java @@ -24,6 +24,7 @@ public class Params { public static final String DEBUG = "-debug"; public static final String SCT = "-sct"; public static final String RECURSE = "-recurse"; + public static final String SHOW_MESSAGES_FROM_REFERENCES = "-showReferenceMessages"; public static final String LOCALE = "-locale"; public static final String STRICT_EXTENSIONS = "-strictExtensions"; public static final String HINT_ABOUT_NON_MUST_SUPPORT = "-hintAboutNonMustSupport"; @@ -148,6 +149,8 @@ public class Params { cliContext.setSnomedCT(args[++i]); } else if (args[i].equals(RECURSE)) { cliContext.setRecursive(true); + } else if (args[i].equals(SHOW_MESSAGES_FROM_REFERENCES)) { + cliContext.setShowMessagesFromReferences(true); } else if (args[i].equals(LOCALE)) { if (i + 1 == args.length) { throw new Error("Specified -locale without indicating locale"); From 4e96d087c9799199dd63930a72ae19edbda22c03 Mon Sep 17 00:00:00 2001 From: Lloyd McKenzie Date: Sat, 21 Aug 2021 10:10:32 -0600 Subject: [PATCH 16/16] Added documentation --- RELEASE_NOTES.md | 1 + org.hl7.fhir.validation/src/main/resources/help.txt | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e69de29bb..46d41d7a8 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -0,0 +1 @@ +Exposed showMessagesFromReferences on the command line interface to support reporting validation errors on referenced types (particularly useful when validating messages & documents) \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/main/resources/help.txt b/org.hl7.fhir.validation/src/main/resources/help.txt index bf0d13dbe..5daf15475 100644 --- a/org.hl7.fhir.validation/src/main/resources/help.txt +++ b/org.hl7.fhir.validation/src/main/resources/help.txt @@ -41,6 +41,12 @@ The following parameters are supported: Note: the profile (and it's dependencies) have to be made available through one of the -ig parameters. Note that package dependencies will automatically be resolved +-showReferenceMessages + Includes validation messages resulting from validating target resources + against profiles defined on a reference. This increases the volume of + validationmessages, but may allow easier debugging. If not specified, + then only a high-level message indicating that the referenced item wasn't + valid against the listed profile(s) will be provided. -questionnaire mode: what to do with when validating QuestionnaireResponse resources none (default): just ignore the questionnaire reference required: check that the QuestionnaireResponse has a questionnaire and validate against it