Search in sources :

Example 6 with ValidationReport

use of org.apache.jena.shacl.ValidationReport in project jena by apache.

the class Shacl01_validateGraph method main.

public static void main(String... args) {
    String SHAPES = "shapes.ttl";
    String DATA = "data1.ttl";
    Graph shapesGraph = RDFDataMgr.loadGraph(SHAPES);
    Graph dataGraph = RDFDataMgr.loadGraph(DATA);
    Shapes shapes = Shapes.parse(shapesGraph);
    ValidationReport report = ShaclValidator.get().validate(shapes, dataGraph);
    ShLib.printReport(report);
    System.out.println();
    RDFDataMgr.write(System.out, report.getModel(), Lang.TTL);
}
Also used : Graph(org.apache.jena.graph.Graph) ValidationReport(org.apache.jena.shacl.ValidationReport) Shapes(org.apache.jena.shacl.Shapes)

Example 7 with ValidationReport

use of org.apache.jena.shacl.ValidationReport in project jena by apache.

the class TestFusekiShaclValidation method shacl_targetNode_2.

@Test
public void shacl_targetNode_2() {
    try (RDFConnection conn = RDFConnection.connect(serverURL + "/ds")) {
        conn.put("urn:abc:graph", DIR + "data1.ttl");
        ValidationReport report = validateReport(serverURL + "/ds/shacl?graph=urn:abc:graph&target=:s3", DIR + "shapes1.ttl");
        assertNotNull(report);
        assertEquals(0, report.getEntries().size());
        conn.update("CLEAR ALL");
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) ValidationReport(org.apache.jena.shacl.ValidationReport) Test(org.junit.Test)

Example 8 with ValidationReport

use of org.apache.jena.shacl.ValidationReport in project jena by apache.

the class TestFusekiShaclValidation method shacl_targetNode_3.

@Test
public void shacl_targetNode_3() {
    try (RDFConnection conn = RDFConnection.connect(serverURL + "/ds")) {
        conn.put("urn:abc:graph", DIR + "data1.ttl");
        ValidationReport report = validateReport(serverURL + "/ds/shacl?graph=urn:abc:graph&target=http://nosuch/node/", DIR + "shapes1.ttl");
        assertNotNull(report);
        assertEquals(0, report.getEntries().size());
        conn.update("CLEAR ALL");
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) ValidationReport(org.apache.jena.shacl.ValidationReport) Test(org.junit.Test)

Example 9 with ValidationReport

use of org.apache.jena.shacl.ValidationReport in project jena by apache.

the class TestFusekiShaclValidation method shacl_default_graph.

@Test
public void shacl_default_graph() {
    try (RDFConnection conn = RDFConnection.connect(serverURL + "/ds")) {
        conn.put(DIR + "data1.ttl");
        ValidationReport report = validateReport(serverURL + "/ds/shacl?graph=default", DIR + "shapes1.ttl");
        assertNotNull(report);
        assertEquals(3, report.getEntries().size());
        conn.update("CLEAR ALL");
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) ValidationReport(org.apache.jena.shacl.ValidationReport) Test(org.junit.Test)

Example 10 with ValidationReport

use of org.apache.jena.shacl.ValidationReport in project jena by apache.

the class TestFusekiShaclValidation method shacl_targetNode_1.

@Test
public void shacl_targetNode_1() {
    try (RDFConnection conn = RDFConnection.connect(serverURL + "/ds")) {
        conn.put("urn:abc:graph", DIR + "data1.ttl");
        ValidationReport report = validateReport(serverURL + "/ds/shacl?graph=urn:abc:graph&target=:s1", DIR + "shapes1.ttl");
        assertNotNull(report);
        assertEquals(2, report.getEntries().size());
        conn.update("CLEAR ALL");
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) ValidationReport(org.apache.jena.shacl.ValidationReport) Test(org.junit.Test)

Aggregations

ValidationReport (org.apache.jena.shacl.ValidationReport)24 RDFConnection (org.apache.jena.rdfconnection.RDFConnection)9 Test (org.junit.Test)9 Graph (org.apache.jena.graph.Graph)7 Union (org.apache.jena.graph.compose.Union)5 Model (org.apache.jena.rdf.model.Model)3 Shapes (org.apache.jena.shacl.Shapes)3 IOException (java.io.IOException)2 Node (org.apache.jena.graph.Node)2 Resource (org.apache.jena.rdf.model.Resource)2 ValidationContext (org.apache.jena.shacl.engine.ValidationContext)2 MediaType (org.apache.jena.atlas.web.MediaType)1 FusekiServer (org.apache.jena.fuseki.main.FusekiServer)1 Operation (org.apache.jena.fuseki.server.Operation)1 Lang (org.apache.jena.riot.Lang)1 Shape (org.apache.jena.shacl.parser.Shape)1 ResettableErrorHandler (won.shacl2java.validation.ResettableErrorHandler)1