Search in sources :

Example 56 with ContractTest

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

the class WhereClauseTest method testAddMinus.

@ContractTest
public void testAddMinus() {
    SelectBuilder sb = new SelectBuilder();
    sb.addPrefix("pfx", "uri").addVar("?x").addWhere("<one>", "<two>", "three");
    WhereClause<?> whereClause = getProducer().newInstance();
    AbstractQueryBuilder<?> builder = whereClause.addMinus(sb);
    String str = builder.buildString();
    assertContainsRegex(MINUS + OPEN_CURLY + uri("one") + SPACE + uri("two") + SPACE + quote("three") + CLOSE_CURLY, str);
}
Also used : SelectBuilder(org.apache.jena.arq.querybuilder.SelectBuilder) ContractTest(org.xenei.junit.contract.ContractTest)

Example 57 with ContractTest

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

the class GraphMem_CS method testHasStatistics.

@ContractTest
public void testHasStatistics() {
    GraphStatisticsHandler h = graphProducer.newInstance().getStatisticsHandler();
    assertNotNull(h);
}
Also used : GraphStatisticsHandler(org.apache.jena.graph.GraphStatisticsHandler) ContractTest(org.xenei.junit.contract.ContractTest)

Example 58 with ContractTest

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

the class GraphMem_CS method testUnnecessaryMatches.

@ContractTest
public void testUnnecessaryMatches() {
    Node special = new Node_URI("eg:foo") {

        @Override
        public boolean matches(Node s) {
            fail("Matched called superfluously.");
            return true;
        }
    };
    Graph g = graphWith(graphProducer.newInstance(), "x p y");
    g.add(new Triple(special, special, special));
    exhaust(g.find(special, Node.ANY, Node.ANY));
    exhaust(g.find(Node.ANY, special, Node.ANY));
    exhaust(g.find(Node.ANY, Node.ANY, special));
}
Also used : Node_URI(org.apache.jena.graph.Node_URI) Triple(org.apache.jena.graph.Triple) Graph(org.apache.jena.graph.Graph) Node(org.apache.jena.graph.Node) ContractTest(org.xenei.junit.contract.ContractTest)

Example 59 with ContractTest

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

the class SolutionModifierTest method testSetVarsGroupBy.

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

Example 60 with ContractTest

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