use of org.xenei.junit.contract.ContractTest 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.xenei.junit.contract.ContractTest in project jena by apache.
the class SelectClauseTest method testAddVarAsterisk.
@ContractTest
public void testAddVarAsterisk() throws Exception {
SelectClause<?> selectClause = getProducer().newInstance();
selectClause.addVar("*");
Query query = getQuery(selectClause.addVar("*"));
VarExprList expr = query.getProject();
assertEquals(0, expr.size());
assertTrue(query.isQueryResultStar());
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class SelectClauseTest method testAddVarString.
@ContractTest
public void testAddVarString() throws Exception {
Var v = Var.alloc("one");
SelectClause<?> selectClause = getProducer().newInstance();
selectClause.addVar("one");
Query query = getQuery(selectClause.addVar("one"));
VarExprList expr = query.getProject();
assertEquals(1, expr.size());
assertTrue(expr.contains(v));
}
use of org.xenei.junit.contract.ContractTest 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.xenei.junit.contract.ContractTest in project jena by apache.
the class SolutionModifierTest method testSetVarsOrderBy.
@ContractTest
public void testSetVarsOrderBy() {
Var v = Var.alloc("v");
SolutionModifierClause<?> solutionModifier = getProducer().newInstance();
AbstractQueryBuilder<?> builder = solutionModifier.addOrderBy("?v");
String[] s = byLine(builder);
assertContainsRegex(ORDER_BY + var("v"), s);
builder.setVar(v, Var.alloc("v2"));
s = byLine(builder);
assertContainsRegex(ORDER_BY + var("v2"), s);
}
Aggregations