use of org.apache.jena.sparql.expr.E_Random in project jena by apache.
the class SolutionModifierHandlerTest method testAddGroupByExpr.
@Test
public void testAddGroupByExpr() {
solutionModifier.addGroupBy(new E_Random());
String[] s = byLine(query.toString());
assertContainsRegex(GROUP_BY + "rand" + OPEN_PAREN + CLOSE_PAREN, s);
solutionModifier.addGroupBy(Var.alloc("groupBy2"));
s = byLine(query.toString());
assertContainsRegex(GROUP_BY + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE + var("groupBy2"), s);
}
use of org.apache.jena.sparql.expr.E_Random 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);
assertContainsRegex(OPEN_CURLY + BIND + OPEN_PAREN + "rand\\(\\)" + SPACE + "AS" + SPACE + var("foo") + CLOSE_PAREN + CLOSE_CURLY, query.toString());
}
use of org.apache.jena.sparql.expr.E_Random 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);
}
use of org.apache.jena.sparql.expr.E_Random in project jena by apache.
the class SolutionModifierTest method testAddOrderByExprDescending.
@ContractTest
public void testAddOrderByExprDescending() {
SolutionModifierClause<?> solutionModifier = getProducer().newInstance();
Expr e = new E_Random();
AbstractQueryBuilder<?> builder = solutionModifier.addOrderBy(e, Order.DESCENDING);
assertContainsRegex(ORDER_BY + "DESC" + OPEN_PAREN + "rand" + OPEN_PAREN + CLOSE_PAREN + CLOSE_PAREN, builder.buildString());
builder = solutionModifier.addOrderBy("bar");
assertContainsRegex(ORDER_BY + "DESC" + OPEN_PAREN + "rand" + OPEN_PAREN + CLOSE_PAREN + CLOSE_PAREN + SPACE + var("bar"), builder.buildString());
}
use of org.apache.jena.sparql.expr.E_Random in project jena by apache.
the class SolutionModifierTest method testAddGroupByExpr.
@ContractTest
public void testAddGroupByExpr() {
SolutionModifierClause<?> solutionModifier = getProducer().newInstance();
AbstractQueryBuilder<?> builder = solutionModifier.addGroupBy(new E_Random());
assertContainsRegex(GROUP_BY + "rand" + OPEN_PAREN + CLOSE_PAREN, builder.buildString());
builder = solutionModifier.addGroupBy("bar");
assertContainsRegex(GROUP_BY + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE + var("bar"), builder.buildString());
}
Aggregations