use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereHandlerTest method testAddUnionOfOne.
@Test
public void testAddUnionOfOne() {
Triple t1 = new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createURI("three"));
SelectBuilder sb = new SelectBuilder().addWhere(t1);
handler.addUnion(sb);
handler.build();
ElementPathBlock epb1 = new ElementPathBlock();
epb1.addTriple(t1);
WhereValidator visitor = new WhereValidator(epb1);
handler.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereHandlerTest method testSetVarsInWhereValues.
@Test
public void testSetVarsInWhereValues() {
Var v = Var.alloc("v");
Node value = NodeFactory.createLiteral(LiteralLabelFactory.createTypedLiteral(10));
Map<Var, Node> values = new HashMap<>();
values.put(v, value);
handler.addValueVar(query.getPrefixMapping(), "?x", "<one>", "?v");
handler.setVars(values);
handler.build();
ElementData edat = new ElementData();
Var x = Var.alloc("x");
edat.add(x);
Binding binding1 = BindingFactory.binding(x, NodeFactory.createURI("one"));
edat.add(binding1);
Binding binding2 = BindingFactory.binding(x, value);
edat.add(binding2);
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 testBindExprVar.
@Test
public void testBindExprVar() {
Var v = Var.alloc("foo");
handler.addBind(new E_Random(), v);
handler.build();
ElementBind bind = new ElementBind(Var.alloc("foo"), new E_Random());
WhereValidator visitor = new WhereValidator(bind);
handler.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereHandlerTest method testSetVarsInFilter.
@Test
public void testSetVarsInFilter() throws ParseException {
handler.addFilter("?one < ?v");
handler.build();
E_LessThan expr = new ExprFactory().lt(NodeFactory.createVariable("one"), NodeFactory.createVariable("v"));
WhereValidator visitor = new WhereValidator(new ElementFilter(expr));
handler.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
Map<Var, Node> values = new HashMap<>();
values.put(Var.alloc("v"), NodeFactory.createLiteral(LiteralLabelFactory.createTypedLiteral(10)));
handler.setVars(values);
handler.build();
expr = new ExprFactory().lt(NodeFactory.createVariable("one"), NodeFactory.createLiteral(LiteralLabelFactory.createTypedLiteral(10)));
visitor = new WhereValidator(new ElementFilter(expr));
handler.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereHandlerTest method testAddValueVar_pfx_obj.
@Test
public void testAddValueVar_pfx_obj() {
handler.addValueVar(query.getPrefixMapping(), "?v");
handler.build();
Var v = Var.alloc("v");
ElementData edat = new ElementData();
edat.add(v);
WhereValidator visitor = new WhereValidator(edat);
query.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
Aggregations