work on snapshot generation tests
This commit is contained in:
parent
e2d52143d9
commit
d74ee20e4e
|
@ -277,6 +277,7 @@ public class SnapShotGenerationTests {
|
|||
@Parameters(name = "{index}: file {0}")
|
||||
public static Iterable<Object[]> data() throws ParserConfigurationException, IOException, FHIRFormatError {
|
||||
SnapShotGenerationTestsContext context = new SnapShotGenerationTestsContext();
|
||||
System.out.println("Snapshot tests using "+TestingUtilities.resourceNameToFile("snapshot-generation-tests.xml"));
|
||||
context.tests = (TestScript) new XmlParser().parse(new FileInputStream(TestingUtilities.resourceNameToFile("snapshot-generation-tests.xml")));
|
||||
|
||||
context.checkTestsDetails();
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ExpressionNode {
|
|||
|
||||
Empty, Not, Exists, SubsetOf, SupersetOf, IsDistinct, Distinct, Count, Where, Select, All, Repeat, Aggregate, Item /*implicit from name[]*/, As, Is, Single,
|
||||
First, Last, Tail, Skip, Take, Union, Combine, Intersect, Exclude, Iif, Upper, Lower, ToChars, Substring, StartsWith, EndsWith, Matches, ReplaceMatches, Contains, Replace, Length,
|
||||
Children, Descendants, MemberOf, Trace, Today, Now, Resolve, Extension, AllFalse, AnyFalse, AllTrue, AnyTrue,
|
||||
Children, Descendants, MemberOf, Trace, Check, Today, Now, Resolve, Extension, AllFalse, AnyFalse, AllTrue, AnyTrue,
|
||||
HasValue, AliasAs, Alias, HtmlChecks, OfType, Type,
|
||||
ConvertsToBoolean, ConvertsToInteger, ConvertsToString, ConvertsToDecimal, ConvertsToQuantity, ConvertsToDateTime, ConvertsToTime, ToBoolean, ToInteger, ToString, ToDecimal, ToQuantity, ToDateTime, ToTime, ConformsTo;
|
||||
|
||||
|
@ -108,6 +108,7 @@ public class ExpressionNode {
|
|||
if (name.equals("descendants")) return Function.Descendants;
|
||||
if (name.equals("memberOf")) return Function.MemberOf;
|
||||
if (name.equals("trace")) return Function.Trace;
|
||||
if (name.equals("check")) return Function.Check;
|
||||
if (name.equals("today")) return Function.Today;
|
||||
if (name.equals("now")) return Function.Now;
|
||||
if (name.equals("resolve")) return Function.Resolve;
|
||||
|
@ -183,6 +184,7 @@ public class ExpressionNode {
|
|||
case Descendants : return "descendants";
|
||||
case MemberOf : return "memberOf";
|
||||
case Trace : return "trace";
|
||||
case Check : return "check";
|
||||
case Today : return "today";
|
||||
case Now : return "now";
|
||||
case Resolve : return "resolve";
|
||||
|
|
|
@ -1110,6 +1110,7 @@ public class FHIRPathEngine {
|
|||
case Descendants: return checkParamCount(lexer, location, exp, 0);
|
||||
case MemberOf: return checkParamCount(lexer, location, exp, 1);
|
||||
case Trace: return checkParamCount(lexer, location, exp, 1, 2);
|
||||
case Check: return checkParamCount(lexer, location, exp, 2);
|
||||
case Today: return checkParamCount(lexer, location, exp, 0);
|
||||
case Now: return checkParamCount(lexer, location, exp, 0);
|
||||
case Resolve: return checkParamCount(lexer, location, exp, 0);
|
||||
|
@ -2549,6 +2550,10 @@ public class FHIRPathEngine {
|
|||
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||
return focus;
|
||||
}
|
||||
case Check : {
|
||||
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||
return focus;
|
||||
}
|
||||
case Today :
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_DateTime);
|
||||
case Now :
|
||||
|
@ -2741,6 +2746,7 @@ public class FHIRPathEngine {
|
|||
case Descendants : return funcDescendants(context, focus, exp);
|
||||
case MemberOf : return funcMemberOf(context, focus, exp);
|
||||
case Trace : return funcTrace(context, focus, exp);
|
||||
case Check : return funcCheck(context, focus, exp);
|
||||
case Today : return funcToday(context, focus, exp);
|
||||
case Now : return funcNow(context, focus, exp);
|
||||
case Resolve : return funcResolve(context, focus, exp);
|
||||
|
@ -3484,6 +3490,16 @@ public class FHIRPathEngine {
|
|||
return focus;
|
||||
}
|
||||
|
||||
private List<Base> funcCheck(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
|
||||
List<Base> n1 = execute(context, focus, exp.getParameters().get(0), true);
|
||||
if (!convertToBoolean(n1)) {
|
||||
List<Base> n2 = execute(context, focus, exp.getParameters().get(1), true);
|
||||
String name = n2.get(0).primitiveValue();
|
||||
throw new FHIRException("check failed: "+name);
|
||||
}
|
||||
return focus;
|
||||
}
|
||||
|
||||
private List<Base> funcDistinct(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
|
||||
if (focus.size() <= 1)
|
||||
return focus;
|
||||
|
|
|
@ -2086,7 +2086,7 @@
|
|||
</element>
|
||||
<element>
|
||||
<path value="Observation.value[x]"/>
|
||||
<sliceName value="quantity"/>
|
||||
<sliceName value="Quantity"/>
|
||||
<short value="some text for quantity"/>
|
||||
<type>
|
||||
<code value="Quantity"/>
|
||||
|
@ -2168,7 +2168,7 @@
|
|||
</element>
|
||||
<element>
|
||||
<path value="Observation.value[x]"/>
|
||||
<sliceName value="quantity"/>
|
||||
<sliceName value="Quantity"/>
|
||||
<short value="some text for quantity"/>
|
||||
<type>
|
||||
<code value="Quantity"/>
|
||||
|
@ -2180,7 +2180,7 @@
|
|||
</element>
|
||||
<element>
|
||||
<path value="Observation.value[x]"/>
|
||||
<sliceName value="codeable"/>
|
||||
<sliceName value="CodeableConcept"/>
|
||||
<short value="some text for CodeableConcept"/>
|
||||
<type>
|
||||
<code value="CodeableConcept"/>
|
||||
|
@ -4310,4 +4310,288 @@
|
|||
</assert>
|
||||
</action>
|
||||
</test>
|
||||
|
||||
<test>
|
||||
<name value="Test40"/>
|
||||
<description value="40. Choice Types: constrain minimum cardinality"/>
|
||||
<action>
|
||||
<operation>
|
||||
<type>
|
||||
<system value="http://hl7.org/fhir/testscript-operation-codes"/>
|
||||
<code value="snapshot"/>
|
||||
</type>
|
||||
<resource value="StructureDefinition"/>
|
||||
<encodeRequestUrl value="false"/>
|
||||
<params value="sort=true"/>
|
||||
<responseId value="t40o"/>
|
||||
<sourceId value="t40"/>
|
||||
</operation>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test40-1"/>
|
||||
<description value="Snapshot must generate ok"/>
|
||||
<response value="okay"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test40-2"/>
|
||||
<description value="There should only be one element definition for value[x]"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t40o').snapshot.element.where(path.startsWith('Observation.value')).count() = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test40-3"/>
|
||||
<description value="The element definition for value[x] should have min = 1"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t40o').snapshot.element.where(path.startsWith('Observation.value')).min = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
</test>
|
||||
|
||||
<test>
|
||||
<name value="Test41"/>
|
||||
<description value="41. Choice Types: constrain list of choices to 2"/>
|
||||
<action>
|
||||
<operation>
|
||||
<type>
|
||||
<system value="http://hl7.org/fhir/testscript-operation-codes"/>
|
||||
<code value="snapshot"/>
|
||||
</type>
|
||||
<resource value="StructureDefinition"/>
|
||||
<encodeRequestUrl value="false"/>
|
||||
<params value="sort=true"/>
|
||||
<responseId value="t41o"/>
|
||||
<sourceId value="t41"/>
|
||||
</operation>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test41-1"/>
|
||||
<description value="Snapshot must generate ok"/>
|
||||
<response value="okay"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test41-2"/>
|
||||
<description value="There should only be one element definition for value[x]"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t41o').snapshot.element.where(path.startsWith('Observation.value')).count() = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test41-3"/>
|
||||
<description value="The element definition for value[x] should have 2 types"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t41o').snapshot.element.where(path.startsWith('Observation.value')).type.count() = 2"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
</test>
|
||||
|
||||
<test>
|
||||
<name value="Test42"/>
|
||||
<description value="Choice Types: constrain list of choices to 1"/>
|
||||
<action>
|
||||
<operation>
|
||||
<type>
|
||||
<system value="http://hl7.org/fhir/testscript-operation-codes"/>
|
||||
<code value="snapshot"/>
|
||||
</type>
|
||||
<resource value="StructureDefinition"/>
|
||||
<encodeRequestUrl value="false"/>
|
||||
<params value="sort=true"/>
|
||||
<responseId value="t42o"/>
|
||||
<sourceId value="t42"/>
|
||||
</operation>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test42-1"/>
|
||||
<description value="Snapshot must generate ok"/>
|
||||
<response value="okay"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test42-2"/>
|
||||
<description value="There should only be one element definition for value[x]"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t42o').snapshot.element.where(path.startsWith('Observation.value')).count() = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test42-3"/>
|
||||
<description value="The element definition for value[x] should have 1 type"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t42o').snapshot.element.where(path.startsWith('Observation.value')).type.count() = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test42-4"/>
|
||||
<description value="The element definition for value[x] should have short = 'some text'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t42o').snapshot.element.where(path.startsWith('Observation.value')).short = 'some text'"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
</test>
|
||||
|
||||
<test>
|
||||
<name value="Test43"/>
|
||||
<description value="Choice Types: constrain list of choices to 1 and constrain the type (slicing)"/>
|
||||
<action>
|
||||
<operation>
|
||||
<type>
|
||||
<system value="http://hl7.org/fhir/testscript-operation-codes"/>
|
||||
<code value="snapshot"/>
|
||||
</type>
|
||||
<resource value="StructureDefinition"/>
|
||||
<encodeRequestUrl value="false"/>
|
||||
<params value="sort=true"/>
|
||||
<responseId value="t43o"/>
|
||||
<sourceId value="t43"/>
|
||||
</operation>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test43-1"/>
|
||||
<description value="Snapshot must generate ok"/>
|
||||
<response value="okay"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test43-2"/>
|
||||
<description value="There should be 9 element definitions for value[x] (base + quantity + walking into quantity"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t43o').snapshot.element.where(path.startsWith('Observation.value')).count() = 9"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test43-3"/>
|
||||
<description value="The element definition for value[x] should have 1 type"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t43o').snapshot.element.where(id = 'Observation.value[x]').type.count().trace('count') = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test43-4"/>
|
||||
<description value="The element definition for value[x] should have short = 'some text'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t43o').snapshot.element.where(id = 'Observation.value[x]').short = 'some text'"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test43-5"/>
|
||||
<description value="The element definition for value[x] quantity slice should have sliceName = 'Quantity'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t43o').snapshot.element.where(id = 'Observation.value[x]:Quantity').check(exists(), 'no slice').sliceName = 'Quantity'"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test43-6"/>
|
||||
<description value="The element definition for value[x].value quantity slice should have sliceName = 'Quantity'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t43o').snapshot.element.where(id = 'Observation.value[x]:Quantity.value').check(exists(), 'no slice').min = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
</test>
|
||||
|
||||
<test>
|
||||
<name value="Test44"/>
|
||||
<description value="Choice Types: constrain list of choices to 1 and constrain the type (shortcut)"/>
|
||||
<action>
|
||||
<operation>
|
||||
<type>
|
||||
<system value="http://hl7.org/fhir/testscript-operation-codes"/>
|
||||
<code value="snapshot"/>
|
||||
</type>
|
||||
<resource value="StructureDefinition"/>
|
||||
<encodeRequestUrl value="false"/>
|
||||
<params value="sort=true"/>
|
||||
<responseId value="t44o"/>
|
||||
<sourceId value="t44"/>
|
||||
</operation>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test44-1"/>
|
||||
<description value="Snapshot must generate ok"/>
|
||||
<response value="okay"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test44-2"/>
|
||||
<description value="There should be 9 element definitions for value[x] (base + quantity + walking into quantity"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t44o').snapshot.element.where(path.startsWith('Observation.value')).count() = 9"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test44-3"/>
|
||||
<description value="The element definition for value[x] should have 1 type"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t44o').snapshot.element.where(id = 'Observation.value[x]').type.count().trace('count') = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test44-4"/>
|
||||
<description value="The element definition for value[x] should have short = 'some text'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t44o').snapshot.element.where(id = 'Observation.value[x]').short = 'some text'"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test44-5"/>
|
||||
<description value="The element definition for value[x] quantity slice should have sliceName = 'Quantity'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t44o').snapshot.element.where(id = 'Observation.value[x]:Quantity').check(exists(), 'no slice').sliceName = 'Quantity'"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
<action>
|
||||
<assert>
|
||||
<label value="test44-6"/>
|
||||
<description value="The element definition for value[x].value quantity slice should have sliceName = 'Quantity'"/>
|
||||
<direction value="response"/>
|
||||
<expression value="fixture('t44o').snapshot.element.where(id = 'Observation.value[x]:Quantity.value').check(exists(), 'no slice').min = 1"/>
|
||||
<warningOnly value="false"/>
|
||||
</assert>
|
||||
</action>
|
||||
</test>
|
||||
|
||||
</TestScript>
|
||||
|
|
Loading…
Reference in New Issue