diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java index 16826b997..0ad221c62 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java @@ -1,20 +1,11 @@ package org.hl7.fhir.r5.context; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy; import org.hl7.fhir.r5.context.IWorkerContext.PackageVersion; import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.CodeSystem; -import org.hl7.fhir.r5.model.DomainResource; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; import org.hl7.fhir.utilities.VersionUtilities; @@ -28,6 +19,11 @@ import org.hl7.fhir.utilities.VersionUtilities; public class CanonicalResourceManager { + private final String[] INVALID_TERMINOLOGY_URLS = { + "http://snomed.info/sct", + "http://nucc.org/provider-taxonomy" + }; + public static abstract class CanonicalResourceProxy { private String type; private String id; @@ -219,7 +215,11 @@ public class CanonicalResourceManager { public void see(CachedCanonicalResource cr) { // ignore UTG NUCC erroneous code system - if (cr.getPackageInfo() != null && cr.getPackageInfo().getId() != null && cr.getPackageInfo().getId().startsWith("hl7.terminology") && "http://nucc.org/provider-taxonomy".equals(cr.getUrl())) { + if (cr.getPackageInfo() != null + && cr.getPackageInfo().getId() != null + && cr.getPackageInfo().getId().startsWith("hl7.terminology") + && Arrays.stream(INVALID_TERMINOLOGY_URLS).anyMatch((it)->it.equals(cr.getUrl())) + ) { return; } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TestPackageLoader.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestPackageLoader.java similarity index 96% rename from org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TestPackageLoader.java rename to org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestPackageLoader.java index 17c1a4724..130dce1db 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TestPackageLoader.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestPackageLoader.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.context; +package org.hl7.fhir.r5.test.utils; import java.io.IOException; import java.io.InputStream; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java index 8459d7869..d57c785e1 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java @@ -114,6 +114,11 @@ public class TestingUtilities extends BaseTestingUtilities { IWorkerContext fcontext = getWorkerContext(pcm.loadPackage(VersionUtilities.packageForVersion(version), version)); fcontext.setUcumService(new UcumEssenceService(TestingUtilities.loadTestResourceStream("ucum", "ucum-essence.xml"))); fcontext.setExpansionProfile(new Parameters()); + if (!fcontext.hasPackage("hl7.terminology", null)) { + NpmPackage utg = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage("hl7.terminology"); + System.out.println("Loading THO: "+utg.name()+"#"+utg.version()); + fcontext.loadFromPackage(utg, new TestPackageLoader(new String[]{"CodeSystem", "ValueSet"})); + } return fcontext; } catch (Exception e) { e.printStackTrace(); diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java index bfb77e3cb..e3b04f2c7 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java @@ -132,24 +132,24 @@ public class NarrativeGenerationTests { } XhtmlNode x = RendererFactory.factory(source, rc).build(source); - String target = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + ".html")); - String output = HEADER+new XhtmlComposer(true, true).compose(x)+FOOTER; - String tfn = TestingUtilities.tempFile("narrative", test.getId() + ".target.html"); - String ofn = TestingUtilities.tempFile("narrative", test.getId() + ".output.html"); - TextFile.stringToFile(target, tfn); - TextFile.stringToFile(output, ofn); - String msg = TestingUtilities.checkXMLIsSame(ofn, tfn); + String expected = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + ".html")); + String actual = HEADER+new XhtmlComposer(true, true).compose(x)+FOOTER; + String expectedFileName = TestingUtilities.tempFile("narrative", test.getId() + ".expected.html"); + String actualFileName = TestingUtilities.tempFile("narrative", test.getId() + ".actual.html"); + TextFile.stringToFile(expected, expectedFileName); + TextFile.stringToFile(actual, actualFileName); + String msg = TestingUtilities.checkXMLIsSame(actualFileName, expectedFileName); Assertions.assertTrue(msg == null, "Output does not match expected: "+msg); if (test.isMeta()) { org.hl7.fhir.r5.elementmodel.Element e = Manager.parseSingle(context, TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + ".xml"), FhirFormat.XML); x = RendererFactory.factory(source, rc).render(new ElementWrappers.ResourceWrapperMetaElement(rc, e)); - target = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + "-meta.html")); - output = HEADER+new XhtmlComposer(true, true).compose(x)+FOOTER; - ofn = TestingUtilities.tempFile("narrative", test.getId() + "-meta.output.html"); - TextFile.stringToFile(output, ofn); - msg = TestingUtilities.checkXMLIsSame(ofn, tfn); + expected = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + "-meta.html")); + actual = HEADER+new XhtmlComposer(true, true).compose(x)+FOOTER; + actualFileName = TestingUtilities.tempFile("narrative", test.getId() + "-meta.actual.html"); + TextFile.stringToFile(actual, actualFileName); + msg = TestingUtilities.checkXMLIsSame(actualFileName, expectedFileName); Assertions.assertTrue(msg == null, "Meta output does not match expected: "+msg); } } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java index 2155fb195..60b87c159 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java @@ -18,7 +18,7 @@ import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.r5.conformance.ProfileUtilities; import org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider; -import org.hl7.fhir.r5.context.TestPackageLoader; +import org.hl7.fhir.r5.test.utils.TestPackageLoader; import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.XmlParser; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java index cdbf4fe9e..32d8e364b 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.test; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -13,7 +12,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.r5.context.IWorkerContext; -import org.hl7.fhir.r5.context.TestPackageLoader; +import org.hl7.fhir.r5.test.utils.TestPackageLoader; import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.XmlParser; @@ -109,13 +108,8 @@ public class VocabTests { /* Do NOT get a shared worker context from Testing Utilities or else the terminology package loaded below will appear in tests where it causes failures. */ - context = TestingUtilities.getWorkerContext(VersionUtilities.getMajMin(TestingUtilities.DEFAULT_CONTEXT_VERSION)); - if (!context.hasPackage("hl7.terminology", null)) { - - NpmPackage utg = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage("hl7.terminology"); - System.out.println("Loading THO: "+utg.name()+"#"+utg.version()); - context.loadFromPackage(utg, new TestPackageLoader(new String[]{"CodeSystem", "ValueSet"})); - } + context = TestingUtilities.getSharedWorkerContext(VersionUtilities.getMajMin(TestingUtilities.DEFAULT_CONTEXT_VERSION)); + } @ParameterizedTest(name = "{index}: file {0}") @@ -150,13 +144,13 @@ public class VocabTests { if (outcome.isOk()) { outcome.getValueset().getExpansion().setIdentifier(null); outcome.getValueset().getExpansion().setTimestamp(null); - String target = new XmlParser().setOutputStyle(OutputStyle.PRETTY).composeString(targetVS); - String output = new XmlParser().setOutputStyle(OutputStyle.PRETTY).composeString(outcome.getValueset()); - String tfn = TestingUtilities.tempFile("vocab", test.getId() + ".target.html"); - String ofn = TestingUtilities.tempFile("vocab", test.getId() + ".output.html"); - TextFile.stringToFile(target, tfn); - TextFile.stringToFile(output, ofn); - String msg = TestingUtilities.checkXMLIsSame(ofn, tfn); + String expected = new XmlParser().setOutputStyle(OutputStyle.PRETTY).composeString(targetVS); + String actual = new XmlParser().setOutputStyle(OutputStyle.PRETTY).composeString(outcome.getValueset()); + String expectedFileName = TestingUtilities.tempFile("vocab", test.getId() + ".expected.html"); + String actualFileName = TestingUtilities.tempFile("vocab", test.getId() + ".actual.html"); + TextFile.stringToFile(expected, expectedFileName); + TextFile.stringToFile(actual, actualFileName); + String msg = TestingUtilities.checkXMLIsSame(actualFileName, expectedFileName); Assertions.assertTrue(msg == null, "Output does not match expected: "+msg); } else { Assertions.fail("Expansion Failed: "+outcome.getError()); diff --git a/pom.xml b/pom.xml index dc0a17cef..73e580654 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.4.0 - 1.1.94 + 1.1.95 5.7.1 1.7.1 3.0.0-M5