use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testContains_Node_Node_Node.
@ContractTest
public void testContains_Node_Node_Node() {
Graph graph = graphWith(producer.newInstance(), "S P O; S2 P2 O2; S3 P3 O3");
assertTrue(graph.contains(node("S"), node("P"), node("O")));
assertFalse(graph.contains(node("S"), node("P"), node("O2")));
assertFalse(graph.contains(node("S"), node("P2"), node("O")));
assertFalse(graph.contains(node("S2"), node("P"), node("O")));
assertTrue(graph.contains(Node.ANY, Node.ANY, Node.ANY));
assertTrue(graph.contains(Node.ANY, Node.ANY, node("O")));
assertTrue(graph.contains(Node.ANY, node("P"), Node.ANY));
assertTrue(graph.contains(node("S"), Node.ANY, Node.ANY));
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testFind_Node_Node_Node_ProgrammaticValues.
@ContractTest
public void testFind_Node_Node_Node_ProgrammaticValues() {
Graph g = producer.newInstance();
if (g.getCapabilities().handlesLiteralTyping()) {
Node ab = NodeFactory.createLiteral(LiteralLabelFactory.createTypedLiteral(new Byte((byte) 42)));
Node as = NodeFactory.createLiteral(LiteralLabelFactory.createTypedLiteral(new Short((short) 42)));
Node ai = NodeFactory.createLiteral(LiteralLabelFactory.createTypedLiteral(new Integer(42)));
Node al = NodeFactory.createLiteral(LiteralLabelFactory.createTypedLiteral(new Long(42)));
Node SB = NodeCreateUtils.create("SB");
Node SS = NodeCreateUtils.create("SS");
Node SI = NodeCreateUtils.create("SI");
Node SL = NodeCreateUtils.create("SL");
Node P = NodeCreateUtils.create("P");
txnBegin(g);
try {
g.add(Triple.create(SB, P, ab));
g.add(Triple.create(SS, P, as));
g.add(Triple.create(SI, P, ai));
g.add(Triple.create(SL, P, al));
} catch (Exception e) {
txnRollback(g);
fail(e.getMessage());
}
txnCommit(g);
assertEquals(String.format("Should have found 4 elements, does %s really implement literal typing", g.getClass()), 4, iteratorToSet(g.find(Node.ANY, P, NodeCreateUtils.create("42"))).size());
}
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphMakerContractTest method testCarefulClose.
@ContractTest
public void testCarefulClose() {
Graph x = graphMaker.createGraph("x");
Graph y = graphMaker.openGraph("x");
x.add(GraphHelper.triple("a BB c"));
x.close();
y.add(GraphHelper.triple("p RR q"));
y.close();
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testFind_Triple_ByFluidTriple.
@ContractTest
public void testFind_Triple_ByFluidTriple() {
Graph g = graphWith(producer.newInstance(), "x y z ");
Set<Triple> expect = tripleSet("x y z");
assertEquals(expect, g.find(triple("?? y z")).toSet());
assertEquals(expect, g.find(triple("x ?? z")).toSet());
assertEquals(expect, g.find(triple("x y ??")).toSet());
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testContains_Node_Node_Node_Fluid.
@ContractTest
public void testContains_Node_Node_Node_Fluid() {
Node x = node("x");
Node R = node("R");
Node P = node("P");
Node y = node("y");
Node a = node("a");
Node b = node("b");
Graph g = graphWith(producer.newInstance(), "x R y; a P b");
assertTrue(g.contains(Node.ANY, R, y));
assertTrue(g.contains(x, Node.ANY, y));
assertTrue(g.contains(x, R, Node.ANY));
assertTrue(g.contains(Node.ANY, P, b));
assertTrue(g.contains(a, Node.ANY, b));
assertTrue(g.contains(a, P, Node.ANY));
assertTrue(g.contains(Node.ANY, R, y));
/* */
assertFalse(g.contains(Node.ANY, R, b));
assertFalse(g.contains(a, Node.ANY, y));
assertFalse(g.contains(x, P, Node.ANY));
assertFalse(g.contains(Node.ANY, R, x));
assertFalse(g.contains(x, Node.ANY, R));
assertFalse(g.contains(a, node("S"), Node.ANY));
}
Aggregations