use of org.apache.jena.sparql.expr.E_Random in project jena by apache.
the class SelectClauseTest method testAddStringVar.
@ContractTest
public void testAddStringVar() throws Exception {
SelectClause<?> selectClause = getProducer().newInstance();
AbstractQueryBuilder<?> aqb = selectClause.addVar("rand()", Var.alloc("foo"));
Query query = getQuery(aqb);
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 SelectClauseTest method testAddExprVar.
@ContractTest
public void testAddExprVar() throws Exception {
SelectClause<?> selectClause = getProducer().newInstance();
AbstractQueryBuilder<?> aqb = selectClause.addVar(new E_Random(), Var.alloc("foo"));
Query query = getQuery(aqb);
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 testAddHavingExpr.
@ContractTest
public void testAddHavingExpr() throws ParseException {
SolutionModifierClause<?> solutionModifier = getProducer().newInstance();
AbstractQueryBuilder<?> builder = solutionModifier.addHaving(new E_Random());
assertContainsRegex(HAVING + "rand" + OPEN_PAREN + CLOSE_PAREN, builder.buildString());
solutionModifier.addHaving("?having2");
assertContainsRegex(HAVING + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE + var("having2"), builder.buildString());
}
use of org.apache.jena.sparql.expr.E_Random in project jena by apache.
the class SolutionModifierTest method testAddGroupByVarAndExpr.
@ContractTest
public void testAddGroupByVarAndExpr() {
SolutionModifierClause<?> solutionModifier = getProducer().newInstance();
AbstractQueryBuilder<?> builder = solutionModifier.addGroupBy(Var.alloc("foo"), new E_Random());
assertContainsRegex(GROUP_BY + OPEN_PAREN + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE + "AS" + SPACE + var("foo") + CLOSE_PAREN, builder.buildString());
builder = solutionModifier.addGroupBy("bar");
assertContainsRegex(GROUP_BY + OPEN_PAREN + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE + "AS" + SPACE + var("foo") + 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 testAddOrderByExprAscending.
@ContractTest
public void testAddOrderByExprAscending() {
SolutionModifierClause<?> solutionModifier = getProducer().newInstance();
Expr e = new E_Random();
AbstractQueryBuilder<?> builder = solutionModifier.addOrderBy(e, Order.ASCENDING);
assertContainsRegex(ORDER_BY + "ASC" + OPEN_PAREN + "rand" + OPEN_PAREN + CLOSE_PAREN + CLOSE_PAREN, builder.buildString());
builder = solutionModifier.addOrderBy("bar");
assertContainsRegex(ORDER_BY + "ASC" + OPEN_PAREN + "rand" + OPEN_PAREN + CLOSE_PAREN + CLOSE_PAREN + SPACE + var("bar"), builder.buildString());
}
Aggregations