Skip to content

Commit

Permalink
Update expected message to reflect tweaks in XSLT verbiage
Browse files Browse the repository at this point in the history
  • Loading branch information
galtm authored and aj-stein-nist committed Sep 28, 2023
1 parent 571a2a1 commit 3299323
Showing 1 changed file with 164 additions and 0 deletions.
164 changes: 164 additions & 0 deletions src/utils/resolver-pipeline/testing/5_finished/finish.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,170 @@
</x:scenario>
</x:scenario>

<x:scenario label="Tests for mode=all-or-last-only template">
<x:scenario label="Element that can occur with any multiplicity">
<x:context mode="all-or-last-only" select="(//o:link)[2]">
<parent>
<link href="target1"/>
<link href="target2"/>
<link href="target3"/>
</parent>
</x:context>
<x:expect label="Copy of element, regardless of multiplicity or position">
<link href="target2"/>
</x:expect>
</x:scenario>
<x:scenario label="Non-OSCAL element">
<x:context mode="all-or-last-only" select="(//opr:title)[2]">
<parent>
<opr:title>A</opr:title>
<opr:title>B</opr:title>
<opr:title>C</opr:title>
</parent>
</x:context>
<x:expect label="Copy of element, regardless of multiplicity or position">
<opr:title>B</opr:title>
</x:expect>
</x:scenario>
<x:scenario label="Element that can occur at most once, ">
<x:variable name="ov:context-parent">
<parent>
<title>Original</title>
<title>Intermediate replacement</title>
<title>Another intermediate replacement</title>
<title>Last replacement</title>
</parent>
</x:variable>
<x:scenario label="first of four instances">
<x:context mode="all-or-last-only" select="($ov:context-parent//o:title)[1]"/>
<x:expect label="Nothing; the warning will come from the next to last instance, and the copy will come from the last instance"
select="()"/>
</x:scenario>
<x:scenario label="second of four instances">
<x:context mode="all-or-last-only" select="($ov:context-parent//o:title)[2]"/>
<x:expect label="Nothing; the warning will come from the next to last instance, and the copy will come from the last instance"
select="()"/>
</x:scenario>
<x:scenario label="next to last instance">
<x:context mode="all-or-last-only" select="($ov:context-parent//o:title)[last()-1]"/>
<x:expect label="PI for warning about extra title"
test="$x:result/self::processing-instruction('message-handler')">
<?message-handler Warning: Found 4 elements of type <title>. Only the last will be present in result.?>
</x:expect>
<x:expect label="No elements" test="empty($x:result/self::element())"/>
</x:scenario>
<x:scenario label="last instance">
<x:context mode="all-or-last-only" select="($ov:context-parent//o:title)[last()]"/>
<x:expect label="Copy of element">
<title>Last replacement</title>
</x:expect>
<x:expect label="No PI for warning or error" test="empty($x:result/self::processing-instruction())"/>
</x:scenario>
</x:scenario>
</x:scenario>

<x:scenario label="Tests for name=process-expected-child-elements template">
<x:scenario label="Child elements out of sequence, extraneous elements, and extra title">
<x:context>
<parent>
<param id="param-A.a">
<label>A.a parameter</label>
<value>A.a value</value>
</param>
<published/>
<prop name="label" value="1st"/>
<title>Original</title>
<prop name="label" value="2nd"/>
<title>Replacement</title>
<param id="param-B.b">
<label>B.b parameter</label>
<value>B.b value</value>
</param>
<opr:title>Non-OSCAL Title</opr:title>
</parent>
</x:context>
<x:call template="process-expected-child-elements">
<x:param name="expected-child-element-names"
select="('title','param','prop')"/>
</x:call>
<x:expect label="One title, all params, all props, and no other elements" test="element()">
<title>Replacement</title>
<param id="param-A.a">
<label>A.a parameter</label>
<value>A.a value</value>
</param>
<param id="param-B.b">
<label>B.b parameter</label>
<value>B.b value</value>
</param>
<prop name="label" value="1st"/>
<prop name="label" value="2nd"/>
</x:expect>
<x:expect label="PI for warning about extra OSCAL-namespace title" test="/processing-instruction('message-handler')">
<?message-handler Warning: Found 2 elements of type <title>. Only the last will be present in result.?>
</x:expect>
<!-- Note: An extraneous <published/> element causes the report-unexpected-child-elements
template, not the template being called in this scenario, to output an error PI. -->
</x:scenario>
</x:scenario>

<x:scenario label="Tests for name=report-unexpected-child-elements template">
<x:scenario label="Unexpected elements among expected and opr:* child elements">
<x:context>
<parent>
<param id="param-A.a">
<label>A.a parameter</label>
<value>A.a value</value>
</param>
<published/>
<prop name="label" value="1st"/>
<title>OSCAL Title</title>
<opr:title>Non-OSCAL Title</opr:title>
<unknown-element>Text</unknown-element>
</parent>
</x:context>
<x:call template="report-unexpected-child-elements">
<x:param name="expected-child-element-names"
select="('title','param','prop')"/>
</x:call>
<x:expect label="Processing instructions about 'published' and 'unknown-element' elements"
test="/processing-instruction('message-handler')">
<?message-handler Error: Element of type <published> is not valid inside <parent> and will not be present in result.?>
<?message-handler Error: Element of type <unknown-element> is not valid inside <parent> and will not be present in result.?>
</x:expect>
</x:scenario>
<x:scenario label="No unexpected child elements">
<x:context>
<parent>
<param id="param-A.a">
<label>A.a parameter</label>
<value>A.a value</value>
</param>
<prop name="label" value="1st"/>
<title>OSCAL Title</title>
<opr:title>Non-OSCAL Title</opr:title>
</parent>
</x:context>
<x:call template="report-unexpected-child-elements">
<x:param name="expected-child-element-names"
select="('title','param','prop')"/>
</x:call>
<x:expect label="Nothing" select="()"/>
</x:scenario>
<x:scenario label="No child elements">
<x:context>
<parent>
<!-- no child elements -->
</parent>
</x:context>
<x:call template="report-unexpected-child-elements">
<x:param name="expected-child-element-names"
select="('title','param','prop')"/>
</x:call>
<x:expect label="Nothing" select="()"/>
</x:scenario>
</x:scenario>

<x:scenario label="Tests for match=catalog template">
<x:scenario label="Base">
<x:context>
Expand Down

0 comments on commit 3299323

Please sign in to comment.