Search in sources :

Example 1 with ValidityReport

use of org.apache.jena.reasoner.ValidityReport in project jena by apache.

the class OWLConsistencyTest method runTest.

@Override
public void runTest() {
    ValidityReport report = testResults();
    switch(expected) {
        case INCONSISTENT:
            assertTrue("expected inconsistent", !report.isValid());
            break;
        case WARNINGS:
            assertTrue("expected just warnings but reports not valid", report.isValid());
            assertFalse("expected warnings but reports clean", report.isClean());
            break;
        case CLEAN:
            assertTrue("expected clean", report.isClean());
    }
    if (culprit != null) {
        boolean foundit = false;
        for (Iterator<Report> i = report.getReports(); i.hasNext(); ) {
            ValidityReport.Report r = i.next();
            if (r.getExtension() != null && r.getExtension().equals(culprit)) {
                foundit = true;
                break;
            }
        }
        if (!foundit) {
            assertTrue("Expcted to find a culprint " + culprit, false);
        }
    }
}
Also used : ValidityReport(org.apache.jena.reasoner.ValidityReport) ValidityReport(org.apache.jena.reasoner.ValidityReport) Report(org.apache.jena.reasoner.ValidityReport.Report) Report(org.apache.jena.reasoner.ValidityReport.Report)

Example 2 with ValidityReport

use of org.apache.jena.reasoner.ValidityReport in project jena by apache.

the class TestOWLMisc method doTestDatatypeRangeValidation.

private void doTestDatatypeRangeValidation(RDFDatatype over12Type, OntModelSpec spec) {
    String NS = "http://jena.hpl.hp.com/example#";
    OntModel ont = ModelFactory.createOntologyModel(spec);
    Resource over12 = ont.createResource(over12Type.getURI());
    DatatypeProperty hasValue = ont.createDatatypeProperty(NS + "hasValue");
    hasValue.addRange(over12);
    ont.createResource(NS + "a").addProperty(hasValue, "15", over12Type);
    ont.createResource(NS + "b").addProperty(hasValue, "16", XSDDatatype.XSDinteger);
    ont.createResource(NS + "c").addProperty(hasValue, "10", XSDDatatype.XSDinteger);
    ValidityReport validity = ont.validate();
    assertTrue(!validity.isValid());
    // Check culprit reporting
    ValidityReport.Report report = (validity.getReports().next());
    Triple culprit = (Triple) report.getExtension();
    assertEquals(culprit.getSubject().getURI(), NS + "c");
    assertEquals(culprit.getPredicate(), hasValue.asNode());
}
Also used : Triple(org.apache.jena.graph.Triple) ValidityReport(org.apache.jena.reasoner.ValidityReport) OntModel(org.apache.jena.ontology.OntModel) DatatypeProperty(org.apache.jena.ontology.DatatypeProperty)

Example 3 with ValidityReport

use of org.apache.jena.reasoner.ValidityReport in project jena by apache.

the class TestOWLMisc method testLiteralBug.

/**
 * Test change of RDF specs to allow plain literals w/o lang and XSD string to be the same.
 */
public void testLiteralBug() {
    Model model = FileManager.getInternal().loadModelInternal("file:testing/reasoners/bugs/dtValidation.owl");
    // Model m = ModelFactory.createDefaultModel();
    Reasoner r = ReasonerRegistry.getOWLReasoner();
    InfModel infmodel = ModelFactory.createInfModel(r, model);
    ValidityReport validity = infmodel.validate();
    assertTrue(validity.isValid());
}
Also used : Reasoner(org.apache.jena.reasoner.Reasoner) ValidityReport(org.apache.jena.reasoner.ValidityReport) OntModel(org.apache.jena.ontology.OntModel)

Aggregations

ValidityReport (org.apache.jena.reasoner.ValidityReport)3 OntModel (org.apache.jena.ontology.OntModel)2 Triple (org.apache.jena.graph.Triple)1 DatatypeProperty (org.apache.jena.ontology.DatatypeProperty)1 Reasoner (org.apache.jena.reasoner.Reasoner)1 Report (org.apache.jena.reasoner.ValidityReport.Report)1