use of org.apache.jena.graph.Graph in project jena by apache.
the class TestIntersection method testIntersectionReflectsChangesToOperands.
public void testIntersectionReflectsChangesToOperands() {
Graph l = graphWith("x R y");
Graph r = graphWith("p S q");
Intersection isec = new Intersection(l, r);
assertIsomorphic(graphWith(""), isec);
// add to the left what is already in the right
l.add(triple("p S q"));
assertIsomorphic(graphWith("p S q"), isec);
// add to the right what is already in the left
r.add(triple("x R y"));
assertIsomorphic(graphWith("p S q; x R y"), isec);
// add to a single graph is not reflected
l.add(triple("p S o"));
r.add(triple("x R z"));
assertIsomorphic(graphWith("p S q; x R y"), isec);
// remove from the left
l.delete(triple("x R y"));
assertIsomorphic(graphWith("p S q"), isec);
// remove from the right
r.delete(triple("p S q"));
assertIsomorphic(graphWith(""), isec);
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class TestDisjointUnion method testRemoveBoth.
public void testRemoveBoth() {
Graph L = graphWith("x R y; a P b"), R = graphWith("x R y; p Q r");
Graph du = new DisjointUnion(L, R);
du.delete(triple("x R y"));
assertIsomorphic(graphWith("a P b"), L);
assertIsomorphic(graphWith("p Q r"), R);
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class TestPackage method suite.
public static TestSuite suite() {
TestSuite result = new TestSuite();
GraphModelFactory gmf = new GraphModelFactory() {
@Override
Graph getGraph() {
return new Intersection(Factory.createGraphMem(), Factory.createGraphMem());
}
};
AbstractTestPackage atp = new AbstractTestPackage("Intersection", gmf) {
};
for (int i = 0; i < atp.testCount(); i++) {
result.addTest(atp.testAt(i));
}
gmf = new GraphModelFactory() {
@Override
Graph getGraph() {
return new Difference(Factory.createGraphMem(), Factory.createGraphMem());
}
};
atp = new AbstractTestPackage("Difference", gmf) {
};
for (int i = 0; i < atp.testCount(); i++) {
result.addTest(atp.testAt(i));
}
gmf = new GraphModelFactory() {
@Override
Graph getGraph() {
return new Union(Factory.createGraphMem(), Factory.createGraphMem());
}
};
atp = new AbstractTestPackage("Union", gmf) {
};
for (int i = 0; i < atp.testCount(); i++) {
result.addTest(atp.testAt(i));
}
/* */
result.addTest(TestDelta.suite());
result.addTest(TestUnion.suite());
result.addTest(TestDisjointUnion.suite());
result.addTest(TestDifference.suite());
result.addTest(TestIntersection.suite());
result.addTestSuite(TestUnionStatistics.class);
result.addTest(TestMultiUnion.suite());
/* */
result.addTest(TestPolyadicPrefixMapping.suite());
return result;
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class TestUnion method testDelete.
public void testDelete() {
Graph l = graphWith("x R y; x R z");
Graph r = graphWith("x R y; p S q");
Union u = new Union(l, r);
u.delete(triple("r A s"));
assertIsomorphic(graphWith("x R y; x R z"), l);
assertIsomorphic(graphWith("x R y; p S q"), r);
u.delete(triple("x R z"));
assertIsomorphic(graphWith("x R y"), l);
assertIsomorphic(graphWith("x R y; p S q"), r);
u.delete(triple("p S q"));
assertIsomorphic(graphWith("x R y"), l);
assertIsomorphic(graphWith("x R y"), r);
u.delete(triple("x R y"));
assertIsomorphic(graphWith(""), l);
assertIsomorphic(graphWith(""), r);
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class TestDelta method testDeleteGoesToDeletions.
public void testDeleteGoesToDeletions() {
Graph base = graphWith(DEFAULT_TRIPLES);
Delta delta = new Delta(base);
delta.delete(triple("x R y"));
assertIsomorphic(graphWith(DEFAULT_TRIPLES), base);
assertIsomorphic(graphWith("x R y"), delta.getDeletions());
assertIsomorphic(graphWith("p S q"), delta);
}
Aggregations