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());
}
Aggregations