Search in sources :

Example 1 with DatatypeProperty

use of org.apache.jena.ontology.DatatypeProperty 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)

Aggregations

Triple (org.apache.jena.graph.Triple)1 DatatypeProperty (org.apache.jena.ontology.DatatypeProperty)1 OntModel (org.apache.jena.ontology.OntModel)1 ValidityReport (org.apache.jena.reasoner.ValidityReport)1