📄 testclassexpression.java
字号:
A.setHasClassQ( d );
assertEquals( "Restriction should hasClassQ d", d, A.getHasClassQ() );
assertTrue( "Restriction should be hasClassQ d", A.hasHasClassQ( d ) );
assertFalse( "Restriction should not be hasClassQ c", A.hasHasClassQ( c ) );
assertTrue( "Should be a qualified restriction", m.getResource( NS + nameA ).canAs( QualifiedRestriction.class ) );
A.removeHasClassQ( d );
assertFalse( "Should not be a qualified restriction", m.getResource( NS + nameA ).canAs( QualifiedRestriction.class ) );
}
},
new OntTestCase( "CardinalityQRestriction.cardinality", false, false, true, false ) {
public void ontTest( OntModel m ) throws Exception {
OntProperty p = m.createObjectProperty( NS + "p" );
OntClass c = m.createClass( NS + "C" );
CardinalityQRestriction A = m.createCardinalityQRestriction( NS + "A", p, 3, c );
assertEquals( "Restriction should cardinality 3", 3, A.getCardinalityQ() );
assertTrue( "Restriction should be cardinality 3", A.hasCardinalityQ( 3 ) );
assertFalse( "Restriction should not be cardinality 1", A.hasCardinalityQ( 1 ) );
A.setCardinalityQ( 1 );
assertEquals( "Restriction should cardinality 1", 1, A.getCardinalityQ() );
assertFalse( "Restriction should not be cardinality 3", A.hasCardinalityQ( 3 ) );
assertTrue( "Restriction should be cardinality 1", A.hasCardinalityQ( 1 ) );
assertTrue( "Should be a qualified cardinality restriction", m.getResource( NS + "A" ).canAs( CardinalityQRestriction.class ) );
A.removeCardinalityQ( 1 );
assertFalse( "Should not be a qualified cardinality restriction", m.getResource( NS + "A" ).canAs( CardinalityQRestriction.class ) );
}
},
new OntTestCase( "MinCardinalityQRestriction.minCardinality", false, false, true, false ) {
public void ontTest( OntModel m ) throws Exception {
OntProperty p = m.createObjectProperty( NS + "p" );
OntClass c = m.createClass( NS + "C" );
MinCardinalityQRestriction A = m.createMinCardinalityQRestriction( NS + "A", p, 3, c );
assertEquals( "Restriction should min cardinality 3", 3, A.getMinCardinalityQ() );
assertTrue( "Restriction should be min cardinality 3", A.hasMinCardinalityQ( 3 ) );
assertFalse( "Restriction should not be min cardinality 1", A.hasMinCardinalityQ( 1 ) );
A.setMinCardinalityQ( 1 );
assertEquals( "Restriction should min cardinality 1", 1, A.getMinCardinalityQ() );
assertFalse( "Restriction should not be min cardinality 3", A.hasMinCardinalityQ( 3 ) );
assertTrue( "Restriction should be min cardinality 1", A.hasMinCardinalityQ( 1 ) );
assertTrue( "Should be a qualified min cardinality restriction", m.getResource( NS + "A" ).canAs( MinCardinalityQRestriction.class ) );
A.removeMinCardinalityQ( 1 );
assertFalse( "Should not be a qualified min cardinality restriction", m.getResource( NS + "A" ).canAs( MinCardinalityQRestriction.class ) );
}
},
new OntTestCase( "MaxCardinalityQRestriction.maxCardinality", false, false, true, false ) {
public void ontTest( OntModel m ) throws Exception {
OntProperty p = m.createObjectProperty( NS + "p" );
OntClass c = m.createClass( NS + "C" );
MaxCardinalityQRestriction A = m.createMaxCardinalityQRestriction( NS + "A", p, 3, c );
assertEquals( "Restriction should max cardinality 3", 3, A.getMaxCardinalityQ() );
assertTrue( "Restriction should be max cardinality 3", A.hasMaxCardinalityQ( 3 ) );
assertFalse( "Restriction should not be max cardinality 1", A.hasMaxCardinalityQ( 1 ) );
A.setMaxCardinalityQ( 1 );
assertEquals( "Restriction should max cardinality 1", 1, A.getMaxCardinalityQ() );
assertFalse( "Restriction should not be max cardinality 3", A.hasMaxCardinalityQ( 3 ) );
assertTrue( "Restriction should be max cardinality 1", A.hasMaxCardinalityQ( 1 ) );
assertTrue( "Should be a qualified max cardinality restriction", m.getResource( NS + "A" ).canAs( MaxCardinalityQRestriction.class ) );
A.removeMaxCardinalityQ( 1 );
assertFalse( "Should not be a qualified max cardinality restriction", m.getResource( NS + "A" ).canAs( MaxCardinalityQRestriction.class ) );
}
},
// from file
new OntTestCase( "OntClass.subclass.fromFile", true, true, true, true ) {
public void ontTest( OntModel m ) throws Exception {
String lang = m_owlLang ? "owl" : (m_damlLang ? "daml" : "rdfs");
String fileName = "file:testing/ontology/" + lang + "/ClassExpression/test.rdf";
m.read( fileName );
OntClass A = m.createClass( NS + "ClassA" );
OntClass B = m.createClass( NS + "ClassB" );
iteratorTest( A.listSuperClasses(), new Object[] {B} );
iteratorTest( B.listSubClasses(), new Object[] {A} );
}
},
new OntTestCase( "OntClass.equivalentClass.fromFile", true, true, true, false ) {
public void ontTest( OntModel m ) throws Exception {
String lang = m_owlLang ? "owl" : (m_damlLang ? "daml" : "rdfs");
String fileName = "file:testing/ontology/" + lang + "/ClassExpression/test.rdf";
m.read( fileName );
OntClass A = m.createClass( NS + "ClassA" );
OntClass C = m.createClass( NS + "ClassC" );
assertTrue( "A should be equiv to C", A.hasEquivalentClass( C ) );
}
},
new OntTestCase( "OntClass.disjoint.fromFile", true, false, true, false ) {
public void ontTest( OntModel m ) throws Exception {
String lang = m_owlLang ? "owl" : (m_damlLang ? "daml" : "rdfs");
String fileName = "file:testing/ontology/" + lang + "/ClassExpression/test.rdf";
m.read( fileName );
OntClass A = m.createClass( NS + "ClassA" );
OntClass D = m.createClass( NS + "ClassD" );
assertTrue( "A should be disjoint with D", A.isDisjointWith( D ) );
}
},
// type testing
new OntTestCase( "OntClass.isEnumeratedClass", true, false, true, false ) {
public void ontTest( OntModel m ) throws Exception {
OntClass b = m.createClass( NS + "B" );
Individual x = m.createIndividual( NS + "x", b );
Individual y = m.createIndividual( NS + "y", b );
OntClass a = m.createEnumeratedClass( NS + "A", m.createList( new RDFNode[] {x, y} ) );
assertTrue( "enumerated class test not correct", a.isEnumeratedClass() );
assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
assertTrue( "union class test not correct", !a.isUnionClass() );
assertTrue( "complement class test not correct", !a.isComplementClass() );
assertTrue( "restriction test not correct", !a.isRestriction() );
}
},
new OntTestCase( "OntClass.isIntersectionClass", true, true, true, false ) {
public void ontTest( OntModel m ) throws Exception {
OntClass b = m.createClass( NS + "B" );
OntClass c = m.createClass( NS + "C" );
OntClass a = m.createIntersectionClass( NS + "A", m.createList( new RDFNode[] {b,c} ) );
assertTrue( "enumerated class test not correct", m_owlLiteLang || !a.isEnumeratedClass() );
assertTrue( "intersection class test not correct", a.isIntersectionClass() );
assertTrue( "union class test not correct", m_owlLiteLang || !a.isUnionClass() );
assertTrue( "complement class test not correct", m_owlLiteLang || !a.isComplementClass() );
assertTrue( "restriction test not correct", !a.isRestriction() );
}
},
new OntTestCase( "OntClass.isUnionClass", true, false, true, false ) {
public void ontTest( OntModel m ) throws Exception {
OntClass b = m.createClass( NS + "B" );
OntClass c = m.createClass( NS + "C" );
OntClass a = m.createUnionClass( NS + "A", m.createList( new RDFNode[] {b,c} ) );
assertTrue( "enumerated class test not correct", !a.isEnumeratedClass() );
assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
assertTrue( "union class test not correct", a.isUnionClass() );
assertTrue( "complement class test not correct", !a.isComplementClass() );
assertTrue( "restriction test not correct", !a.isRestriction() );
}
},
new OntTestCase( "OntClass.isComplementClass", true, false, true, false ) {
public void ontTest( OntModel m ) throws Exception {
OntClass b = m.createClass( NS + "B" );
OntClass a = m.createComplementClass( NS + "A", b );
assertTrue( "enumerated class test not correct", !a.isEnumeratedClass() );
assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
assertTrue( "union class test not correct", !a.isUnionClass() );
assertTrue( "complement class test not correct", a.isComplementClass() );
assertTrue( "restriction test not correct", !a.isRestriction() );
}
},
new OntTestCase( "OntClass.isRestriction", true, true, true, false ) {
public void ontTest( OntModel m ) throws Exception {
OntClass a = m.createRestriction( null );
assertTrue( "enumerated class test not correct", m_owlLiteLang || !a.isEnumeratedClass() );
assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
assertTrue( "union class test not correct", m_owlLiteLang || !a.isUnionClass() );
assertTrue( "complement class test not correct", m_owlLiteLang || !a.isComplementClass() );
assertTrue( "restriction test not correct", a.isRestriction() );
}
},
// conversion
new OntTestCase( "OntClass.toEnumeratedClass", true, false, true, false ) {
public void ontTest( OntModel m ) throws Exception {
OntClass a = m.createClass( NS + "A" );
assertTrue( "enumerated class test not correct", !a.isEnumeratedClass() );
assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
assertTrue( "union class test not correct", !a.isUnionClass() );
assertTrue( "complement class test not correct", !a.isComplementClass() );
assertTrue( "restriction test not correct", !a.isRestriction() );
OntClass b = m.createClass( NS + "B" );
Individual x = m.createIndividual( NS + "x", b );
Individual y = m.createIndividual( NS + "y", b );
a = a.convertToEnumeratedClass( m.createList( new RDFNode[] {x, y} ) );
assertTrue( "enumerated class test not correct", a.isEnumeratedClass() );
assertTrue( "intersection class test not correct", !a.isIntersectionClass() );
assertTrue( "union class test not correct", !a.isUnionClass() );
assertTrue( "complement class test not correct", !a.isComplementClass() );
assertTrue( "restriction test not correct", !a.isRestriction() );
}
},
new OntTestCase( "OntClass.toIntersectionClass", true, true, true, false ) {
public void ontTest( OntModel m ) throws Exception {
OntClass a = m.createClass( NS + "A" );
assertTrue( "enumerated class test not correct", m_owlLiteLang || !a.isEnumeratedClass() );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -