use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereHandlerTest method addWhereTriple.
@Test
public void addWhereTriple() {
handler.addWhere(new TriplePath(new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createURI("three"))));
handler.build();
Triple t1 = new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createURI("three"));
TriplePath tp = new TriplePath(t1);
ElementPathBlock epb = new ElementPathBlock();
epb.addTriple(tp);
WhereValidator wv = new WhereValidator(epb);
query.getQueryPattern().visit(wv);
assertTrue(wv.matching);
}
use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereHandlerTest method testAddWhereAnonymous.
@Test
public void testAddWhereAnonymous() {
handler.addWhere(new TriplePath(new Triple(Node.ANY, RDF.first.asNode(), Node.ANY)));
handler.build();
TriplePath tp = new TriplePath(new Triple(Node.ANY, RDF.first.asNode(), Node.ANY));
ElementPathBlock epb = new ElementPathBlock();
epb.addTriple(tp);
WhereValidator wv = new WhereValidator(epb);
query.getQueryPattern().visit(wv);
assertTrue(wv.matching);
}
use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereHandlerTest method testMakeSubQueryFromSelectWithOutVar.
@Test
public void testMakeSubQueryFromSelectWithOutVar() {
SelectBuilder sb = new SelectBuilder().addWhere("?x", RDF.type, RDF.Alt);
ElementSubQuery esq = handler.makeSubQuery(sb);
Triple t1 = new Triple(NodeFactory.createVariable("x"), RDF.type.asNode(), RDF.Alt.asNode());
TriplePath tp = new TriplePath(t1);
ElementPathBlock epb = new ElementPathBlock();
epb.addTriple(tp);
Query q = new Query();
q.setQuerySelectType();
q.setQueryResultStar(true);
q.setQueryPattern(epb);
ElementSubQuery esq2 = new ElementSubQuery(q);
WhereValidator wv = new WhereValidator(esq2);
esq.visit(wv);
assertTrue(wv.matching);
}
use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereHandlerTest method testAddValueRow_pfx_array.
@Test
public void testAddValueRow_pfx_array() {
final Var v = Var.alloc("v");
final Var x = Var.alloc("x");
handler.addValueVar(query.getPrefixMapping(), v);
handler.addValueVar(query.getPrefixMapping(), x);
handler.addValueRow(query.getPrefixMapping(), "<one>", "three");
handler.addValueRow(query.getPrefixMapping(), "<two>", "four");
handler.build();
ElementData edat = new ElementData();
edat.add(v);
edat.add(x);
setupBindings(edat, x, v);
WhereValidator visitor = new WhereValidator(edat);
query.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereHandlerTest method testAddUnion.
@Test
public void testAddUnion() {
Triple t1 = new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createURI("three"));
Triple t2 = new Triple(NodeFactory.createURI("uno"), NodeFactory.createURI("dos"), NodeFactory.createURI("tres"));
SelectBuilder sb1 = new SelectBuilder().addWhere(t1);
SelectBuilder sb2 = new SelectBuilder().addWhere(t2);
handler.addUnion(sb1);
handler.addUnion(sb2);
handler.build();
ElementUnion union = new ElementUnion();
ElementPathBlock epb1 = new ElementPathBlock();
epb1.addTriple(t1);
union.addElement(epb1);
ElementPathBlock epb2 = new ElementPathBlock();
epb2.addTriple(t2);
union.addElement(epb2);
WhereValidator visitor = new WhereValidator(union);
handler.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
Aggregations