From fe538ea530db5f7b612d737e003d90d4b2ecf540 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 17 Mar 2023 07:56:06 +1100 Subject: [PATCH] fhirpath tests on element model --- .../test/java/org/hl7/fhir/r5/test/FHIRPathTests.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java index d865d067d..f27aab1c7 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java @@ -11,6 +11,9 @@ import org.apache.commons.lang3.NotImplementedException; import org.fhir.ucum.UcumException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; +import org.hl7.fhir.r5.elementmodel.Manager; +import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat; +import org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.model.*; @@ -204,7 +207,12 @@ public class FHIRPathTests { if (node != null) { try { - outcome = fp.evaluate(res, node); + if ("element".equals(test.getAttribute("mode"))) { + List e = Manager.parse(fp.getWorker(), TestingUtilities.loadTestResourceStream("r5", input), input.endsWith(".json") ? FhirFormat.JSON : FhirFormat.XML); + outcome = fp.evaluate(e.get(0).getElement(), node); + } else { + outcome = fp.evaluate(res, node); + } Assertions.assertTrue(fail == TestResultType.OK, String.format("Expected exception didn't occur executing %s", expression)); } catch (Exception e) { System.out.println("Execution Error: "+e.getMessage());