-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
modules/shacl/src/test/resources/shacl/imports/importWithLoop.ttl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
prefix : <http://example.org/> | ||
prefix foaf: <http://xmlns.com/foaf/0.1/> | ||
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
prefix schema: <http://schema.org/> | ||
prefix sh: <http://www.w3.org/ns/shacl#> | ||
prefix xsd: <http://www.w3.org/2001/XMLSchema#> | ||
prefix owl: <http://www.w3.org/2002/07/owl#> | ||
|
||
<> owl:imports <loop.ttl> . | ||
|
||
:Person a sh:NodeShape ; | ||
sh:property :hasName . | ||
|
||
:Person sh:targetNode :alice . | ||
:Person sh:targetNode :bob . | ||
|
||
:alice :name "Alice" . | ||
:bob :age 23 . # Has no name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
prefix : <http://example.org/> | ||
prefix foaf: <http://xmlns.com/foaf/0.1/> | ||
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
prefix schema: <http://schema.org/> | ||
prefix sh: <http://www.w3.org/ns/shacl#> | ||
prefix xsd: <http://www.w3.org/2001/XMLSchema#> | ||
prefix owl: <http://www.w3.org/2002/07/owl#> | ||
|
||
# An infinite loop as it imports itself... | ||
<> owl:imports <loop.ttl> . | ||
|
||
:hasName a sh:PropertyShape ; | ||
sh:path :name ; | ||
sh:minCount 1 . |
60 changes: 60 additions & 0 deletions
60
modules/shacl/src/test/scala/es/weso/shacl/ImportTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package es.weso.shacl | ||
|
||
import java.nio.file.Paths | ||
|
||
import com.typesafe.config.{Config, ConfigFactory} | ||
import es.weso.rdf.jena.RDFAsJenaModel | ||
import es.weso.rdf.nodes.IRI | ||
import es.weso.shacl.converter.RDF2Shacl | ||
import es.weso.shacl.validator.Validator | ||
import org.scalatest._ | ||
|
||
class ImportTest extends FunSpec with Matchers with TryValues with OptionValues | ||
with SchemaMatchers { | ||
|
||
val conf: Config = ConfigFactory.load() | ||
val shaclFolderStr = conf.getString("shaclTests") | ||
val shaclFolder = IRI(Paths.get(shaclFolderStr).normalize.toUri.toString) | ||
|
||
describe("import") { | ||
it(s"Validates a shape that imports another one") { | ||
val r = for { | ||
rdf <- RDFAsJenaModel.fromIRI(shaclFolder + "imports/import.ttl") | ||
schema <- RDF2Shacl.getShacl(rdf) | ||
result <- Validator.validate(schema, rdf) | ||
} yield result | ||
|
||
r.fold( | ||
e => fail(s"Error reading: $e"), | ||
pair => { | ||
val (typing, ok) = pair | ||
val alice = IRI("http://example.org/alice") | ||
val bob = IRI("http://example.org/bob") | ||
val person = IRI("http://example.org/Person") | ||
val hasName = IRI("http://example.org/hasName") | ||
typing.getFailedValues(alice).map(_.id) should contain theSameElementsAs(List()) | ||
typing.getFailedValues(bob).map(_.id) should contain theSameElementsAs(List(person,hasName)) | ||
}) | ||
} | ||
|
||
it(s"Validates a shape that imports another one with a loop") { | ||
val r = for { | ||
rdf <- RDFAsJenaModel.fromIRI(shaclFolder + "imports/importWithLoop.ttl") | ||
schema <- RDF2Shacl.getShacl(rdf) | ||
result <- Validator.validate(schema, rdf) | ||
} yield result | ||
|
||
r.fold( | ||
e => fail(s"Error reading: $e"), | ||
pair => { | ||
val (typing, ok) = pair | ||
val alice = IRI("http://example.org/alice") | ||
val bob = IRI("http://example.org/bob") | ||
val person = IRI("http://example.org/Person") | ||
val hasName = IRI("http://example.org/hasName") | ||
typing.getFailedValues(alice).map(_.id) should contain theSameElementsAs(List()) | ||
typing.getFailedValues(bob).map(_.id) should contain theSameElementsAs(List(person,hasName)) | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# New features | ||
|
||
- Added support for owl:imports in SHACL | ||
|
||
TODOs | ||
----- | ||
|
||
- ShEx: Complete semantic actions implementation [Issue 116](https://github.com/labra/shaclex/issues/116) | ||
|
||
- ShEx: test-suite with shape maps and update report [Issue 115](https://github.com/labra/shaclex/issues/115) | ||
|
||
- Shaclex: Conversion from ShEx to SHACL [Issue 114](https://github.com/labra/shaclex/issues/114) | ||
|
||
- Shaclex: Conversion from SHACL to ShEx [Issue 113](https://github.com/labra/shaclex/issues/113) | ||
|
||
- Shacl: Implement SHACL-Sparql [Issue 112](https://github.com/labra/shaclex/issues/112) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version in ThisBuild := "0.1.03" | ||
version in ThisBuild := "0.1.04" |