public static Graph getGraph() { Graph g = Factory.createGraphMem(); g.add( new Triple( NodeFactory.createURI("http://example.com/subject"), NodeFactory.createURI("http://example.com/predicate"), NodeFactory.createURI("http://example.com/object"))); g.add( new Triple( NodeFactory.createBlankNode(BlankNodeId.create("a")), NodeFactory.createURI("http://example.com/p1"), NodeFactory.createBlankNode(BlankNodeId.create("b")))); g.add( new Triple( NodeFactory.createBlankNode(BlankNodeId.create("b")), NodeFactory.createURI("http://example.com/p2"), NodeFactory.createLiteral("foo"))); g.add( new Triple( NodeFactory.createURI("http://example.com/ns/e"), NodeFactory.createURI("http://example.com/ns/p5"), NodeFactory.createLiteral("verify base works"))); return g; }
public void testRetrieveTriplesByNode() { Graph G = getGraph(); Node N = NodeFactory.createBlankNode(), M = NodeFactory.createBlankNode(); ReifierStd.reifyAs(G, N, triple("x R y")); assertEquals("gets correct triple", triple("x R y"), ReifierStd.getTriple(G, N)); ReifierStd.reifyAs(G, M, triple("p S q")); assertDiffer("the anon nodes must be distinct", N, M); assertEquals("gets correct triple", triple("p S q"), ReifierStd.getTriple(G, M)); assertTrue("node is known bound", ReifierStd.hasTriple(G, M)); assertTrue("node is known bound", ReifierStd.hasTriple(G, N)); assertFalse( "node is known unbound", ReifierStd.hasTriple(G, NodeFactory.createURI("any:thing"))); }
public void testReifyAs() { Graph G = getGraph(); Node X = NodeFactory.createURI("some:uri"); assertEquals("node used", X, ReifierStd.reifyAs(G, X, triple("x R y"))); assertEquals("retrieves correctly", triple("x R y"), ReifierStd.getTriple(G, X)); }