From a74bbc2fb457db359f44ae340f3b43c900a17bf2 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 18 Oct 2019 22:26:29 +1100 Subject: [PATCH] more logical tests (test derivation by constraint) --- .gitignore | 2 + .../fhir/r5/test/SnapShotGenerationTests.java | 3 +- .../snapshot-generation/logical1-expected.xml | 29 ++- .../snapshot-generation/logical1-input.xml | 6 - .../snapshot-generation/logical2-expected.xml | 212 ++++++++++++++++++ .../snapshot-generation/logical2-input.xml | 25 +++ .../snapshot-generation/manifest.xml | 1 + 7 files changed, 261 insertions(+), 17 deletions(-) create mode 100644 org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical2-expected.xml create mode 100644 org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical2-input.xml diff --git a/.gitignore b/.gitignore index 370e73650..5be4cc5b1 100644 --- a/.gitignore +++ b/.gitignore @@ -298,3 +298,5 @@ local.properties /org.hl7.fhir.r5/src/test/resources/snapshot-generation/au2-actual.xml /org.hl7.fhir.r5/src/test/resources/snapshot-generation/au3-actual.xml /org.hl7.fhir.r5/src/test/resources/snapshot-generation/t29b-input.xml +/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical1-actual.xml +/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical2-actual.xml diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java index 76f111fd7..619c90bad 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java @@ -452,7 +452,8 @@ public class SnapShotGenerationTests { pu.setIds(test.included, false); StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, test.included.getBaseDefinition()); pu.generateSnapshot(base, test.included, test.included.getUrl(), "http://test.org/profile", test.included.getName()); - TestingUtilities.context().cacheResource(test.included); + if (!TestingUtilities.context().hasResource(StructureDefinition.class, test.included.getUrl())) + TestingUtilities.context().cacheResource(test.included); } StructureDefinition base = getSD(test.getSource().getBaseDefinition()); if (!base.getUrl().equals(test.getSource().getBaseDefinition())) diff --git a/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical1-expected.xml b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical1-expected.xml index ce5e02cd6..6a70e024f 100644 --- a/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical1-expected.xml +++ b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical1-expected.xml @@ -136,17 +136,10 @@ - - - + + - - - - - - - + @@ -180,6 +173,22 @@ + + + + + + + + + + + + + + + + diff --git a/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical1-input.xml b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical1-input.xml index 7dc148e44..d52499c55 100644 --- a/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical1-input.xml +++ b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical1-input.xml @@ -1,12 +1,6 @@ - - -
-

Defines the basic properties of every data value. This is an abstract type, meaning that no value can be just a data value without belonging to any concrete type. Every concrete type is a specialization of this general abstract DataValue type.

