From baac4ac1a8ac581b41d84833a7a39debe1dea1f6 Mon Sep 17 00:00:00 2001 From: dotasek Date: Fri, 25 Feb 2022 11:25:27 -0500 Subject: [PATCH] Fix + initial test --- .../hl7/fhir/dstu3/utils/FHIRPathEngine.java | 2 +- .../hl7/fhir/dstu3/utils/FhirPathTests.java | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java diff --git a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/FHIRPathEngine.java b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/FHIRPathEngine.java index 7794fc858..54191747f 100644 --- a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/FHIRPathEngine.java @@ -2219,7 +2219,7 @@ public class FHIRPathEngine { if (!Utilities.noString(f)) { - if (exp.getParameters().size() != 2) { + if (exp.getParameters().size() == 2) { String t = convertToString(execute(context, focus, exp.getParameters().get(0), true)); String r = convertToString(execute(context, focus, exp.getParameters().get(1), true)); diff --git a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java new file mode 100644 index 000000000..800668cc6 --- /dev/null +++ b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java @@ -0,0 +1,49 @@ +package org.hl7.fhir.dstu3.utils; + + +import org.hl7.fhir.dstu3.context.IWorkerContext; +import org.hl7.fhir.dstu3.model.Base; +import org.hl7.fhir.dstu3.model.ExpressionNode; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class FhirPathTests { + + @Mock + IWorkerContext iWorkerContext; + + @Mock + Object appContext; + + @Mock + Base resource; + + @Mock + Base base; + + @Test + public void testFuncReplaceParamSize() { + FHIRPathEngine engine = Mockito.spy(new FHIRPathEngine(iWorkerContext)); + + ExpressionNode expressionNode = new ExpressionNode(0); + expressionNode.setKind(ExpressionNode.Kind.Function); + expressionNode.setFunction(ExpressionNode.Function.Replace); + + ExpressionNode expressionNodeB = new ExpressionNode(1); + expressionNodeB.setKind(ExpressionNode.Kind.Function); + expressionNodeB.setFunction(ExpressionNode.Function.Empty); + + ExpressionNode expressionNodeC = new ExpressionNode(2); + expressionNodeC.setKind(ExpressionNode.Kind.Function); + expressionNodeC.setFunction(ExpressionNode.Function.Empty); + + expressionNode.getParameters().add(expressionNodeB); + expressionNode.getParameters().add(expressionNodeC); + engine.evaluate(appContext, resource, base, expressionNode); + + } +} \ No newline at end of file