aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java')
-rw-r--r--test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java60
1 files changed, 59 insertions, 1 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java b/test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java
index 19e0b2a..6e60e24 100644
--- a/test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java
+++ b/test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java
@@ -23,6 +23,64 @@ public class BugTests {
23 } 23 }
24 24
25 @Test 25 @Test
26 public void minimumCardinalityAxiom2() throws OWLOntologyCreationException, IOException, OWLOntologyStorageException {
27
28 /*
29 * Build test ontology
30 * */
31
32 OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
33 OWLDataFactory factory = manager.getOWLDataFactory();
34 OWLOntology ontology = manager.createOntology();
35
36// OWLClass student = factory.getOWLClass(getEntityIRI("Student"));
37// manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(student));
38// OWLClass course = factory.getOWLClass(getEntityIRI("Course"));
39// manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(course));
40 OWLClass hardWorkingStudent = factory.getOWLClass(getEntityIRI("HardWorkingStudent"));
41 manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(hardWorkingStudent));
42 OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a"));
43 OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b"));
44 OWLObjectProperty takesCourse = factory.getOWLObjectProperty(IRI.create(String.format(NS, "takesCourse")));
45 manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(takesCourse));
46
47 // Class assertions
48 manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(hardWorkingStudent, a)); // HardWorkingStudent(a)
49 manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(hardWorkingStudent, b)); // HardWorkingStudent(b)
50
51 // Minimum cardinality axiom
52 manager.addAxiom(ontology,
53 factory.getOWLEquivalentClassesAxiom(hardWorkingStudent,
54 factory.getOWLObjectMinCardinality(3,
55 takesCourse)));
56
57// manager.saveOntology(ontology, Files.newOutputStream(Paths.get("/home/alessandro/Desktop/test-ontology.owl")));
58
59 /*
60 * Test one query
61 * */
62
63 QueryReasoner pagoda = QueryReasoner.getInstance(ontology);
64 pagoda.loadOntology(ontology);
65 if (pagoda.preprocess()) {
66 String query = "select distinct ?x ?y " +
67 " where { "
68 + " ?x <" + takesCourse.toStringID() + "> _:z . "
69 + " ?y <" + takesCourse.toStringID() + "> _:z " +
70 " }";
71 AnswerTuples answers = pagoda.evaluate(query);
72 int count = 0;
73 for (AnswerTuple ans; answers.isValid(); answers.moveNext()) {
74 ans = answers.getTuple();
75 TestUtil.logInfo(ans);
76 count++;
77 }
78 Assert.assertEquals(count, 2);
79 }
80 pagoda.dispose();
81 }
82
83// @Test
26 public void minimumCardinalityAxiom() throws OWLOntologyCreationException, IOException, OWLOntologyStorageException { 84 public void minimumCardinalityAxiom() throws OWLOntologyCreationException, IOException, OWLOntologyStorageException {
27 85
28 /* 86 /*
@@ -107,7 +165,7 @@ public class BugTests {
107 * @throws IOException 165 * @throws IOException
108 * @throws OWLOntologyStorageException 166 * @throws OWLOntologyStorageException
109 */ 167 */
110 @Test 168// @Test
111 public void rTest() throws OWLOntologyCreationException, IOException, OWLOntologyStorageException { 169 public void rTest() throws OWLOntologyCreationException, IOException, OWLOntologyStorageException {
112 170
113 /* 171 /*