diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-09-03 15:09:35 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-09-03 15:09:35 +0100 |
| commit | 1c02a4bde9eddb66550341377b2bd980ff48c474 (patch) | |
| tree | 6e86500be926c98fd5f285b8410fe88e8805423c /test/uk/ac/ox/cs/pagoda/global_tests | |
| parent | 90cb6032058ad3fc16b895922823b5a700121b1b (diff) | |
| download | ACQuA-1c02a4bde9eddb66550341377b2bd980ff48c474.tar.gz ACQuA-1c02a4bde9eddb66550341377b2bd980ff48c474.zip | |
New test cases.
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/global_tests')
3 files changed, 90 insertions, 1 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/MadeUpCases.java b/test/uk/ac/ox/cs/pagoda/global_tests/MadeUpCases.java new file mode 100644 index 0000000..3d154cb --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/MadeUpCases.java | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.global_tests; | ||
| 2 | |||
| 3 | import org.semanticweb.owlapi.apibinding.OWLManager; | ||
| 4 | import org.semanticweb.owlapi.model.*; | ||
| 5 | import org.testng.Assert; | ||
| 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.TestUtil; | ||
| 11 | |||
| 12 | import java.io.IOException; | ||
| 13 | |||
| 14 | import static uk.ac.ox.cs.pagoda.util.TestUtil.getEntityIRI; | ||
| 15 | |||
| 16 | public class MadeUpCases { | ||
| 17 | |||
| 18 | @Test(groups = {"existential"}) | ||
| 19 | public void someTest() throws OWLOntologyCreationException, IOException, OWLOntologyStorageException { | ||
| 20 | |||
| 21 | /* | ||
| 22 | * Build test ontology | ||
| 23 | * */ | ||
| 24 | |||
| 25 | OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); | ||
| 26 | OWLDataFactory factory = manager.getOWLDataFactory(); | ||
| 27 | OWLOntology ontology = manager.createOntology(); | ||
| 28 | |||
| 29 | OWLClass A1 = factory.getOWLClass(getEntityIRI("A1")); | ||
| 30 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A1)); | ||
| 31 | OWLClass A2 = factory.getOWLClass(getEntityIRI("A2")); | ||
| 32 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A2)); | ||
| 33 | OWLClass A3 = factory.getOWLClass(getEntityIRI("A3")); | ||
| 34 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A3)); | ||
| 35 | OWLClass A4 = factory.getOWLClass(getEntityIRI("A4")); | ||
| 36 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A4)); | ||
| 37 | OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a")); | ||
| 38 | OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b")); | ||
| 39 | OWLObjectProperty R = factory.getOWLObjectProperty(IRI.create(String.format(TestUtil.NS, "R"))); | ||
| 40 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(R)); | ||
| 41 | |||
| 42 | // Class assertions | ||
| 43 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(A1, a)); | ||
| 44 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(A1, b)); | ||
| 45 | |||
| 46 | // Minimum cardinality axiom | ||
| 47 | manager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(A1, factory.getOWLObjectSomeValuesFrom(R, A2))); | ||
| 48 | manager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(A2, factory.getOWLObjectSomeValuesFrom(R, A3))); | ||
| 49 | manager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(A3, factory.getOWLObjectSomeValuesFrom(R, A4))); | ||
| 50 | manager.addAxiom(ontology, factory.getOWLTransitiveObjectPropertyAxiom(R)); | ||
| 51 | |||
| 52 | // manager.saveOntology(ontology, Files.newOutputStream(Paths.get("/home/alessandro/Desktop/test-ontology.owl"))); | ||
| 53 | |||
| 54 | /* | ||
| 55 | * Test one query | ||
| 56 | * */ | ||
| 57 | |||
| 58 | QueryReasoner pagoda = QueryReasoner.getInstance(ontology); | ||
| 59 | pagoda.loadOntology(ontology); | ||
| 60 | if (pagoda.preprocess()) { | ||
| 61 | String query = "select distinct ?x ?y " + | ||
| 62 | " where { " | ||
| 63 | + " ?x <" + R.toStringID() + "> _:z . " | ||
| 64 | + " ?y <" + R.toStringID() + "> _:z " + | ||
| 65 | " }"; | ||
| 66 | AnswerTuples answers = pagoda.evaluate(query); | ||
| 67 | int count = 0; | ||
| 68 | for (AnswerTuple ans; answers.isValid(); answers.moveNext()) { | ||
| 69 | ans = answers.getTuple(); | ||
| 70 | TestUtil.logInfo(ans); | ||
| 71 | count++; | ||
| 72 | } | ||
| 73 | Assert.assertEquals(count, 2); | ||
| 74 | } | ||
| 75 | pagoda.dispose(); | ||
| 76 | } | ||
| 77 | } | ||
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaReactome.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaReactome.java index 6ef03c5..a13b7f4 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaReactome.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaReactome.java | |||
| @@ -37,4 +37,16 @@ public class TestPagodaReactome { | |||
| 37 | .run(); | 37 | .run(); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | @Test(groups = {"existential"}) | ||
| 41 | public void justExecute_existential() throws IOException { | ||
| 42 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 43 | |||
| 44 | Pagoda.builder() | ||
| 45 | .ontology(Paths.get(ontoDir, "reactome/biopax-level3-processed.owl")) | ||
| 46 | .data(Paths.get(ontoDir, "reactome/data/sample_10.ttl")) | ||
| 47 | .query(Paths.get(ontoDir, "reactome/existential_queries.sparql")) | ||
| 48 | .build() | ||
| 49 | .run(); | ||
| 50 | } | ||
| 51 | |||
| 40 | } | 52 | } |
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java index 426bdf2..4dae223 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java | |||
| @@ -85,7 +85,7 @@ public class TestPagodaUOBM { | |||
| 85 | .run(); | 85 | .run(); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | @Test(groups = {"justExecute", "heavy", "nonOriginal"}) | 88 | @Test(groups = {"justExecute", "heavy", "nonOriginal", "existential"}) |
| 89 | public void justExecute_modifiedUOBM() throws IOException { | 89 | public void justExecute_modifiedUOBM() throws IOException { |
| 90 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | 90 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); |
| 91 | 91 | ||
