@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); UnionClass A = m.createUnionClass( NS + "A", null ); OntClass B = m.createClass( NS + "B" ); OntClass C = m.createClass( NS + "C" ); A.addOperand( B ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) ); assertEquals( "Size should be 1", 1, A.getOperands().size() ); assertTrue( "A should have a as union member", A.getOperands().contains( B ) ); A.addOperand( C ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) ); assertEquals( "Size should be 2", 2, A.getOperands().size() ); iteratorTest( A.listOperands(), new Object[] {B,C} ); ClosableIterator<? extends Resource> i = A.listOperands(); assertTrue( "Argument should be an OntClass", i.next() instanceof OntClass ); i.close(); A.setOperands( m.createList( new RDFNode[] {C} ) ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) ); assertEquals( "Size should be 1", 1, A.getOperands().size() ); assertTrue( "A should have C in the union", A.hasOperand( C ) ); assertTrue( "A should not have B in the union", !A.hasOperand( B ) ); A.removeOperand( B ); assertTrue( "Should have C as an operand", A.hasOperand( C ) ); A.removeOperand( C ); assertTrue( "Should not have C as an operand", !A.hasOperand( C ) ); } },
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); UnionClass A = m.createUnionClass( NS + "A", null ); OntClass B = m.createClass( NS + "B" ); OntClass C = m.createClass( NS + "C" ); A.addOperand( B ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) ); assertEquals( "Size should be 1", 1, A.getOperands().size() ); assertTrue( "A should have a as union member", A.getOperands().contains( B ) ); A.addOperand( C ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) ); assertEquals( "Size should be 2", 2, A.getOperands().size() ); iteratorTest( A.listOperands(), new Object[] {B,C} ); ClosableIterator<? extends Resource> i = A.listOperands(); assertTrue( "Argument should be an OntClass", i.next() instanceof OntClass ); i.close(); A.setOperands( m.createList( new RDFNode[] {C} ) ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) ); assertEquals( "Size should be 1", 1, A.getOperands().size() ); assertTrue( "A should have C in the union", A.hasOperand( C ) ); assertTrue( "A should not have B in the union", !A.hasOperand( B ) ); A.removeOperand( B ); assertTrue( "Should have C as an operand", A.hasOperand( C ) ); A.removeOperand( C ); assertTrue( "Should not have C as an operand", !A.hasOperand( C ) ); } },