aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java
diff options
context:
space:
mode:
authorRncLsn <rnc.lsn@gmail.com>2015-07-09 16:01:01 +0100
committerRncLsn <rnc.lsn@gmail.com>2015-07-09 16:01:01 +0100
commit3d44aee6069175038266c65f945147569e6343f6 (patch)
treee4eb3f166c28339701636cec513a387673e4ac0a /test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java
parent8241a535a55508b6c504f4f0b426612fe95d15a5 (diff)
downloadACQuA-3d44aee6069175038266c65f945147569e6343f6.tar.gz
ACQuA-3d44aee6069175038266c65f945147569e6343f6.zip
Bug-fix for answer dependencies analysis: now it checks whether the endomorphism makes the first tuple identical to the second one.
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java')
-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}