| 1 | package conformancetests; |
| 2 | |
| 3 | import static org.junit.Assert.assertEquals; |
| 4 | |
| 5 | import java.util.Set; |
| 6 | |
| 7 | import org.junit.Test; |
| 8 | import org.semanticweb.owlapi.apibinding.OWLManager; |
| 9 | import org.semanticweb.owlapi.model.IRI; |
| 10 | import org.semanticweb.owlapi.model.OWLClass; |
| 11 | import org.semanticweb.owlapi.model.OWLDataFactory; |
| 12 | import org.semanticweb.owlapi.model.OWLOntology; |
| 13 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; |
| 14 | import org.semanticweb.owlapi.model.OWLOntologyManager; |
| 15 | import org.semanticweb.owlapi.reasoner.InferenceType; |
| 16 | import org.semanticweb.owlapi.reasoner.NodeSet; |
| 17 | import org.semanticweb.owlapi.reasoner.OWLReasoner; |
| 18 | |
| 19 | import testbase.TestBase; |
| 20 | |
| 21 | @SuppressWarnings("javadoc") |
| 22 | public class StrangeTestCase extends TestBase { |
| 23 | |
| 24 | @Test |
| 25 | public void shouldFindThreeSubclasses() throws OWLOntologyCreationException { |
| 26 | OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 27 | OWLOntology o = m.createOntology(); |
| 28 | OWLDataFactory d = m.getOWLDataFactory(); |
| 29 | m.addAxiom( |
| 30 | o, |
| 31 | d.getOWLSubClassOfAxiom(d.getOWLClass(IRI.create("urn:b")), |
| 32 | d.getOWLClass(IRI.create("urn:c")))); |
| 33 | m.addAxiom( |
| 34 | o, |
| 35 | d.getOWLSubClassOfAxiom(d.getOWLClass(IRI.create("urn:a")), |
| 36 | d.getOWLClass(IRI.create("urn:b")))); |
| 37 | OWLReasoner r = factory().createReasoner(o); |
| 38 | r.precomputeInferences(InferenceType.CLASS_HIERARCHY); |
| 39 | NodeSet<OWLClass> subClasses = r.getSubClasses( |
| 40 | d.getOWLClass(IRI.create("urn:c")), false); |
| 41 | Set<OWLClass> flat = subClasses.getFlattened(); |
| 42 | assertEquals(flat.toString(), 3, flat.size()); |
| 43 | } |
| 44 | } |