use of org.apache.jena.arq.querybuilder.ExprFactory in project jena by apache.
the class WhereHandlerTest method testAddFilterVarOnly.
@Test
public void testAddFilterVarOnly() throws ParseException {
handler.addFilter("?one");
handler.build();
ExprFactory fact = new ExprFactory();
WhereValidator visitor = new WhereValidator(new ElementFilter(fact.asExpr("?one")));
handler.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.arq.querybuilder.ExprFactory 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.ExprFactory in project jena by apache.
the class WhereHandlerTest method testAddFilter.
@Test
public void testAddFilter() throws ParseException {
handler.addFilter("?one < 10");
handler.build();
BigInteger bi = new BigInteger(Integer.toString(10));
E_LessThan expr = new ExprFactory().lt(NodeFactory.createVariable("one"), bi);
WhereValidator visitor = new WhereValidator(new ElementFilter(expr));
handler.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.arq.querybuilder.ExprFactory in project jena by apache.
the class WhereHandlerTest method testAddFilterWithNamespace.
@Test
public void testAddFilterWithNamespace() throws ParseException {
query.setPrefix("afn", "http://jena.apache.org/ARQ/function#");
handler.addFilter("afn:namespace(?one) = 'foo'");
handler.build();
ExprFactory fact = new ExprFactory();
E_Function func = new E_Function("http://jena.apache.org/ARQ/function#namespace", fact.asList("?one"));
E_Equals expr = fact.eq(func, "foo");
WhereValidator visitor = new WhereValidator(new ElementFilter(expr));
handler.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
Aggregations