Search in sources :

Example 6 with ExprAggregator

use of org.apache.jena.sparql.expr.ExprAggregator 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

ExprAggregator (org.apache.jena.sparql.expr.ExprAggregator)6 Var (org.apache.jena.sparql.core.Var)3 Expr (org.apache.jena.sparql.expr.Expr)3 ArrayList (java.util.ArrayList)2 VarExprList (org.apache.jena.sparql.core.VarExprList)2 Test (org.junit.Test)2 IteratorDelayedInitialization (org.apache.jena.atlas.iterator.IteratorDelayedInitialization)1 Pair (org.apache.jena.atlas.lib.Pair)1 Node (org.apache.jena.graph.Node)1 Binding (org.apache.jena.sparql.engine.binding.Binding)1 BindingMap (org.apache.jena.sparql.engine.binding.BindingMap)1 ExprVar (org.apache.jena.sparql.expr.ExprVar)1 NodeValue (org.apache.jena.sparql.expr.NodeValue)1 Accumulator (org.apache.jena.sparql.expr.aggregate.Accumulator)1 AggCount (org.apache.jena.sparql.expr.aggregate.AggCount)1 AggSum (org.apache.jena.sparql.expr.aggregate.AggSum)1