diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-05-28 19:14:03 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-05-28 19:14:03 +0100 |
| commit | b8212705e65db860bbb899b16fa0e7bc9e8536cf (patch) | |
| tree | 7343b7349904717a4b99840f44e802e401650044 /test/uk/ac/ox/cs/pagoda/global_tests/TestGapMappedToLower.java | |
| parent | 1055e67727b1aca80ae7ffaceabce3aacb00b6d2 (diff) | |
| download | ACQuA-b8212705e65db860bbb899b16fa0e7bc9e8536cf.tar.gz ACQuA-b8212705e65db860bbb899b16fa0e7bc9e8536cf.zip | |
Bug-fix in tester.
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/global_tests/TestGapMappedToLower.java')
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/global_tests/TestGapMappedToLower.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestGapMappedToLower.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestGapMappedToLower.java new file mode 100644 index 0000000..4b1ec6d --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestGapMappedToLower.java | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.global_tests; | ||
| 2 | |||
| 3 | import junit.framework.Assert; | ||
| 4 | import org.semanticweb.owlapi.apibinding.OWLManager; | ||
| 5 | import org.semanticweb.owlapi.model.*; | ||
| 6 | import org.testng.annotations.Test; | ||
| 7 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | ||
| 8 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | ||
| 9 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; | ||
| 10 | import uk.ac.ox.cs.pagoda.util.Namespace; | ||
| 11 | |||
| 12 | public class TestGapMappedToLower { | ||
| 13 | |||
| 14 | public static final String ns = "http://example.org/test#%s"; | ||
| 15 | |||
| 16 | public IRI getEntityIRI(String name) { | ||
| 17 | return IRI.create(String.format(ns, name)); | ||
| 18 | } | ||
| 19 | |||
| 20 | @Test | ||
| 21 | public void test() throws OWLOntologyCreationException { | ||
| 22 | OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); | ||
| 23 | OWLDataFactory factory = manager.getOWLDataFactory(); | ||
| 24 | OWLOntology ontology = manager.createOntology(); | ||
| 25 | OWLClass A = factory.getOWLClass(getEntityIRI("A")); | ||
| 26 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A)); | ||
| 27 | OWLClass B = factory.getOWLClass(getEntityIRI("B")); | ||
| 28 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(B)); | ||
| 29 | OWLClass C = factory.getOWLClass(getEntityIRI("C")); | ||
| 30 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(C)); | ||
| 31 | OWLClass A1 = factory.getOWLClass(getEntityIRI("A1")); | ||
| 32 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A1)); | ||
| 33 | OWLClass A2 = factory.getOWLClass(getEntityIRI("A2")); | ||
| 34 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A2)); | ||
| 35 | OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a")); | ||
| 36 | OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b")); | ||
| 37 | OWLNamedIndividual c = factory.getOWLNamedIndividual(getEntityIRI("c")); | ||
| 38 | OWLObjectProperty r = factory.getOWLObjectProperty(IRI.create(String.format(ns, "r"))); | ||
| 39 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(r)); | ||
| 40 | |||
| 41 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(A, a)); // A(a) | ||
| 42 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(B, b)); // B(b) | ||
| 43 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(C, c)); // C(c) | ||
| 44 | manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(r, a, b)); // r(a,b) | ||
| 45 | manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(r, a, c)); // r(a,c) | ||
| 46 | manager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(A, factory.getOWLObjectUnionOf(A1, A2))); // A \sqsubseteq A1 \sqcup A2 | ||
| 47 | manager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(A1, factory.getOWLObjectMaxCardinality(1, r))); // A1 \sqsubseteq \leq 1 r.\top | ||
| 48 | manager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(A2, factory.getOWLObjectMaxCardinality(1, r))); // A2 \sqsubseteq \leq 1 r.\top | ||
| 49 | |||
| 50 | QueryReasoner pagoda = QueryReasoner.getInstance(ontology); | ||
| 51 | pagoda.loadOntology(ontology); | ||
| 52 | if (pagoda.preprocess()) { | ||
| 53 | String sparql = "select ?x where { " | ||
| 54 | + "?x <" + r.toStringID() + "> ?y . " | ||
| 55 | + "?y " + Namespace.RDF_TYPE_QUOTED + " <" + B.toStringID() + "> . " | ||
| 56 | + "?y " + Namespace.RDF_TYPE_QUOTED + " <" + C.toStringID() + "> . } "; | ||
| 57 | AnswerTuples rs = pagoda.evaluate(sparql); | ||
| 58 | int count = 0; | ||
| 59 | for (AnswerTuple ans; rs.isValid(); rs.moveNext()) { | ||
| 60 | ans = rs.getTuple(); | ||
| 61 | System.out.println(ans.getGroundTerm(0)); | ||
| 62 | ++count; | ||
| 63 | } | ||
| 64 | Assert.assertEquals(1, count); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | } | ||
