diff options
Diffstat (limited to 'test/uk')
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java | 59 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java | 14 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/util/TestUtil.java | 7 |
3 files changed, 72 insertions, 8 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java b/test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java new file mode 100644 index 0000000..eec1e8f --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.endomorph; | ||
| 2 | |||
| 3 | import org.semanticweb.owlapi.apibinding.OWLManager; | ||
| 4 | import org.semanticweb.owlapi.model.*; | ||
| 5 | import org.testng.annotations.Test; | ||
| 6 | import uk.ac.ox.cs.JRDFox.model.GroundTerm; | ||
| 7 | import uk.ac.ox.cs.JRDFox.model.Individual; | ||
| 8 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | ||
| 9 | import uk.ac.ox.cs.pagoda.summary.Graph; | ||
| 10 | import uk.ac.ox.cs.pagoda.summary.NodeTuple; | ||
| 11 | import uk.ac.ox.cs.pagoda.util.TestUtil; | ||
| 12 | |||
| 13 | import java.util.HashSet; | ||
| 14 | |||
| 15 | import static uk.ac.ox.cs.pagoda.util.TestUtil.getEntityIRI; | ||
| 16 | |||
| 17 | public class DependencyGraphTest { | ||
| 18 | |||
| 19 | private OWLOntology getOntology() throws OWLOntologyCreationException { | ||
| 20 | OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); | ||
| 21 | OWLDataFactory factory = manager.getOWLDataFactory(); | ||
| 22 | OWLOntology ontology = manager.createOntology(); | ||
| 23 | |||
| 24 | OWLClass hardWorkingStudent = factory.getOWLClass(getEntityIRI("HardWorkingStudent")); | ||
| 25 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(hardWorkingStudent)); | ||
| 26 | OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a")); | ||
| 27 | OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b")); | ||
| 28 | OWLObjectProperty takesCourse = factory.getOWLObjectProperty(IRI.create(String.format(TestUtil.NS, "takesCourse"))); | ||
| 29 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(takesCourse)); | ||
| 30 | |||
| 31 | // Class assertions | ||
| 32 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(hardWorkingStudent, a)); // HardWorkingStudent(a) | ||
| 33 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(hardWorkingStudent, b)); // HardWorkingStudent(b) | ||
| 34 | |||
| 35 | // Minimum cardinality axiom | ||
| 36 | manager.addAxiom(ontology, | ||
| 37 | factory.getOWLEquivalentClassesAxiom(hardWorkingStudent, | ||
| 38 | factory.getOWLObjectMinCardinality(3, | ||
| 39 | takesCourse))); | ||
| 40 | return ontology; | ||
| 41 | } | ||
| 42 | |||
| 43 | @Test | ||
| 44 | public void test() throws OWLOntologyCreationException { | ||
| 45 | OWLOntology ontology = getOntology(); | ||
| 46 | Graph graph = new Graph(ontology); | ||
| 47 | DependencyGraph dependencyGraph = new DependencyGraph(graph); | ||
| 48 | |||
| 49 | HashSet<NodeTuple> tuples = new HashSet<>(); | ||
| 50 | tuples.add(graph.getNodeTuple(new AnswerTuple(new GroundTerm[]{Individual.create(String.format(TestUtil.NS, "a")), Individual.create(String.format(TestUtil.NS, "a"))}))); | ||
| 51 | tuples.add(graph.getNodeTuple(new AnswerTuple(new GroundTerm[]{Individual.create(String.format(TestUtil.NS, "a")), Individual.create(String.format(TestUtil.NS, "b"))}))); | ||
| 52 | tuples.add(graph.getNodeTuple(new AnswerTuple(new GroundTerm[]{Individual.create(String.format(TestUtil.NS, "b")), Individual.create(String.format(TestUtil.NS, "a"))}))); | ||
| 53 | tuples.add(graph.getNodeTuple(new AnswerTuple(new GroundTerm[]{Individual.create(String.format(TestUtil.NS, "b")), Individual.create(String.format(TestUtil.NS, "b"))}))); | ||
| 54 | |||
| 55 | dependencyGraph.build(tuples); | ||
| 56 | |||
| 57 | System.out.println(dependencyGraph.getTopologicalOrder()); | ||
| 58 | } | ||
| 59 | } | ||
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 6e60e24..3f14ec7 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java | |||
| @@ -14,13 +14,11 @@ import java.io.IOException; | |||
| 14 | import java.nio.file.Files; | 14 | import java.nio.file.Files; |
| 15 | import java.nio.file.Paths; | 15 | import java.nio.file.Paths; |
| 16 | 16 | ||
| 17 | import static uk.ac.ox.cs.pagoda.util.TestUtil.getEntityIRI; | ||
| 18 | |||
| 17 | public class BugTests { | 19 | public class BugTests { |
| 18 | 20 | ||
| 19 | public static final String NS = "http://example.org/test#%s"; | ||
| 20 | 21 | ||
| 21 | private IRI getEntityIRI(String name) { | ||
| 22 | return IRI.create(String.format(NS, name)); | ||
| 23 | } | ||
| 24 | 22 | ||
| 25 | @Test | 23 | @Test |
| 26 | public void minimumCardinalityAxiom2() throws OWLOntologyCreationException, IOException, OWLOntologyStorageException { | 24 | public void minimumCardinalityAxiom2() throws OWLOntologyCreationException, IOException, OWLOntologyStorageException { |
| @@ -41,7 +39,7 @@ public class BugTests { | |||
| 41 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(hardWorkingStudent)); | 39 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(hardWorkingStudent)); |
| 42 | OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a")); | 40 | OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a")); |
| 43 | OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b")); | 41 | OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b")); |
| 44 | OWLObjectProperty takesCourse = factory.getOWLObjectProperty(IRI.create(String.format(NS, "takesCourse"))); | 42 | OWLObjectProperty takesCourse = factory.getOWLObjectProperty(IRI.create(String.format(TestUtil.NS, "takesCourse"))); |
| 45 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(takesCourse)); | 43 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(takesCourse)); |
| 46 | 44 | ||
| 47 | // Class assertions | 45 | // Class assertions |
| @@ -105,7 +103,7 @@ public class BugTests { | |||
| 105 | OWLNamedIndividual d1 = factory.getOWLNamedIndividual(getEntityIRI("d1")); | 103 | OWLNamedIndividual d1 = factory.getOWLNamedIndividual(getEntityIRI("d1")); |
| 106 | OWLNamedIndividual d2 = factory.getOWLNamedIndividual(getEntityIRI("d2")); | 104 | OWLNamedIndividual d2 = factory.getOWLNamedIndividual(getEntityIRI("d2")); |
| 107 | OWLNamedIndividual d3 = factory.getOWLNamedIndividual(getEntityIRI("d3")); | 105 | OWLNamedIndividual d3 = factory.getOWLNamedIndividual(getEntityIRI("d3")); |
| 108 | OWLObjectProperty takesCourse = factory.getOWLObjectProperty(IRI.create(String.format(NS, "takesCourse"))); | 106 | OWLObjectProperty takesCourse = factory.getOWLObjectProperty(IRI.create(String.format(TestUtil.NS, "takesCourse"))); |
| 109 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(takesCourse)); | 107 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(takesCourse)); |
| 110 | 108 | ||
| 111 | // Class assertions | 109 | // Class assertions |
| @@ -183,9 +181,9 @@ public class BugTests { | |||
| 183 | OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a")); | 181 | OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a")); |
| 184 | OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b")); | 182 | OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b")); |
| 185 | OWLNamedIndividual c = factory.getOWLNamedIndividual(getEntityIRI("c")); | 183 | OWLNamedIndividual c = factory.getOWLNamedIndividual(getEntityIRI("c")); |
| 186 | OWLObjectProperty roleR = factory.getOWLObjectProperty(IRI.create(String.format(NS, "R"))); | 184 | OWLObjectProperty roleR = factory.getOWLObjectProperty(IRI.create(String.format(TestUtil.NS, "R"))); |
| 187 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(roleR)); | 185 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(roleR)); |
| 188 | OWLObjectProperty roleP = factory.getOWLObjectProperty(IRI.create(String.format(NS, "P"))); | 186 | OWLObjectProperty roleP = factory.getOWLObjectProperty(IRI.create(String.format(TestUtil.NS, "P"))); |
| 189 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(roleP)); | 187 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(roleP)); |
| 190 | 188 | ||
| 191 | // Class assertions | 189 | // Class assertions |
diff --git a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java index fdd242a..c7f024a 100644 --- a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java +++ b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java | |||
| @@ -3,6 +3,7 @@ package uk.ac.ox.cs.pagoda.util; | |||
| 3 | import org.apache.log4j.Appender; | 3 | import org.apache.log4j.Appender; |
| 4 | import org.apache.log4j.FileAppender; | 4 | import org.apache.log4j.FileAppender; |
| 5 | import org.apache.log4j.Logger; | 5 | import org.apache.log4j.Logger; |
| 6 | import org.semanticweb.owlapi.model.IRI; | ||
| 6 | 7 | ||
| 7 | import java.io.File; | 8 | import java.io.File; |
| 8 | import java.io.IOException; | 9 | import java.io.IOException; |
| @@ -87,4 +88,10 @@ public class TestUtil { | |||
| 87 | LOGGER.error(msg, t); | 88 | LOGGER.error(msg, t); |
| 88 | } | 89 | } |
| 89 | 90 | ||
| 91 | public static final String NS = "http://example.org/test#%s"; | ||
| 92 | |||
| 93 | public static IRI getEntityIRI(String name) { | ||
| 94 | return IRI.create(String.format(NS, name)); | ||
| 95 | } | ||
| 96 | |||
| 90 | } | 97 | } |
