Skip to content

Commit

Permalink
GH-5139 add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad committed Oct 2, 2024
1 parent 96d1225 commit 95b9222
Show file tree
Hide file tree
Showing 50 changed files with 219 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ abstract public class AbstractShaclTest {
public static final Set<IRI> SHAPE_GRAPHS = Set.of(RDF4J.SHACL_SHAPE_GRAPH, RDF4J.NIL,
Values.iri("http://example.com/ns#shapesGraph1"));

public static final String INITIAL_DATA_FILE = "initialData.trig";

private static final Set<String> ignoredTestCases = Set.of(
"test-cases/path/oneOrMorePath",
"test-cases/path/zeroOrMorePath",
Expand Down Expand Up @@ -222,7 +224,7 @@ private static Stream<TestCase> findTestCases(String testCase, ExpectedResult ba
if (files != null) {
Optional<String> initialData = Arrays.stream(files)
.map(File::getName)
.filter(name -> name.equals("initialData.ttl"))
.filter(name -> name.equals(INITIAL_DATA_FILE))
.findAny();
List<File> queries = Arrays.stream(files)
.filter(f -> f.getName().endsWith(".rq"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PREFIX ex: <http://example.com/ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

INSERT DATA {
ex:person1 a ex:Person;
ex:name "en val"@en, "whatever", "other".
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@prefix ex: <http://example.com/ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rsx: <http://rdf4j.org/shacl-extensions#> .
@prefix rdf4j: <http://rdf4j.org/schema/rdf4j#> .

[] a sh:ValidationReport;
rdf4j:truncated false;
sh:conforms false;
sh:result [ a sh:ValidationResult;
rsx:shapesGraph rdf4j:SHACLShapeGraph;
sh:focusNode ex:person1;
sh:resultPath ex:name;
sh:resultSeverity sh:Violation;
sh:sourceConstraintComponent sh:QualifiedMaxCountConstraintComponent;
sh:sourceShape [ a sh:PropertyShape;
sh:path ex:name;
sh:qualifiedMaxCount 1;
sh:qualifiedValueShape [ a sh:NodeShape;
sh:datatype xsd:string
]
]
] .
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@prefix ex: <http://example.com/ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:person1 a ex:Person ;
ex:name "en val"@en, "whatever" .
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
PREFIX ex: <http://example.com/ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

INSERT {
GRAPH ex:graph2 {
ex:person2 ex:change ?entity_iri .
}
?entity_iri ex:name "NONE (string) value updated 2", "NONE (string) value updated 3".
} WHERE {
VALUES ?entity_iri {
ex:person1
}
?entity_iri rdf:type ?entity_iri_rdf_type__0 .

FILTER (?entity_iri_rdf_type__0 = ex:Person)
BIND ('LangStringUniq' as ?entity_iri_ignore__1) .
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@prefix ex: <http://example.com/ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rsx: <http://rdf4j.org/shacl-extensions#> .
@prefix rdf4j: <http://rdf4j.org/schema/rdf4j#> .

[] a sh:ValidationReport;
rdf4j:truncated false;
sh:conforms false;
sh:result [ a sh:ValidationResult;
rsx:shapesGraph rdf4j:SHACLShapeGraph;
sh:focusNode ex:person1;
sh:resultPath ex:name;
sh:resultSeverity sh:Violation;
sh:sourceConstraintComponent sh:QualifiedMaxCountConstraintComponent;
sh:sourceShape [ a sh:PropertyShape;
sh:path ex:name;
sh:qualifiedMaxCount 1;
sh:qualifiedValueShape [ a sh:NodeShape;
sh:datatype xsd:string
]
]
] .
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@prefix ex: <http://example.com/ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:person1 a ex:Person ;
ex:name "en val"@en, "whatever" .
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PREFIX ex: <http://example.com/ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

INSERT DATA {
ex:person1 ex:name "other".
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@prefix ex: <http://example.com/ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rsx: <http://rdf4j.org/shacl-extensions#> .
@prefix rdf4j: <http://rdf4j.org/schema/rdf4j#> .

[] a sh:ValidationReport;
rdf4j:truncated false;
sh:conforms false;
sh:result [ a sh:ValidationResult;
rsx:shapesGraph rdf4j:SHACLShapeGraph;
sh:focusNode ex:person1;
sh:resultPath ex:name;
sh:resultSeverity sh:Violation;
sh:sourceConstraintComponent sh:QualifiedMaxCountConstraintComponent;
sh:sourceShape [ a sh:PropertyShape;
sh:path ex:name;
sh:qualifiedMaxCount 1;
sh:qualifiedValueShape [ a sh:NodeShape;
sh:datatype xsd:string
]
]
] .
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@prefix ex: <http://example.com/ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf4j: <http://rdf4j.org/schema/rdf4j#> .

rdf4j:SHACLShapeGraph {
ex:PersonShape a sh:NodeShape;
sh:targetClass ex:Person;
sh:property [
sh:path ex:name;
sh:qualifiedValueShape [sh:datatype xsd:string ; ] ;
sh:qualifiedMaxCount 1 ;
] .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PREFIX ex: <http://example.com/ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

INSERT DATA {
ex:person1 a ex:Person;
ex:name "en val"@en, "whatever" .
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@prefix ex: <http://example.com/ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rsx: <http://rdf4j.org/shacl-extensions#> .
@prefix rdf4j: <http://rdf4j.org/schema/rdf4j#> .

[] a sh:ValidationReport;
rdf4j:truncated false;
sh:conforms true .
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PREFIX ex: <http://example.com/ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

INSERT DATA {
ex:person1 ex:name "en val"@en, "whatever" .
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PREFIX ex: <http://example.com/ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

INSERT DATA {
ex:person1 a ex:Person.
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@prefix ex: <http://example.com/ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rsx: <http://rdf4j.org/shacl-extensions#> .
@prefix rdf4j: <http://rdf4j.org/schema/rdf4j#> .

[] a sh:ValidationReport;
rdf4j:truncated false;
sh:conforms true .

0 comments on commit 95b9222

Please sign in to comment.