Skip to content

Commit

Permalink
test: cases for blank node contact point
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Dec 13, 2023
1 parent 908673c commit a2aac44
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"test": "run-s -ns \"test:* {@}\" --",
"test:observations": "./test/check-observations.sh",
"test:basic-cube-constraint": "./test/check-metadata.sh --profile=basic-cube-constraint",
"test:standalone-cube-constraint": "./test/check-metadata.sh --profile=standalone-cube-constraint",
"test:standalone-constraint-constraint": "./test/check-metadata.sh --profile=standalone-constraint-constraint",
"release": "changeset tag"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix cube: <https://cube.link/> .
@prefix observation: <https://environment.ld.admin.ch/foen/nfi/observation/max_min_undefined> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix schema: <http://schema.org/> .
@base <https://example.org/> .

<cube> a cube:Cube ;
cube:observationConstraint <shape> ;
cube:observationSet <observationSet> ;
schema:name "Example cube" ;
schema:publisher <publisher> ;
schema:creator <creator> ;
schema:contributor <contributor> ;
schema:dateCreated "2020-10-10"^^xsd:date ;
schema:dateModified "2020-10-10"^^xsd:date ;
schema:datePublished "2020-11-11"^^xsd:date ;
schema:contactPoint
[
schema:name "John Doe" ;
# schema:email "[email protected]" ;
] .

<observationSet> cube:observation <observation> .

<observation> a cube:Observation ;
cube:observedBy <observer> ;
<dimension1> 4.9 .

<shape> a cube:Constraint ;
sh:targetClass cube:Observation ;
sh:closed true ;
sh:property
[
sh:path rdf:type ;
sh:nodeKind sh:IRI
] ;
sh:property
[
sh:path cube:observedBy ; ;
sh:nodeKind sh:IRI
] ;
sh:property
[
sh:datatype xsd:decimal ;
sh:path <dimension1> ;
schema:name "some Quantity"
] ;
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix cube: <https://cube.link/> .

_:report a sh:ValidationReport ;
sh:result [
rdf:type sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:OrConstraintComponent ;
sh:sourceShape [
sh:path schema:contactPoint ;
sh:minCount 1 ;
sh:or (
[
sh:nodeKind sh:IRI ;
]
[
sh:nodeKind sh:BlankNode ;
sh:property [
sh:path schema:email ;
sh:minCount 1 ;
sh:message "Contact point needs an email" ;
sh:datatype xsd:string ;
], [
sh:path schema:name ;
sh:minCount 1 ;
sh:message "Contact point needs a name" ;
sh:datatype xsd:string ;
] ;
]
) ;
sh:message "cube:Cube needs a schema:contactpoint" ;
] ;
sh:focusNode <https://example.org/cube> ;
sh:resultPath schema:contactPoint ;
sh:value _:b1 ;
sh:resultMessage "cube:Cube needs a schema:contactpoint" ;
] ;
sh:conforms false .
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix cube: <https://cube.link/> .
@prefix observation: <https://environment.ld.admin.ch/foen/nfi/observation/max_min_undefined> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix schema: <http://schema.org/> .
@base <https://example.org/> .

<cube> a cube:Cube ;
cube:observationConstraint <shape> ;
cube:observationSet <observationSet> ;
schema:name "Example cube" ;
schema:publisher <publisher> ;
schema:creator <creator> ;
schema:contributor <contributor> ;
schema:dateCreated "2020-10-10"^^xsd:date ;
schema:dateModified "2020-10-10"^^xsd:date ;
schema:datePublished "2020-11-11"^^xsd:date ;
schema:contactPoint
[
# schema:name "John Doe" ;
schema:email "[email protected]" ;
] .

<observationSet> cube:observation <observation> .

<observation> a cube:Observation ;
cube:observedBy <observer> ;
<dimension1> 4.9 .

<shape> a cube:Constraint ;
sh:targetClass cube:Observation ;
sh:closed true ;
sh:property
[
sh:path rdf:type ;
sh:nodeKind sh:IRI
] ;
sh:property
[
sh:path cube:observedBy ; ;
sh:nodeKind sh:IRI
] ;
sh:property
[
sh:datatype xsd:decimal ;
sh:path <dimension1> ;
schema:name "some Quantity"
] ;
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix cube: <https://cube.link/> .

_:report a sh:ValidationReport ;
sh:result [
rdf:type sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:OrConstraintComponent ;
sh:sourceShape [
sh:path schema:contactPoint ;
sh:minCount 1 ;
sh:or (
[
sh:nodeKind sh:IRI ;
]
[
sh:nodeKind sh:BlankNode ;
sh:property [
sh:path schema:email ;
sh:minCount 1 ;
sh:message "Contact point needs an email" ;
sh:datatype xsd:string ;
], [
sh:path schema:name ;
sh:minCount 1 ;
sh:message "Contact point needs a name" ;
sh:datatype xsd:string ;
] ;
]
) ;
sh:message "cube:Cube needs a schema:contactpoint" ;
] ;
sh:focusNode <https://example.org/cube> ;
sh:resultPath schema:contactPoint ;
sh:value _:b1 ;
sh:resultMessage "cube:Cube needs a schema:contactpoint" ;
] ;
sh:conforms false .
50 changes: 50 additions & 0 deletions test/standalone-cube-constraint/valid.blankContactPoint.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix cube: <https://cube.link/> .
@prefix observation: <https://environment.ld.admin.ch/foen/nfi/observation/max_min_undefined> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix schema: <http://schema.org/> .
@base <https://example.org/> .

<cube> a cube:Cube ;
cube:observationConstraint <shape> ;
cube:observationSet <observationSet> ;
schema:name "Example cube" ;
schema:publisher <publisher> ;
schema:creator <creator> ;
schema:contributor <contributor> ;
schema:dateCreated "2020-10-10"^^xsd:date ;
schema:dateModified "2020-10-10"^^xsd:date ;
schema:datePublished "2020-11-11"^^xsd:date ;
schema:contactPoint
[
schema:name "John Doe" ;
schema:email "[email protected]" ;
] .

<observationSet> cube:observation <observation> .

<observation> a cube:Observation ;
cube:observedBy <observer> ;
<dimension1> 4.9 .

<shape> a cube:Constraint ;
sh:targetClass cube:Observation ;
sh:closed true ;
sh:property
[
sh:path rdf:type ;
sh:nodeKind sh:IRI
] ;
sh:property
[
sh:path cube:observedBy ; ;
sh:nodeKind sh:IRI
] ;
sh:property
[
sh:datatype xsd:decimal ;
sh:path <dimension1> ;
schema:name "some Quantity"
] ;
.

0 comments on commit a2aac44

Please sign in to comment.