use of org.apache.jena.graph.Graph in project jena by apache.
the class TestDifference method testAdd.
public void testAdd() {
Graph l = graphWith("x R y");
Graph r = graphWith("x R y; x R z");
Difference diff = new Difference(l, r);
assertIsomorphic(graphWith(""), diff);
// case 1: add to the left operand
diff.add(triple("p S q"));
assertIsomorphic(graphWith("p S q"), diff);
assertIsomorphic(graphWith("x R y; p S q"), l);
assertIsomorphic(graphWith("x R y; x R z"), r);
// case 2: remove from the right, and add to the left operand
diff.add(triple("x R z"));
assertIsomorphic(graphWith("x R z; p S q"), diff);
assertIsomorphic(graphWith("x R y; x R z; p S q"), l);
assertIsomorphic(graphWith("x R y"), r);
// case 3: remove from the right operand
diff.add(triple("x R y"));
assertIsomorphic(graphWith("x R y; x R z; p S q"), diff);
assertIsomorphic(graphWith("x R y; x R z; p S q"), l);
assertIsomorphic(graphWith(""), r);
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class TestDisjointUnion method testRightUnion.
public void testRightUnion() {
Graph g = graphWith("");
testSingleComponent(g, new DisjointUnion(Graph.emptyGraph, g));
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class TestDisjointUnion method testBothComponents.
public void testBothComponents() {
Graph L = graphWith(""), R = graphWith("");
Graph du = new DisjointUnion(L, R);
assertIsomorphic(Graph.emptyGraph, du);
L.add(triple("x P y"));
assertIsomorphic(graphWith("x P y"), du);
R.add(triple("A rdf:type Route"));
assertIsomorphic(graphWith("x P y; A rdf:type Route"), du);
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class TestDisjointUnion method testLeftUnion.
public void testLeftUnion() {
Graph g = graphWith("");
testSingleComponent(g, new DisjointUnion(g, Graph.emptyGraph));
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class TestDisjointUnion method testAddLeftOnlyIfNecessary.
public void testAddLeftOnlyIfNecessary() {
Graph L = graphWith(""), R = graphWith("x R y");
Graph du = new DisjointUnion(L, R);
graphAdd(du, "x R y");
assertEquals(true, L.isEmpty());
graphAdd(du, " a P b");
assertIsomorphic(graphWith("a P b"), L);
assertIsomorphic(graphWith("x R y"), R);
}
Aggregations