-
-
diff --git a/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical2-expected.xml b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical2-expected.xml new file mode 100644 index 000000000..3aa056923 --- /dev/null +++ b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical2-expected.xml @@ -0,0 +1,212 @@ + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ Name + + Flags + + Card. + + Type + + Description & Constraints + + + doco + + +
+ . + . + nullFlavor + + + + 0 + .. + 1 + + code + + Fixed Value: + UNK +
+
+ + doco Documentation for this format + +
+
+
+ + + + + + + <status value="active"/> + <experimental value="false"/> + <publisher value="HL7"/> + <description value="test constraints in specializations"/> + <mapping> + <identity value="rim"/> + <uri value="http://hl7.org/v3"/> + <name value="RIM Mapping"/> + </mapping> + <kind value="logical"/> + <abstract value="true"/> + <type value="ANY"/> + <baseDefinition value="http://hl7.org/fhir/cda/StructureDefinition/ANY"/> + <derivation value="specialization"/> + <snapshot> + <element id="ANY"> + <path value="ANY"/> + <short value="Base for all elements"/> + <definition value="Defines the basic properties of every data value. This is an abstract type, meaning that no value can be just a data value without belonging to any concrete type. Every concrete type is a specialization of this general abstract DataValue type."/> + <min value="1"/> + <max value="*"/> + <base> + <path value="Element"/> + <min value="0"/> + <max value="*"/> + </base> + <condition value="ele-1"/> + <constraint> + <key value="ele-1"/> + <severity value="error"/> + <human value="All FHIR elements must have a @value or children"/> + <expression value="hasValue() or (children().count() > id.count())"/> + <xpath value="@value|f:*|h:div"/> + <source value="ANY"/> + </constraint> + <isModifier value="false"/> + <mapping> + <identity value="rim"/> + <map value="n/a"/> + </mapping> + </element> + <element id="ANY.id"> + <path value="ANY.id"/> + <representation value="xmlAttr"/> + <short value="Unique id for inter-element referencing"/> + <definition value="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces."/> + <min value="0"/> + <max value="1"/> + <base> + <path value="Element.id"/> + <min value="0"/> + <max value="1"/> + </base> + <type> + <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type"> + <valueUrl value="string"/> + </extension> + <code value="http://hl7.org/fhirpath/System.String"/> + </type> + <isModifier value="false"/> + <isSummary value="false"/> + <mapping> + <identity value="rim"/> + <map value="n/a"/> + </mapping> + </element> + <element id="ANY.extension"> + <path value="ANY.extension"/> + <slicing> + <discriminator> + <type value="value"/> + <path value="url"/> + </discriminator> + <description value="Extensions are always sliced by (at least) url"/> + <rules value="open"/> + </slicing> + <short value="Additional content defined by implementations"/> + <definition value="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension."/> + <comment value="There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions. The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone."/> + <alias value="extensions"/> + <alias value="user content"/> + <min value="0"/> + <max value="*"/> + <base> + <path value="Element.extension"/> + <min value="0"/> + <max value="*"/> + </base> + <type> + <code value="Extension"/> + </type> + <constraint> + <key value="ele-1"/> + <severity value="error"/> + <human value="All FHIR elements must have a @value or children"/> + <expression value="hasValue() or (children().count() > id.count())"/> + <xpath value="@value|f:*|h:div"/> + <source value="Element"/> + </constraint> + <constraint> + <key value="ext-1"/> + <severity value="error"/> + <human value="Must have either extensions or value[x], not both"/> + <expression value="extension.exists() != value.exists()"/> + <xpath value="exists(f:extension)!=exists(f:*[starts-with(local-name(.), "value")])"/> + <source value="Extension"/> + </constraint> + <isModifier value="false"/> + <isSummary value="false"/> + <mapping> + <identity value="rim"/> + <map value="n/a"/> + </mapping> + </element> + <element id="ANY.nullFlavor"> + <path value="ANY.nullFlavor"/> + <representation value="xmlAttr"/> + <label value="Exceptional Value Detail"/> + <definition value="If a value is an exceptional value (NULL-value), this specifies in what way and why proper information is missing."/> + <min value="0"/> + <max value="1"/> + <base> + <path value="ANY.nullFlavor"/> + <min value="0"/> + <max value="1"/> + </base> + <type> + <code value="code"/> + </type> + <fixedCode value="UNK"/> + <binding> + <strength value="required"/> + <valueSet value="http://terminology.hl7.org/ValueSet/v3-NullFlavor"/> + </binding> + </element> + </snapshot> + <differential> + <element id="ANY.nullFlavor"> + <path value="ANY.nullFlavor"/> + <fixedCode value="UNK"/> + </element> + </differential> +</StructureDefinition> \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical2-input.xml b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical2-input.xml new file mode 100644 index 000000000..c816725b2 --- /dev/null +++ b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical2-input.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<StructureDefinition xmlns="http://hl7.org/fhir"> + <id value="ANY2"/> + <extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace"> + <valueUri value="urn:hl7-org:v3"/> + </extension> + <url value="http://hl7.org/fhir/cda/StructureDefinition/ANY2"/> + <name value="ANY2"/> + <title value="ANY2 - constraint on ANY to test out making constraints in specializations"/> + <status value="active"/> + <experimental value="false"/> + <publisher value="HL7"/> + <description value="test constraints in specializations"/> + <kind value="logical"/> + <abstract value="true"/> + <type value="ANY"/> + <baseDefinition value="http://hl7.org/fhir/cda/StructureDefinition/ANY"/> + <derivation value="specialization"/> + <differential> + <element id="ANY.nullFlavor"> + <path value="ANY.nullFlavor"/> + <fixedCode value="UNK"/> + </element> + </differential> +</StructureDefinition> \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/test/resources/snapshot-generation/manifest.xml b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/manifest.xml index 1e9afdb9b..9ed6f9670 100644 --- a/org.hl7.fhir.r5/src/test/resources/snapshot-generation/manifest.xml +++ b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/manifest.xml @@ -231,4 +231,5 @@ <test gen="true" id="au3"/> <test gen="true" id="dv1"/> <test gen="true" id="logical1"/> + <test gen="true" id="logical2" register="logical1-expected"/> </snapshot-generation-tests>