source: mauRepo/NewmoonJSP/src/main/webapp/WEB-INF/rules/conformance-test/ISO19136-V3.2-AnxE_XMI-V1.1/test-010.xq @ 7841

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/NewmoonJSP/src/main/webapp/WEB-INF/rules/conformance-test/ISO19136-V3.2-AnxE_XMI-V1.1/test-010.xq@7841
Revision 7841, 3.4 KB checked in by mnagni, 10 years ago (diff)
Line 
1xquery version "1.0";
2(:~~~~~~~~~~~~~~~~~~~~~~~~~~ Conformance Test  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3Test Number:    010
4Description:    Asserts that each name from EAStub element has corresponding
5                                record in registers or type-mapping tables depending on
6                                EAStub/@UMLType.
7Reference:   
8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:)
9
10import module namespace mod-fr = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:framework"
11at "xmldb:exist:///db/modules/conformance-test/ISO19136-V3.2-AnxE_XMI-V1.1/module-framework-functions.xq";
12
13declare namespace UML   = "omg.org/UML1.3";
14declare namespace cr    = "http://ndg.service.newmoon.conftest-result/1.0";
15declare namespace tm    = "urn:x-auscope:xmlns:CSIRO:FullMoon:package-class-map:2.0";
16declare namespace pckr  = "urn:x-auscope:xmlns:CSIRO:FullMoon:package-register:2.0";
17
18(: Declare local variables, particular to this test :)
19declare variable $test-num as xs:integer := 10;
20declare variable $pass-msg as xs:string := "Each external dependency package does have a corresponding record in the dependency register. Each external dependency class does have a corresponding record in a ClassMap found through a register reference.";
21declare variable $fail-msg as xs:string := "Some external packages and/or classes within the model do not have corresponding records in registry or type-mapping tables.";
22
23(: Declare the local assert function which defines a postive condition for pass :)
24declare function local:assert($doc-root as node()?) as node()?
25{
26        let $coll := collection("/db/conformance-test/ISO19136-V3.2-AnxE_XMI-V1.1/mapping"),
27                (: Check external package references :)
28                $fail-package := (
29                        for $ext in $doc-root/XMI/XMI.extensions/EAStub[@UMLType eq "Package"]
30                        return
31                                if (empty($doc-root/XMI/XMI.content/UML:Model//UML:Package[@name eq $ext/@name]) and
32                                        empty($coll/pckr:register/pckr:package[@name eq $ext/@name]) and
33                                        empty($doc-root/XMI//UML:Dependency[@client eq $ext/@xmi.id]))
34                                then
35                                        <cr:message>{ concat("External dependency package &quot;", $ext/@name, "&quot; does NOT have a corresponding record in the dependency register.") }</cr:message>
36                                else ()
37                ),
38                (: Check external class references :)
39                $tmt := $coll/tm:mapping,
40                $fail-class := (
41                        for $ext in $doc-root/XMI/XMI.extensions/EAStub[@UMLType eq "Class"]
42                        let $test-tag := if ($doc-root//UML:Association/UML:ModelElement.taggedValue/UML:TaggedValue[@tag/matches(., "ea_(source|target)Name") and @value eq $ext/@name]/(preceding-sibling::* | following-sibling::*)[@tag eq "direction"]/substring-before(@value, " ") = "Source") then "ea_sourceName" else "ea_targetName"
43                        return
44                                if (empty($tmt//tm:entry/tm:umlClass[text() eq $ext/@name]) and
45                                        empty($doc-root//UML:Generalization[@subtype eq $ext/@xmi.id]) and
46                                        empty($doc-root//UML:Association/UML:ModelElement.taggedValue/UML:TaggedValue[@tag eq $test-tag and @value eq $ext/@name]))
47                                then
48                                        <cr:message>{ concat("External dependency class &quot;", $ext/@name, "&quot; does NOT have a corresponding record in a ClassMap found through a register reference.") }</cr:message>
49                                else ()
50                )
51        return
52                if (empty($fail-package) and empty($fail-class)) then ()
53                else
54                        <cr:fail>
55                                <cr:messages>{ $fail-package, $fail-class }</cr:messages>
56                        </cr:fail>
57};
58
59(: Create a new result element :)
60mod-fr:new-result($test-num, $pass-msg, $fail-msg, local:assert(/))
Note: See TracBrowser for help on using the repository browser.