Search in sources :

Example 1 with AggSum

use of org.apache.jena.sparql.expr.aggregate.AggSum 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);
}
Also used : Expr(org.apache.jena.sparql.expr.Expr) Var(org.apache.jena.sparql.core.Var) ExprAggregator(org.apache.jena.sparql.expr.ExprAggregator) AggSum(org.apache.jena.sparql.expr.aggregate.AggSum) VarExprList(org.apache.jena.sparql.core.VarExprList) Test(org.junit.Test)

Aggregations

Var (org.apache.jena.sparql.core.Var)1 VarExprList (org.apache.jena.sparql.core.VarExprList)1 Expr (org.apache.jena.sparql.expr.Expr)1 ExprAggregator (org.apache.jena.sparql.expr.ExprAggregator)1 AggSum (org.apache.jena.sparql.expr.aggregate.AggSum)1 Test (org.junit.Test)1