use of org.apache.jena.shacl.ValidationReport in project webofneeds by researchstudio-sat.
the class ShaclCheckTest method validateAgainstShapes.
public void validateAgainstShapes(Shapes shapes, Graph graph, Resource resourceOfGraph) {
ValidationReport shaclReport = ShaclSystem.get().validate(shapes, new Union(shapes.getGraph(), graph));
if (!shaclReport.conforms()) {
ShLib.printReport(shaclReport);
System.out.println();
RDFDataMgr.write(System.out, shaclReport.getModel(), Lang.TTL);
}
Assert.isTrue(shaclReport.conforms(), String.format("%s: graph does not conform to shapes", resourceOfGraph.getFilename()));
}
use of org.apache.jena.shacl.ValidationReport in project webofneeds by researchstudio-sat.
the class AuthShapeTest method assertConformityOfAuthorizations.
private void assertConformityOfAuthorizations(Shapes shapes, Resource authGraph) {
logger.debug("checking {}", authGraph.getFilename());
Model data = ModelFactory.createDefaultModel();
try {
RDFDataMgr.read(data, authGraph.getInputStream(), Lang.TTL);
} catch (IOException e) {
e.printStackTrace();
}
Graph g = data.getGraph();
long start = CPUUtils.getCpuTime();
ValidationReport report = ShaclValidator.get().validate(shapes, new Union(g, shapes.getGraph()));
long duration = CPUUtils.getCpuTime() - start;
logger.debug("validation took {} millis ", (double) duration / 1000000d);
if (!report.conforms()) {
printNonconformingReport(report);
}
Assert.assertTrue(report.conforms());
}
use of org.apache.jena.shacl.ValidationReport in project webofneeds by researchstudio-sat.
the class AuthShapeTest method assertConformityOfOperationRequests.
private void assertConformityOfOperationRequests(Shapes shapes, Resource authGraph) {
logger.debug("checking {}", authGraph.getFilename());
Model data = ModelFactory.createDefaultModel();
try {
RDFDataMgr.read(data, authGraph.getInputStream(), Lang.TTL);
} catch (IOException e) {
e.printStackTrace();
}
Graph g = data.getGraph();
long start = CPUUtils.getCpuTime();
ValidationReport report = ShaclValidator.get().validate(shapes, g);
long duration = CPUUtils.getCpuTime() - start;
logger.debug("validation took {} millis ", (double) duration / 1000000d);
if (!report.conforms()) {
printNonconformingReport(report);
}
Assert.assertTrue(report.conforms());
}
use of org.apache.jena.shacl.ValidationReport in project webofneeds by researchstudio-sat.
the class GrantedOperationsTest method validateTestData.
public void validateTestData(Shapes shapes, Graph graph, boolean failTest, String testCaseIdentifier) {
ValidationReport shaclReport = ShaclSystem.get().validate(shapes, new Union(shapes.getGraph(), graph));
if (failTest) {
if (!shaclReport.conforms()) {
ShLib.printReport(shaclReport);
System.out.println();
RDFDataMgr.write(System.out, shaclReport.getModel(), Lang.TTL);
}
Assert.assertTrue(String.format("%s: test data invalid", testCaseIdentifier), shaclReport.conforms());
} else {
if (!shaclReport.conforms()) {
logger.info("failed SHACL validation: {}", testCaseIdentifier);
}
}
}
Aggregations