use of org.apache.jena.sparql.path.P_Link in project jena by apache.
the class WhereQuadHolderTest method namedTest_Var.
@Test
public void namedTest_Var() {
holder = new WhereQuadHolder(new PrefixHandler());
Node g = NodeFactory.createURI("g");
List<Triple> tLst = new ArrayList<Triple>();
Node s = NodeFactory.createURI("s");
Node p = NodeFactory.createVariable("p");
Node o = NodeFactory.createURI("o");
WhereHandler whereHandler = new WhereHandler();
whereHandler.addWhere(new TriplePath(s, new P_Link(p), o));
holder.addGraph(g, whereHandler);
Node s2 = NodeFactory.createURI("s2");
Node p2 = NodeFactory.createURI("p2");
Node o2 = NodeFactory.createURI("o2");
whereHandler = new WhereHandler();
whereHandler.addWhere(new TriplePath(s2, new P_Link(p2), o2));
holder.addGraph(g, whereHandler);
tLst.add(new Triple(s, p2, o));
tLst.add(new Triple(s2, p2, o2));
Map<Var, Node> map = new HashMap<>();
map.put(Var.alloc(p), p2);
holder.setValues(map);
List<Quad> lst = holder.getQuads().toList();
assertEquals(2, lst.size());
assertEquals(new Quad(g, tLst.get(0)), lst.get(0));
assertEquals(new Quad(g, tLst.get(1)), lst.get(1));
}
use of org.apache.jena.sparql.path.P_Link in project jena by apache.
the class WhereQuadHolderTest method mixedTest_Var.
@Test
public void mixedTest_Var() {
holder = new WhereQuadHolder(new PrefixHandler());
List<Triple> tLst = new ArrayList<Triple>();
Node s = NodeFactory.createURI("s");
Node p = NodeFactory.createVariable("p");
Node o = NodeFactory.createURI("o");
holder.addWhere(new TriplePath(s, new P_Link(p), o));
Node g = NodeFactory.createURI("g");
Node s2 = NodeFactory.createURI("s2");
Node p2 = NodeFactory.createURI("p2");
Node o2 = NodeFactory.createURI("o2");
tLst.add(new Triple(s, p2, o));
tLst.add(new Triple(s2, p2, o2));
WhereHandler whereHandler = new WhereHandler();
whereHandler.addWhere(new TriplePath(s2, new P_Link(p2), o2));
holder.addGraph(g, whereHandler);
Map<Var, Node> map = new HashMap<>();
map.put(Var.alloc(p), p2);
holder.setValues(map);
List<Quad> lst = holder.getQuads().toList();
assertEquals(2, lst.size());
assertEquals(new Quad(Quad.defaultGraphNodeGenerated, tLst.get(0)), lst.get(0));
assertEquals(new Quad(g, tLst.get(1)), lst.get(1));
}
use of org.apache.jena.sparql.path.P_Link in project jena by apache.
the class WhereQuadHolderTest method mixedTest.
@Test
public void mixedTest() {
holder = new WhereQuadHolder(new PrefixHandler());
List<Triple> tLst = new ArrayList<Triple>();
Node s = NodeFactory.createURI("s");
Node p = NodeFactory.createURI("p");
Node o = NodeFactory.createURI("o");
tLst.add(new Triple(s, p, o));
holder.addWhere(new TriplePath(s, new P_Link(p), o));
Node g = NodeFactory.createURI("g");
Node s2 = NodeFactory.createURI("s2");
Node p2 = NodeFactory.createURI("p2");
Node o2 = NodeFactory.createURI("o2");
tLst.add(new Triple(s2, p2, o2));
WhereHandler whereHandler = new WhereHandler();
whereHandler.addWhere(new TriplePath(s2, new P_Link(p2), o2));
holder.addGraph(g, whereHandler);
List<Quad> lst = holder.getQuads().toList();
assertEquals(2, lst.size());
assertEquals(new Quad(Quad.defaultGraphNodeGenerated, tLst.get(0)), lst.get(0));
assertEquals(new Quad(g, tLst.get(1)), lst.get(1));
}
use of org.apache.jena.sparql.path.P_Link in project jena by apache.
the class UpdateBuilderTest method testPathInWhereClause.
@Test
public void testPathInWhereClause() {
Node p = NodeFactory.createURI("http://example.com/p");
Path path = new P_Link(p);
// JENA-1739 fails here
new UpdateBuilder().addDelete("?s", "<x>", "?p").addWhere("?s", path, "?p").build();
}
use of org.apache.jena.sparql.path.P_Link in project jena by apache.
the class UpdateBuilderTest method testPathInOptionalClause.
@Test
public void testPathInOptionalClause() {
Node p = NodeFactory.createURI("http://example.com/p");
Path path = new P_Link(p);
// JENA-1739 fails here
new UpdateBuilder().addDelete("?s", "<x>", "?p").addOptional("?s", path, "?p").build();
}
Aggregations