use of org.apache.jena.shacl.ValidationReport in project jena by apache.
the class QualifiedValueShape method conforms.
private static boolean conforms(ValidationContext vCxt, Shape shape, Node v) {
ValidationContext vCxt2 = ValidationContext.create(vCxt);
ValidationProc.execValidateShape(vCxt2, vCxt.getDataGraph(), shape, v);
ValidationReport report = vCxt2.generateReport();
return report.conforms();
}
use of org.apache.jena.shacl.ValidationReport in project jena by apache.
the class ShaclTest method shaclTest.
public static void shaclTest(ShaclTestItem test) {
Graph shapesGraph = RDFDataMgr.loadGraph(test.getShapesGraph().getURI());
try {
Graph dataGraph;
if (test.getShapesGraph().getURI().equals(test.getDataGraph().getURI()))
dataGraph = shapesGraph;
else
dataGraph = RDFDataMgr.loadGraph(test.getDataGraph().getURI());
boolean generalFailure = test.isGeneralFailure();
if (generalFailure) {
try {
ValidationReport testReport = validate(ShaclValidator.get(), shapesGraph, dataGraph);
if (testReport.conforms())
fail("Expect a test failure: " + test.origin());
} catch (RuntimeException ex) {
// Ignore.
}
}
// Fails on unimplemented.
ValidationReport vReportExpected = ValidationReport.fromGraph(test.getResult().getModel().getGraph());
ValidationReport vReportGot;
try {
vReportGot = validate(ShaclValidator.get(), shapesGraph, dataGraph);
} catch (Throwable th) {
System.out.println("** Test : " + test.origin());
throw th;
}
boolean b1 = VR.compare(vReportGot, vReportExpected);
if (!b1) {
// expected report != actual report
System.out.println("<< Test : " + test.origin());
Shapes shapes = Shapes.parse(shapesGraph);
ShLib.printShapes(shapes);
System.out.println("++++ Expected:");
ShLib.printReport(vReportExpected);
System.out.println("++++ Got");
ShLib.printReport(vReportGot);
System.out.println("-----");
}
Model modelGot = VR.strip(vReportGot.getResource().getModel());
Model modelExpected = VR.strip(vReportExpected.getResource().getModel());
boolean b2 = modelGot.isIsomorphicWith(modelExpected);
if (!b2) {
// expected model != actual model
System.out.println("**** Expected");
RDFDataMgr.write(System.out, modelExpected, Lang.TTL);
System.out.println("**** Got");
RDFDataMgr.write(System.out, modelGot, Lang.TTL);
System.out.println(">> Test : " + test.origin());
System.out.println("-----");
}
assertTrue("Reports differ : " + test.origin(), b1);
assertTrue("Report models differ", b2);
} catch (RuntimeException ex) {
// ShLib.printShapes(shapeList);
throw ex;
}
}
use of org.apache.jena.shacl.ValidationReport in project jena by apache.
the class VR method check.
public static void check(ValidationReport report) {
// Internal test.
// Also entries->model->entries but bnode, order issues.
Model m = report.getResource().getModel();
ValidationReport report2 = ValidationReport.fromModel(m);
Model m2 = report2.getResource().getModel();
boolean b = m.isIsomorphicWith(m2);
if (!b) {
System.err.println("****");
RDFDataMgr.write(System.err, m, Lang.TTL);
System.err.println("++++ Round trip");
RDFDataMgr.write(System.err, m2, Lang.TTL);
System.err.println("----");
}
}
use of org.apache.jena.shacl.ValidationReport in project jena by apache.
the class TestValidationReport method testRoundTripReport.
// @Test public void rtReport_2() {
// // two entries
// }
private void testRoundTripReport(String message, ValidationReport report1) {
Resource r = report1.getResource();
ValidationReport report2 = ValidationReport.fromModel(r.getModel());
boolean b = VR.compare(report1, report2);
if (!b) {
System.out.println("****");
ShLib.printReport(report1);
System.out.println("----");
ShLib.printReport(report2);
System.out.flush();
}
assertTrue("Reports differ: " + message, b);
}
use of org.apache.jena.shacl.ValidationReport in project jena by apache.
the class TestValidationReport method rtReport_1.
// Round trip :: ValidationReport -> RDF -> ValidationReport
@Test
public void rtReport_1() {
ValidationReport report = ValidationReport.reportConformsTrue();
testRoundTripReport("conforms", report);
}
Aggregations