aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/pagoda/endomorph
diff options
context:
space:
mode:
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/endomorph')
-rw-r--r--test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java59
1 files changed, 59 insertions, 0 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 @@
1package uk.ac.ox.cs.pagoda.endomorph;
2
3import org.semanticweb.owlapi.apibinding.OWLManager;
4import org.semanticweb.owlapi.model.*;
5import org.testng.annotations.Test;
6import uk.ac.ox.cs.JRDFox.model.GroundTerm;
7import uk.ac.ox.cs.JRDFox.model.Individual;
8import uk.ac.ox.cs.pagoda.query.AnswerTuple;
9import uk.ac.ox.cs.pagoda.summary.Graph;
10import uk.ac.ox.cs.pagoda.summary.NodeTuple;
11import uk.ac.ox.cs.pagoda.util.TestUtil;
12
13import java.util.HashSet;
14
15import static uk.ac.ox.cs.pagoda.util.TestUtil.getEntityIRI;
16
17public 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}