From ae4c3bbe0cb7e6e5109958c68a4a756365f43869 Mon Sep 17 00:00:00 2001 From: Oliver Egger Date: Wed, 3 Jun 2020 22:08:43 +0200 Subject: [PATCH] remove disabled r4 fml tests --- .../r4/test/FHIRMappingLanguageTests.java | 149 ------------------ .../src/test/resources/fml/.gitignore | 1 - .../src/test/resources/fml/manifest.xml | 6 - .../src/test/resources/fml/qr.json | 39 ----- .../resources/fml/qr2pat-assignment-res.json | 4 - .../test/resources/fml/qr2pat-assignment.map | 8 - .../test/resources/fml/qr2pat-gender-res.json | 4 - .../src/test/resources/fml/qr2pat-gender.map | 12 -- .../fml/qr2pat-humannameshared-res.json | 8 - .../resources/fml/qr2pat-humannameshared.map | 26 --- .../fml/qr2pat-humannametwice-res.json | 10 -- .../resources/fml/qr2pat-humannametwice.map | 26 --- 12 files changed, 293 deletions(-) delete mode 100644 org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/FHIRMappingLanguageTests.java delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/.gitignore delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/manifest.xml delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr.json delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment-res.json delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment.map delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender-res.json delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender.map delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared-res.json delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared.map delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice-res.json delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice.map diff --git a/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/FHIRMappingLanguageTests.java b/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/FHIRMappingLanguageTests.java deleted file mode 100644 index 5ba09a2a7..000000000 --- a/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/FHIRMappingLanguageTests.java +++ /dev/null @@ -1,149 +0,0 @@ -package org.hl7.fhir.r4.test; - -import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.r4.context.SimpleWorkerContext; -import org.hl7.fhir.r4.elementmodel.Manager; -import org.hl7.fhir.r4.elementmodel.Manager.FhirFormat; -import org.hl7.fhir.r4.formats.IParser.OutputStyle; -import org.hl7.fhir.r4.formats.JsonParser; -import org.hl7.fhir.r4.model.*; -import org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind; -import org.hl7.fhir.r4.terminologies.ConceptMapEngine; -import org.hl7.fhir.r4.test.utils.TestingUtilities; -import org.hl7.fhir.r4.utils.StructureMapUtilities; -import org.hl7.fhir.r4.utils.StructureMapUtilities.ITransformerServices; -import org.hl7.fhir.utilities.TextFile; -import org.hl7.fhir.utilities.Utilities; -import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager; -import org.hl7.fhir.utilities.cache.ToolsVersion; -import org.hl7.fhir.utilities.xml.XMLUtil; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -import javax.xml.parsers.ParserConfigurationException; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -import static org.junit.Assert.assertTrue; - -@Disabled -public class FHIRMappingLanguageTests implements ITransformerServices { - - private List outputs = new ArrayList(); - - static private SimpleWorkerContext context; - static private JsonParser jsonParser; - - public static Stream data() - throws FileNotFoundException, IOException, ParserConfigurationException, SAXException { - Document tests = XMLUtil.parseFileToDom(TestingUtilities.resourceNameToFile("fml", "manifest.xml")); - Element test = XMLUtil.getFirstChild(tests.getDocumentElement()); - List objects = new ArrayList(); - while (test != null && test.getNodeName().equals("test")) { - objects.add(Arguments.of(test.getAttribute("name"), test.getAttribute("source"), test.getAttribute("map"), - test.getAttribute("output"))); - test = XMLUtil.getNextSibling(test); - } - return objects.stream(); - } - - @BeforeAll - static public void setUp() throws Exception { - if (context == null) { - FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION); - context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.core", "4.0.0")); - jsonParser = new JsonParser(); - jsonParser.setOutputStyle(OutputStyle.PRETTY); - } - } - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("data") - public void test(String name, String source, String map, String output) throws Exception { - - String fileSource = TestingUtilities.resourceNameToFile("fml", source); - String fileMap = TestingUtilities.resourceNameToFile("fml", map); - String fileOutput = TestingUtilities.resourceNameToFile("fml", output); - String fileOutputRes = TestingUtilities.resourceNameToFile("fml", output) + ".out"; - - outputs.clear(); - - boolean ok = false; - String msg = null; - Resource resource = null; - try { - StructureMapUtilities scu = new StructureMapUtilities(context, this); - org.hl7.fhir.r4.elementmodel.Element src = Manager.parse(context, - new ByteArrayInputStream(TextFile.fileToBytes(fileSource)), FhirFormat.JSON); - StructureMap structureMap = scu.parse(TextFile.fileToString(fileMap), name); - String typeName = scu.getTargetType(structureMap).getType(); - resource = ResourceFactory.createResource(typeName); - scu.transform(null, src, structureMap, resource); - ok = true; - } catch (Exception e) { - ok = false; - msg = e.getMessage(); - } - if (ok) { - ByteArrayOutputStream boas = new ByteArrayOutputStream(); - jsonParser.compose(boas, resource); - log(boas.toString()); - TextFile.bytesToFile(boas.toByteArray(), fileOutputRes); - msg = TestingUtilities.checkJsonIsSame(fileOutputRes, fileOutput); - assertTrue(msg, Utilities.noString(msg)); - } else - assertTrue("Error, but proper output was expected (" + msg + ")", output.equals("$error")); - } - - @Override - public void log(String message) { - System.out.println(message); - } - - @Override - public Base createType(Object appInfo, String name) throws FHIRException { - StructureDefinition sd = context.fetchResource(StructureDefinition.class, name); - if (sd != null && sd.getKind() == StructureDefinitionKind.LOGICAL) { - return Manager.build(context, sd); - } else { - if (name.startsWith("http://hl7.org/fhir/StructureDefinition/")) - name = name.substring("http://hl7.org/fhir/StructureDefinition/".length()); - return ResourceFactory.createResourceOrType(name); - } - } - - @Override - public Base createResource(Object appInfo, Base res, boolean atRootofTransform) { - if (atRootofTransform) - outputs.add((Resource) res); - return res; - } - - @Override - public Coding translate(Object appInfo, Coding source, String conceptMapUrl) throws FHIRException { - ConceptMapEngine cme = new ConceptMapEngine(context); - return cme.translate(source, conceptMapUrl); - } - - @Override - public Base resolveReference(Object appContext, String url) throws FHIRException { - throw new FHIRException("resolveReference is not supported yet"); - } - - @Override - public List performSearch(Object appContext, String url) throws FHIRException { - throw new FHIRException("performSearch is not supported yet"); - } - -} \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/.gitignore b/org.hl7.fhir.r4/src/test/resources/fml/.gitignore deleted file mode 100644 index fa929750c..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.out \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/manifest.xml b/org.hl7.fhir.r4/src/test/resources/fml/manifest.xml deleted file mode 100644 index 89b3d6b31..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/manifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr.json b/org.hl7.fhir.r4/src/test/resources/fml/qr.json deleted file mode 100644 index f0d14a3c1..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "resourceType": "QuestionnaireResponse", - "status": "in-progress", - "item": [ - { - "linkId": "patient", - "text": "Patient", - "item": [ - { - "linkId": "patient.lastname", - "text": "Name", - "answer": [ - { - "valueString": "Brönnimann-Bertholet" - } - ] - }, - { - "linkId": "patient.firstname", - "text": "Vorname", - "answer": [ - { - "valueString": "Elisabeth" - } - ] - }, - { - "linkId": "patient.sex", - "text": "Geschlecht", - "answer": [ - { - "valueString": "female" - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment-res.json b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment-res.json deleted file mode 100644 index c29553577..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment-res.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "resourceType" : "Patient", - "gender" : "female" -} \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment.map b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment.map deleted file mode 100644 index 79ddfb89b..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment.map +++ /dev/null @@ -1,8 +0,0 @@ -map "http://github.com/hapifhir/org.hl7.fhir.core/org.hl7.fhir.r4.tests/qr2patassignment" = "qr2patassignment" - -uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source -uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target - -group QuestionnaireResponse(source src : QuestionnaireResponse, target tgt : Patient) { - src -> tgt.gender = 'female' "Simple Assignment"; -} \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender-res.json b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender-res.json deleted file mode 100644 index c29553577..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender-res.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "resourceType" : "Patient", - "gender" : "female" -} \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender.map b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender.map deleted file mode 100644 index ee25265c6..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender.map +++ /dev/null @@ -1,12 +0,0 @@ -map "http://github.com/hapifhir/org.hl7.fhir.core/org.hl7.fhir.r4.tests/qr2patgender" = "qr2patgender" - -uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source -uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target - -group QuestionnaireResponse(source src : QuestionnaireResponse, target tgt : Patient) { - src.item as item -> tgt as patient then item(item, patient); -} - -group item(source src, target tgt: Patient) { - src.item as item where linkId.value in ('patient.sex') -> tgt.gender = (item.answer.valueString); -} diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared-res.json b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared-res.json deleted file mode 100644 index 240a91c69..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared-res.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "resourceType" : "Patient", - "name" : [{ - "family" : "Brönnimann-Bertholet", - "given" : ["Elisabeth"] - }], - "gender" : "female" -} diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared.map b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared.map deleted file mode 100644 index 178a5d658..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared.map +++ /dev/null @@ -1,26 +0,0 @@ -map "http://github.com/hapifhir/org.hl7.fhir.core/org.hl7.fhir.r4.tests/qr2pathumannameshared" = "qr2pathumannametwice" - -uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source -uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target - -group entry(source src : QuestionnaireResponse, target tgt : Patient) { - src.item as item then item(item, tgt); -} - -group item(source src, target tgt) { - src.item as item then item(item, tgt); - src.item as item where linkId.value = 'patient.lastname' -> tgt.name as name share patientName then humanNameFamily(item, name); - src.item as item where linkId.value = 'patient.firstname' -> tgt.name as name share patientName then humanNameGiven(item, name); - src.item as item where linkId.value = 'patient.sex' -> tgt.gender = (item.answer.valueString); -} - -group humanNameFamily(source src, target tgt: HumanName) { - src.answer as answer -> tgt.family = (answer.valueString); -} -group humanNameGiven(source src, target tgt: HumanName) { - src.answer as answer -> tgt.given = (answer.valueString); -} - -group administrativeGender(source src, target tgt: code) { - src.answer as answer -> tgt = (answer.valueString); -} diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice-res.json b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice-res.json deleted file mode 100644 index 9d9bab7db..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice-res.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "resourceType" : "Patient", - "name" : [{ - "family" : "Brönnimann-Bertholet" - }, - { - "given" : ["Elisabeth"] - }], - "gender" : "female" -} \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice.map b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice.map deleted file mode 100644 index 6de8b3c88..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice.map +++ /dev/null @@ -1,26 +0,0 @@ -map "http://github.com/hapifhir/org.hl7.fhir.core/org.hl7.fhir.r4.tests/qr2pathumannametwice" = "qr2pathumannametwice" - -uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source -uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target - -group entry(source src : QuestionnaireResponse, target tgt : Patient) { - src.item as item then item(item, tgt); -} - -group item(source src, target tgt) { - src.item as item then item(item, tgt); - src.item as item where linkId.value = 'patient.lastname' -> tgt.name as name then humanNameFamily(item, name); - src.item as item where linkId.value = 'patient.firstname' -> tgt.name as name then humanNameGiven(item, name); - src.item as item where linkId.value = 'patient.sex' -> tgt.gender = (item.answer.valueString); -} - -group humanNameFamily(source src, target tgt: HumanName) { - src.answer as answer -> tgt.family = (answer.valueString); -} -group humanNameGiven(source src, target tgt: HumanName) { - src.answer as answer -> tgt.given = (answer.valueString); -} - -group administrativeGender(source src, target tgt: code) { - src.answer as answer -> tgt = (answer.valueString); -}