public void testInverse() {
String ns = "http://www.example.org/test#";
OntModel ont = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC, null );
ObjectProperty p1 = ont.createObjectProperty( ns + "p1" );
ObjectProperty p2 = ont.createObjectProperty( ns + "p2" );
ObjectProperty p3 = ont.createObjectProperty( ns + "p3" );
p2.addSubProperty( p1 );
p2.addInverseOf( p3 );
Individual s1 = ont.createIndividual( ns + "s1", OWL.Thing );
Individual o1 = ont.createIndividual( ns + "o1", OWL.Thing );
Individual s2 = ont.createIndividual( ns + "s2", OWL.Thing );
Individual o2 = ont.createIndividual( ns + "o2", OWL.Thing );
Individual s3 = ont.createIndividual( ns + "s3", OWL.Thing );
Individual o3 = ont.createIndividual( ns + "o3", OWL.Thing );
s1.addProperty( p1, o1 );
s2.addProperty( p2, o2 );
s3.addProperty( p3, o3 );
Statement stmt = ont.createStatement( o1, p3, s1 );
assertIteratorContains( o1.listPropertyValues( p3 ), s1 );
assertTrue( ont.contains( stmt ) );
assertIteratorContains( ont.listStatements( null, p3, (RDFNode) null ), stmt );
assertIteratorContains( ont.listStatements( o1, null, (RDFNode) null ), stmt );
assertIteratorContains( ont.listStatements(), stmt );
assertFalse( ont.contains( o3, p1, s3 ) );
assertTrue( p2.isInverseOf( p3 ) );
assertIteratorValues( p2.listInverseOf(), new Property[] { p3 } );
assertTrue( p3.isInverseOf( p2 ) );
assertIteratorValues( p3.listInverseOf(), new Property[] { p2 } );
}