Merge branch 'master' of https://github.com/hapifhir/org.hl7.fhir
This commit is contained in:
commit
503021c9a6
|
@ -2219,7 +2219,7 @@ public class FHIRPathEngine {
|
||||||
|
|
||||||
if (!Utilities.noString(f)) {
|
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 t = convertToString(execute(context, focus, exp.getParameters().get(0), true));
|
||||||
String r = convertToString(execute(context, focus, exp.getParameters().get(1), true));
|
String r = convertToString(execute(context, focus, exp.getParameters().get(1), true));
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
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.hl7.fhir.dstu3.model.StringType;
|
||||||
|
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;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
|
||||||
|
@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);
|
||||||
|
List<Base> result = engine.evaluate(appContext, resource, base, expressionNode);
|
||||||
|
|
||||||
|
assertEquals(1, result.size());
|
||||||
|
Base onlyResult = result.get(0);
|
||||||
|
assertTrue(onlyResult instanceof StringType);
|
||||||
|
assertEquals("base", ((StringType)result.get(0)).asStringValue());
|
||||||
|
Mockito.verify(engine, times(2)).convertToString(any());
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,7 +49,7 @@ public enum FhirPublication {
|
||||||
R4;
|
R4;
|
||||||
|
|
||||||
public static FhirPublication fromCode(String v) {
|
public static FhirPublication fromCode(String v) {
|
||||||
if (VersionUtilities.isR4Ver(v))
|
if (VersionUtilities.isR2Ver(v))
|
||||||
return FhirPublication.DSTU2;
|
return FhirPublication.DSTU2;
|
||||||
if ("1.0".equals(v))
|
if ("1.0".equals(v))
|
||||||
return FhirPublication.DSTU2;
|
return FhirPublication.DSTU2;
|
||||||
|
|
Loading…
Reference in New Issue