Search in sources :

Example 46 with ContractTest

use of org.xenei.junit.contract.ContractTest 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());
}
Also used : E_Random(org.apache.jena.sparql.expr.E_Random) ContractTest(org.xenei.junit.contract.ContractTest)

Example 47 with ContractTest

use of org.xenei.junit.contract.ContractTest 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());
}
Also used : E_Random(org.apache.jena.sparql.expr.E_Random) ContractTest(org.xenei.junit.contract.ContractTest)

Example 48 with ContractTest

use of org.xenei.junit.contract.ContractTest 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());
}
Also used : Expr(org.apache.jena.sparql.expr.Expr) E_Random(org.apache.jena.sparql.expr.E_Random) ContractTest(org.xenei.junit.contract.ContractTest)

Example 49 with ContractTest

use of org.xenei.junit.contract.ContractTest in project jena by apache.

the class SolutionModifierTest method testAddOrderByExpr.

@ContractTest
public void testAddOrderByExpr() {
    SolutionModifierClause<?> solutionModifier = getProducer().newInstance();
    Expr e = new E_Random();
    AbstractQueryBuilder<?> builder = solutionModifier.addOrderBy(e);
    assertContainsRegex(ORDER_BY + "rand" + OPEN_PAREN + CLOSE_PAREN, builder.buildString());
    builder = solutionModifier.addOrderBy("bar");
    assertContainsRegex(ORDER_BY + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE + var("bar"), builder.buildString());
}
Also used : Expr(org.apache.jena.sparql.expr.Expr) E_Random(org.apache.jena.sparql.expr.E_Random) ContractTest(org.xenei.junit.contract.ContractTest)

Example 50 with ContractTest

use of org.xenei.junit.contract.ContractTest in project jena by apache.

the class SolutionModifierTest method testSetVarsHaving.

@ContractTest
public void testSetVarsHaving() throws ParseException {
    Var v = Var.alloc("v");
    SolutionModifierClause<?> solutionModifier = getProducer().newInstance();
    AbstractQueryBuilder<?> builder = solutionModifier.addHaving("?v");
    String[] s = byLine(builder);
    assertContainsRegex(HAVING + var("v"), s);
    builder.setVar(v, Var.alloc("v2"));
    s = byLine(builder);
    assertContainsRegex(HAVING + var("v2"), s);
}
Also used : Var(org.apache.jena.sparql.core.Var) ContractTest(org.xenei.junit.contract.ContractTest)

Aggregations

ContractTest (org.xenei.junit.contract.ContractTest)102 GraphHelper.memGraph (org.apache.jena.testing_framework.GraphHelper.memGraph)51 Graph (org.apache.jena.graph.Graph)16 Var (org.apache.jena.sparql.core.Var)13 Query (org.apache.jena.query.Query)9 E_Random (org.apache.jena.sparql.expr.E_Random)9 SelectBuilder (org.apache.jena.arq.querybuilder.SelectBuilder)6 DeleteDeniedException (org.apache.jena.shared.DeleteDeniedException)6 VarExprList (org.apache.jena.sparql.core.VarExprList)6 MalformedURLException (java.net.MalformedURLException)5 URISyntaxException (java.net.URISyntaxException)5 ClosedException (org.apache.jena.shared.ClosedException)5 Expr (org.apache.jena.sparql.expr.Expr)5 Triple (org.apache.jena.graph.Triple)4 PrefixMapping (org.apache.jena.shared.PrefixMapping)3 TriplePath (org.apache.jena.sparql.core.TriplePath)3 Node (org.apache.jena.graph.Node)2 TransactionHandler (org.apache.jena.graph.TransactionHandler)2 Intersection (org.apache.jena.graph.compose.Intersection)2 GraphWithPerform (org.apache.jena.graph.impl.GraphWithPerform)2