use of org.apache.jena.sparql.expr.Expr in project jena by apache.
the class TestExpressions method testNumeric.
private static void testNumeric(String string, double d) {
Expr expr = parse(string);
NodeValue v = expr.eval(BindingFactory.binding(), new FunctionEnvBase());
assertTrue(v.isDouble());
assertEquals(d, v.getDouble(), 0);
}
use of org.apache.jena.sparql.expr.Expr in project jena by apache.
the class TestExpressions2 method eval.
// It's easier to write tests that simply are expected to return true/false
/*package*/
static void eval(String string, boolean result) {
Expr expr = ExprUtils.parse(string);
NodeValue nv = expr.eval(null, FunctionEnvBase.createTest());
boolean b = XSDFuncOp.booleanEffectiveValue(nv);
assertEquals(string, result, b);
}
use of org.apache.jena.sparql.expr.Expr in project jena by apache.
the class SelectHandlerTest method testAddAggregateStringVar.
@Test
public void testAddAggregateStringVar() {
Var v = Var.alloc("foo");
handler.addVar("count(*)", v);
VarExprList expr = query.getProject();
assertEquals(1, expr.size());
Expr e = expr.getExpr(Var.alloc("foo"));
assertNotNull("expression should not be null", e);
assertTrue("Should be an ExprAggregator", e instanceof ExprAggregator);
assertTrue("Should be AggCount", ((ExprAggregator) e).getAggregator() instanceof AggCount);
}
use of org.apache.jena.sparql.expr.Expr in project jena by apache.
the class SelectHandlerTest method testAddStringWithPrefixVar.
@Test
public void testAddStringWithPrefixVar() {
query.setPrefix("xsd", "http://www.w3.org/2001/XMLSchema#");
Var v = Var.alloc("foo");
handler.addVar("sum(xsd:integer(?V3))", v);
VarExprList expr = query.getProject();
assertEquals(1, expr.size());
Expr e = expr.getExpr(Var.alloc("foo"));
assertNotNull("expression should not be null", e);
assertTrue("Should be an ExprAggregator", e instanceof ExprAggregator);
assertTrue("Should contain an AggSum", ((ExprAggregator) e).getAggregator() instanceof AggSum);
}
use of org.apache.jena.sparql.expr.Expr in project jena by apache.
the class SelectHandlerTest method testAddExprVar.
@Test
public void testAddExprVar() {
Var v = Var.alloc("foo");
handler.addVar(new E_Random(), v);
VarExprList expr = query.getProject();
assertEquals(1, expr.size());
Expr e = expr.getExpr(Var.alloc("foo"));
assertNotNull("expression should not be null", e);
assertTrue("Should be an E_Random", e instanceof E_Random);
}
Aggregations