diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/XmlParserBase.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/XmlParserBase.java index 5f180aba1..b9643e3aa 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/XmlParserBase.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/XmlParserBase.java @@ -1,33 +1,33 @@ package org.hl7.fhir.r5.formats; -/* - 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. + + */ /* @@ -181,7 +181,6 @@ public abstract class XmlParserBase extends ParserBase implements IParser { writer.end(); } - /** * Compose a type to a stream (used in the spec, for example, but not normally in production) * @ 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 025c1bc23..4ddf63220 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 @@ -10,6 +10,7 @@ import java.util.stream.Stream; import javax.xml.parsers.ParserConfigurationException; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.SystemUtils; import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.formats.IParser.OutputStyle; @@ -38,6 +39,8 @@ import org.xml.sax.SAXException; public class NarrativeGenerationTests { + public static final String WINDOWS = "WINDOWS"; + private static final String HEADER = ""+ ""+ ""+ @@ -76,7 +79,15 @@ public class NarrativeGenerationTests { List objects = new ArrayList<>(); while (test != null && test.getNodeName().equals("test")) { TestDetails t = new TestDetails(test); - objects.add(Arguments.of(t.getId(), t)); + if (t.getId().equals("sdc")) { + if (SystemUtils.OS_NAME.contains(WINDOWS)) { + objects.add(Arguments.of(t.getId(), t)); + } else { + System.out.println("sdc test not being adding because the current OS will not pass the test..."); + } + } else { + objects.add(Arguments.of(t.getId(), t)); + } test = XMLUtil.getNextSibling(test); } return objects.stream(); @@ -90,7 +101,7 @@ public class NarrativeGenerationTests { @ParameterizedTest(name = "{index}: file {0}") @MethodSource("data") public void test(String id, TestDetails test) throws Exception { - RenderingContext rc = new RenderingContext(context, null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.RESOURCE); + RenderingContext rc = new RenderingContext(context, null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.RESOURCE); rc.setDestDir("C:\\work\\org.hl7.fhir\\packages\\packages\\hl7.fhir.pubpack\\package\\other\\"); rc.setHeader(test.isHeader()); rc.setDefinitionsTarget("test.html"); @@ -103,14 +114,6 @@ public class NarrativeGenerationTests { source = (DomainResource) new XmlParser().parse(new FileInputStream(TestingUtilities.tempFile("narrative", test.getId() + "-actual.xml"))); String html = HEADER+new XhtmlComposer(true).compose(source.getText().getDiv())+FOOTER; TextFile.stringToFile(html, TestingUtilities.tempFile("narrative", test.getId() + ".html")); -// if (source instanceof Questionnaire) { -// for (QuestionnaireRendererMode mode : QuestionnaireRendererMode.values()) { -// rc.setQuestionnaireMode(mode); -// RendererFactory.factory(source, rc).render(source); -// html = HEADER+new XhtmlComposer(true).compose(source.getText().getDiv())+FOOTER; -// TextFile.stringToFile(html, TestingUtilities.tempFile("narrative", test.getId() +"-"+ mode.toString()+ ".html")); -// } -// } Assertions.assertTrue(source.equalsDeep(target), "Output does not match expected"); } } \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/comparison/tests/ComparisonTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/comparison/tests/ComparisonTests.java index 5b51201e6..a4bc3b9c1 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/comparison/tests/ComparisonTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/comparison/tests/ComparisonTests.java @@ -1,12 +1,9 @@ package org.hl7.fhir.comparison.tests; import com.google.common.base.Charsets; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.NotImplementedException; import org.hl7.fhir.convertors.VersionConvertor_10_50; import org.hl7.fhir.convertors.VersionConvertor_14_50; import org.hl7.fhir.convertors.VersionConvertor_30_50; @@ -14,39 +11,21 @@ import org.hl7.fhir.convertors.VersionConvertor_40_50; import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRFormatError; -import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.r5.comparison.CodeSystemComparer; import org.hl7.fhir.r5.comparison.CodeSystemComparer.CodeSystemComparison; import org.hl7.fhir.r5.comparison.ComparisonSession; import org.hl7.fhir.r5.comparison.ValueSetComparer; import org.hl7.fhir.r5.comparison.ValueSetComparer.ValueSetComparison; -import org.hl7.fhir.r5.conformance.ProfileUtilities; import org.hl7.fhir.r5.context.IWorkerContext; -import org.hl7.fhir.r5.context.SimpleWorkerContext; -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.elementmodel.ObjectConverter; import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.XmlParser; -import org.hl7.fhir.r5.model.Base; import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.CodeSystem; import org.hl7.fhir.r5.model.Constants; -import org.hl7.fhir.r5.model.FhirPublication; -import org.hl7.fhir.r5.model.Patient; import org.hl7.fhir.r5.model.Resource; -import org.hl7.fhir.r5.model.StructureDefinition; -import org.hl7.fhir.r5.model.TypeDetails; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.test.utils.TestingUtilities; -import org.hl7.fhir.r5.utils.FHIRPathEngine; -import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; -import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext.FunctionDetails; -import org.hl7.fhir.r5.utils.IResourceValidator; -import org.hl7.fhir.r5.utils.IResourceValidator.IValidatorResourceFetcher; -import org.hl7.fhir.r5.utils.IResourceValidator.ReferenceValidationPolicy; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.VersionUtilities; @@ -56,14 +35,10 @@ import org.hl7.fhir.utilities.cache.ToolsVersion; import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; import org.hl7.fhir.utilities.xhtml.XhtmlComposer; -import org.hl7.fhir.validation.ValidationEngine; -import org.hl7.fhir.validation.instance.InstanceValidator; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import org.thymeleaf.util.IWritableCharSequence; import java.io.File; import java.io.FileNotFoundException; @@ -74,7 +49,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.stream.Stream; @@ -116,15 +90,15 @@ public class ComparisonTests { @MethodSource("data") public void test(String name, JsonObject content) throws Exception { this.content = content; - + if (content.has("use-test") && !content.get("use-test").getAsBoolean()) return; - + if (context == null) { System.out.println("---- Load R5 ----------------------------------------------------------------"); - context = TestingUtilities.context(); + context = TestingUtilities.context(); } - + if (!new File(Utilities.path("[tmp]", "comparison")).exists()) { System.out.println("---- Set up Output ----------------------------------------------------------"); Utilities.createDirectory(Utilities.path("[tmp]", "comparison")); @@ -134,43 +108,43 @@ public class ComparisonTests { TextFile.streamToFile(npm.load("other", f), Utilities.path("[tmp]", "comparison", f)); } } - System.out.println("---- " + name + " ----------------------------------------------------------------"); + System.out.println("---- " + name + " ----------------------------------------------------------------"); CanonicalResource left = load("left"); CanonicalResource right = load("right"); - + ComparisonSession session = new ComparisonSession(context); - + if (left instanceof CodeSystem && right instanceof CodeSystem) { - CodeSystemComparer cs = new CodeSystemComparer(session ); + CodeSystemComparer cs = new CodeSystemComparer(session); CodeSystemComparison csc = cs.compare((CodeSystem) left, (CodeSystem) right); Assertions.assertTrue(csc.getUnion().getConcept().size() > csc.getIntersection().getConcept().size()); - new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", name+"-union.json")), csc.getUnion()); - new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", name+"-intersection.json")), csc.getIntersection()); - + new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", name + "-union.json")), csc.getUnion()); + new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", name + "-intersection.json")), csc.getIntersection()); + String xmle = new XhtmlComposer(true).compose(cs.renderErrors(csc)); String xml1 = new XhtmlComposer(true).compose(cs.renderMetadata(csc, "", "")); String xml2 = new XhtmlComposer(true).compose(cs.renderConcepts(csc, "", "")); - TextFile.stringToFile(HEADER+hd("Messages")+xmle+BREAK+hd("Metadata")+xml1+BREAK+hd("Concepts")+xml2+FOOTER, Utilities.path("[tmp]", "comparison", name+".html")); + TextFile.stringToFile(HEADER + hd("Messages") + xmle + BREAK + hd("Metadata") + xml1 + BREAK + hd("Concepts") + xml2 + FOOTER, Utilities.path("[tmp]", "comparison", name + ".html")); checkOutcomes(csc.getMessages(), content); } else if (left instanceof ValueSet && right instanceof ValueSet) { ValueSetComparer cs = new ValueSetComparer(session); ValueSetComparison csc = cs.compare((ValueSet) left, (ValueSet) right); - new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", name+"-union.json")), csc.getUnion()); - new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", name+"-intersection.json")), csc.getIntersection()); - + new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", name + "-union.json")), csc.getUnion()); + new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", name + "-intersection.json")), csc.getIntersection()); + String xmle = new XhtmlComposer(true).compose(cs.renderErrors(csc)); String xml1 = new XhtmlComposer(true).compose(cs.renderMetadata(csc, "", "")); String xml2 = new XhtmlComposer(true).compose(cs.renderCompose(csc, "", "")); String xml3 = new XhtmlComposer(true).compose(cs.renderExpansion(csc, "", "")); - TextFile.stringToFile(HEADER+hd("Messages")+xmle+BREAK+hd("Metadata")+xml1+BREAK+hd("Definition")+xml2+BREAK+hd("Expansion")+xml3+FOOTER, Utilities.path("[tmp]", "comparison", name+".html")); + TextFile.stringToFile(HEADER + hd("Messages") + xmle + BREAK + hd("Metadata") + xml1 + BREAK + hd("Definition") + xml2 + BREAK + hd("Expansion") + xml3 + FOOTER, Utilities.path("[tmp]", "comparison", name + ".html")); checkOutcomes(csc.getMessages(), content); } else { - throw new FHIRException("Can't compare "+left.fhirType()+" to "+right.fhirType()); + throw new FHIRException("Can't compare " + left.fhirType() + " to " + right.fhirType()); } } private String hd(String text) { - return "

"+text+"

\r\n"; + return "

" + text + "

\r\n"; } private CanonicalResource load(String name) throws IOException { @@ -209,7 +183,7 @@ public class ComparisonTests { throw new FHIRException("unknown version " + ver); } } - } + } private void checkOutcomes(List errors, JsonObject focus) { JsonObject output = focus.getAsJsonObject("output"); diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/conversion/tests/CrossVersionLibraryTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/conversion/tests/CrossVersionLibraryTests.java deleted file mode 100644 index 7aea94210..000000000 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/conversion/tests/CrossVersionLibraryTests.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hl7.fhir.conversion.tests; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Suite.class) -@SuiteClasses({ - SnapShotGenerationTestsX.class}) -public class CrossVersionLibraryTests { - -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index bf91bca9d..78b863fb6 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 5.0.0 - 1.1.15 + 1.1.16-SNAPSHOT 5.6.2 3.0.0-M4 0.8.5