Skip to content

Commit

Permalink
Added failing test to check result.isValid when the validation is wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
labra committed May 6, 2018
1 parent b718274 commit 452a890
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules/schema/src/test/scala/es/weso/schema/SchemaTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,25 @@ class SchemaTest extends FunSpec with Matchers with EitherValues {
case Left(e) => fail(s"Error trying to validate: $e")
}
}

it("fails to validate a wrong SHACL validation") {
val data =
"""
|@prefix : <http://example.org/> .
|@prefix sh: <http://www.w3.org/ns/shacl#> .
|@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
|:User a sh:NodeShape , rdfs:Class ;
| sh:nodeKind sh:BlankNode .
|:alice a :User .
""".stripMargin
val eitherResult = for {
schema <- Schemas.fromString(data,"TURTLE","SHACLEX",None)
rdf <- RDFAsJenaModel.fromChars(data,"TURTLE",None)
} yield schema.validate(rdf,"TargetDecls","",None,None,rdf.getPrefixMap,schema.pm)
eitherResult.fold(e => fail(s"Error: $e"), result => {
result.isValid should be(false)
})
}
}
}

0 comments on commit 452a890

Please sign in to comment.