11
11
import org .apache .jena .vocabulary .XSD ;
12
12
import org .junit .jupiter .api .Assertions ;
13
13
import org .junit .jupiter .api .Test ;
14
+ import org .semanticweb .owlapi .model .AxiomType ;
14
15
import org .semanticweb .owlapi .model .IRI ;
15
16
import org .semanticweb .owlapi .model .OWLAnnotationProperty ;
16
17
import org .semanticweb .owlapi .model .OWLAnnotationPropertyRangeAxiom ;
20
21
import org .semanticweb .owlapi .model .OWLDatatype ;
21
22
import org .semanticweb .owlapi .model .OWLDeclarationAxiom ;
22
23
import org .semanticweb .owlapi .model .OWLEntity ;
24
+ import org .semanticweb .owlapi .model .OWLEquivalentClassesAxiom ;
25
+ import org .semanticweb .owlapi .model .OWLLogicalAxiom ;
23
26
import org .semanticweb .owlapi .model .OWLNamedIndividual ;
24
27
import org .semanticweb .owlapi .model .OWLObjectProperty ;
25
28
import org .semanticweb .owlapi .model .OWLSubAnnotationPropertyOfAxiom ;
31
34
public class InfOntModelTest {
32
35
33
36
@ Test
34
- void testListAllAxioms () {
37
+ void testListAllAxiomsAndGetCounts () {
35
38
OntologyManager om = OntManagers .createDirectManager ();
36
39
om .getOntologyConfigurator ().setSpecification (OntSpecification .OWL2_FULL_MEM_RDFS_INF );
37
40
38
41
OntModel m1 = om .createGraphModel ("http://a#A" );
39
42
OntModel m2 = om .createGraphModel ("http://b#B" );
40
43
m1 .addImport (m2 );
41
44
42
- m2 .createOntClass ("http://b#C1" );
43
- m2 .createOntClass ("http://b#C2" );
45
+ m2 .createOntClass ("http://b#C1" )
46
+ .addEquivalentClass (
47
+ m2 .createOntClass ("http://b#C2" )
48
+ );
44
49
m1 .createOntClass ("http://a#C1" );
45
50
46
51
Ontology o1 = Objects .requireNonNull (om .getOntology (IRI .create ("http://a#A" )));
@@ -49,16 +54,34 @@ void testListAllAxioms() {
49
54
// Declaration(Class(<http://b#C2>))
50
55
// Declaration(Class(<http://b#C1>))
51
56
// Declaration(Datatype(rdf:XMLLiteral))
57
+ // EquivalentClasses(<http://b#C1> <http://b#C2>)
52
58
// SubAnnotationPropertyOf(rdfs:isDefinedBy rdfs:isDefinedBy)
53
59
// SubAnnotationPropertyOf(rdfs:isDefinedBy rdfs:seeAlso)
54
60
// SubAnnotationPropertyOf(rdfs:seeAlso rdfs:seeAlso)
55
61
// AnnotationPropertyRange(rdfs:label <http://www.w3.org/2000/01/rdf-schema#Literal>)
56
62
// AnnotationPropertyRange(rdfs:comment <http://www.w3.org/2000/01/rdf-schema#Literal>)
57
- List <OWLAxiom > actual = o1 .axioms (Imports .INCLUDED ).toList ();
58
- Assertions .assertEquals (9 , actual .size ());
59
- Assertions .assertEquals (4 , actual .stream ().filter (it -> it instanceof OWLDeclarationAxiom ).count ());
60
- Assertions .assertEquals (3 , actual .stream ().filter (it -> it instanceof OWLSubAnnotationPropertyOfAxiom ).count ());
61
- Assertions .assertEquals (2 , actual .stream ().filter (it -> it instanceof OWLAnnotationPropertyRangeAxiom ).count ());
63
+ List <OWLAxiom > actual1 = o1 .axioms (Imports .INCLUDED ).toList ();
64
+ Assertions .assertEquals (10 , actual1 .size ());
65
+ Assertions .assertEquals (4 , actual1 .stream ().filter (it -> it instanceof OWLDeclarationAxiom ).count ());
66
+ Assertions .assertEquals (3 , actual1 .stream ().filter (it -> it instanceof OWLSubAnnotationPropertyOfAxiom ).count ());
67
+ Assertions .assertEquals (2 , actual1 .stream ().filter (it -> it instanceof OWLAnnotationPropertyRangeAxiom ).count ());
68
+ Assertions .assertEquals (1 , actual1 .stream ().filter (it -> it instanceof OWLEquivalentClassesAxiom ).count ());
69
+
70
+ Assertions .assertEquals (4 , o1 .axioms (AxiomType .DECLARATION , Imports .INCLUDED ).count ());
71
+ Assertions .assertEquals (3 , o1 .axioms (AxiomType .SUB_ANNOTATION_PROPERTY_OF , Imports .INCLUDED ).count ());
72
+ Assertions .assertEquals (2 , o1 .axioms (AxiomType .ANNOTATION_PROPERTY_RANGE , Imports .INCLUDED ).count ());
73
+ Assertions .assertEquals (1 , o1 .axioms (AxiomType .EQUIVALENT_CLASSES , Imports .INCLUDED ).count ());
74
+
75
+ List <OWLLogicalAxiom > actual2 = o1 .logicalAxioms (Imports .INCLUDED ).toList ();
76
+ Assertions .assertEquals (1 , actual2 .size ());
77
+
78
+ Assertions .assertEquals (10 , o1 .getAxiomCount (Imports .INCLUDED ));
79
+ Assertions .assertEquals (1 , o1 .getLogicalAxiomCount (Imports .INCLUDED ));
80
+
81
+ Assertions .assertEquals (4 , o1 .getAxiomCount (AxiomType .DECLARATION , Imports .INCLUDED ));
82
+ Assertions .assertEquals (3 , o1 .getAxiomCount (AxiomType .SUB_ANNOTATION_PROPERTY_OF , Imports .INCLUDED ));
83
+ Assertions .assertEquals (2 , o1 .getAxiomCount (AxiomType .ANNOTATION_PROPERTY_RANGE , Imports .INCLUDED ));
84
+ Assertions .assertEquals (1 , o1 .getAxiomCount (AxiomType .EQUIVALENT_CLASSES , Imports .INCLUDED ));
62
85
}
63
86
64
87
@ Test
0 commit comments