Skip to content

Commit 1906403

Browse files
committed
Add test cases for sh:nodeByExpression
1 parent 0aa5074 commit 1906403

File tree

4 files changed

+178
-0
lines changed

4 files changed

+178
-0
lines changed

shacl12-test-suite/tests/core/node/manifest.ttl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
mf:include <minInclusive-003.ttl> ;
3030
mf:include <minLength-001.ttl> ;
3131
mf:include <node-001.ttl> ;
32+
mf:include <nodeByExpression-001.ttl> ;
3233
mf:include <nodeKind-001.ttl> ;
3334
mf:include <not-001.ttl> ;
3435
mf:include <not-002.ttl> ;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@prefix dash: <http://datashapes.org/dash#> .
2+
@prefix ex: <http://datashapes.org/sh/tests/core/node/nodeByExpression-001.test#> .
3+
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
4+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
5+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
6+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7+
@prefix sh: <http://www.w3.org/ns/shacl#> .
8+
@prefix sht: <http://www.w3.org/ns/shacl-test#> .
9+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
10+
11+
ex:InvalidInstance
12+
rdf:type ex:TestClass ;
13+
rdfs:label "Invalid instance" ;
14+
.
15+
ex:TestClass
16+
rdf:type rdfs:Class ;
17+
rdf:type sh:NodeShape ;
18+
rdfs:label "Test class" ;
19+
rdfs:subClassOf rdfs:Resource ;
20+
# Only using an IRI Expression here because Core doesn't define interesting node expressions
21+
sh:node ex:TestNodeShape ;
22+
.
23+
ex:TestNodeShape
24+
rdf:type sh:NodeShape ;
25+
sh:class ex:OtherClass ;
26+
.
27+
ex:ValidInstance
28+
rdf:type ex:OtherClass ;
29+
rdf:type ex:TestClass ;
30+
rdfs:label "Valid instance" ;
31+
.
32+
<>
33+
rdf:type mf:Manifest ;
34+
mf:entries (
35+
<nodeByExpression-001>
36+
) ;
37+
.
38+
<nodeByExpression-001>
39+
rdf:type sht:Validate ;
40+
rdfs:label "Test of sh:nodeByExpression at node shape 001" ;
41+
mf:action [
42+
sht:dataGraph <> ;
43+
sht:shapesGraph <> ;
44+
] ;
45+
mf:result [
46+
rdf:type sh:ValidationReport ;
47+
sh:conforms "false"^^xsd:boolean ;
48+
sh:result [
49+
rdf:type sh:ValidationResult ;
50+
sh:focusNode ex:InvalidInstance ;
51+
sh:resultSeverity sh:Violation ;
52+
sh:sourceConstraint ex:TestNodeShape ;
53+
sh:sourceConstraintComponent sh:NodeConstraintComponent ;
54+
sh:sourceShape ex:TestClass ;
55+
sh:value ex:InvalidInstance ;
56+
] ;
57+
] ;
58+
mf:status sht:approved ;
59+
.

shacl12-test-suite/tests/core/property/manifest.ttl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
mf:include <minLength-001.ttl> ;
3232
mf:include <node-001.ttl> ;
3333
mf:include <node-002.ttl> ;
34+
mf:include <nodeByExpression-001.ttl> ;
3435
mf:include <nodeKind-001.ttl> ;
3536
mf:include <not-001.ttl> ;
3637
mf:include <or-001.ttl> ;
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
@prefix dash: <http://datashapes.org/dash#> .
2+
@prefix ex: <http://datashapes.org/sh/tests/core/property/nodeByExpression-001.test#> .
3+
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
4+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
5+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
6+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7+
@prefix sh: <http://www.w3.org/ns/shacl#> .
8+
@prefix sht: <http://www.w3.org/ns/shacl-test#> .
9+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
10+
11+
ex:Anon
12+
rdf:type ex:Person ;
13+
ex:firstName "Anon" ;
14+
.
15+
ex:AssignedToShape ;
16+
rdf:type sh:NodeShape ;
17+
rdfs:comment "All assignees must have an email and a last name." ;
18+
sh:property [
19+
sh:path ex:email ;
20+
sh:maxCount 1 ;
21+
sh:minCount 1 ;
22+
] ;
23+
sh:property [
24+
sh:path ex:lastName ;
25+
sh:maxCount 1 ;
26+
sh:minCount 1 ;
27+
] ;
28+
.
29+
ex:Issue
30+
rdf:type rdfs:Class ;
31+
rdf:type sh:NodeShape ;
32+
rdfs:label "Issue" ;
33+
rdfs:subClassOf rdfs:Resource ;
34+
sh:property ex:Issue-assignedTo ;
35+
sh:property ex:Issue-submittedBy ;
36+
.
37+
ex:Issue-assignedTo
38+
sh:path ex:assignedTo ;
39+
sh:class ex:Person ;
40+
# Only using an IRI Expression here because Core doesn't define interesting node expressions
41+
sh:node ex:AssignedToShape ;
42+
.
43+
ex:Issue-submittedBy
44+
sh:path ex:submittedBy ;
45+
sh:class ex:Person ;
46+
sh:minCount 1 ;
47+
.
48+
ex:Issue_1
49+
rdf:type ex:Issue ;
50+
ex:assignedTo ex:Anon ;
51+
ex:submittedBy ex:Anon ;
52+
rdfs:label "Issue 1" ;
53+
.
54+
ex:Issue_2
55+
rdf:type ex:Issue ;
56+
ex:assignedTo ex:JohnDoeWithEmail ;
57+
ex:submittedBy ex:Anon ;
58+
rdfs:label "Issue 2" ;
59+
.
60+
ex:JohnDoeWithEmail
61+
rdf:type ex:Person ;
62+
ex:email "john@doe.com" ;
63+
ex:firstName "John" ;
64+
ex:lastName "Doe" ;
65+
.
66+
ex:Person
67+
rdf:type rdfs:Class ;
68+
rdf:type sh:NodeShape ;
69+
rdfs:label "Person" ;
70+
rdfs:subClassOf rdfs:Resource ;
71+
sh:property [
72+
sh:path ex:email ;
73+
ex:datatype xsd:string ;
74+
rdfs:label "email" ;
75+
] ;
76+
sh:property [
77+
sh:path ex:firstName ;
78+
rdfs:label "first name" ;
79+
sh:datatype xsd:string ;
80+
sh:maxCount 1 ;
81+
sh:minCount 1 ;
82+
] ;
83+
sh:property [
84+
sh:path ex:lastName ;
85+
rdfs:label "last name" ;
86+
sh:datatype xsd:string ;
87+
] ;
88+
.
89+
<>
90+
rdf:type mf:Manifest ;
91+
mf:entries (
92+
<nodeByExpression-001>
93+
) ;
94+
.
95+
<nodeByExpression-001>
96+
rdf:type sht:Validate ;
97+
rdfs:label "Test of sh:nodeByExpression at property shape 001" ;
98+
mf:action [
99+
sht:dataGraph <> ;
100+
sht:shapesGraph <> ;
101+
] ;
102+
mf:result [
103+
rdf:type sh:ValidationReport ;
104+
sh:conforms "false"^^xsd:boolean ;
105+
sh:result [
106+
rdf:type sh:ValidationResult ;
107+
sh:focusNode ex:Issue_1 ;
108+
sh:resultPath ex:assignedTo ;
109+
sh:resultSeverity sh:Violation ;
110+
sh:sourceConstraint ex:AssignedToShape ;
111+
sh:sourceConstraintComponent sh:NodeConstraintComponent ;
112+
sh:sourceShape ex:Issue-assignedTo ;
113+
sh:value ex:Anon ;
114+
] ;
115+
] ;
116+
mf:status sht:approved ;
117+
.

0 commit comments

Comments
 (0)