Search in sources :

Example 66 with ContractTest

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

the class WhereClauseTest method testSetVarsInOptional.

@ContractTest
public void testSetVarsInOptional() {
    Var v = Var.alloc("v");
    WhereClause<?> whereClause = getProducer().newInstance();
    AbstractQueryBuilder<?> builder = whereClause.addOptional(new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), v));
    assertContainsRegex(WHERE + OPEN_CURLY + "OPTIONAL" + SPACE + OPEN_CURLY + uri("one") + SPACE + uri("two") + SPACE + var("v") + OPT_SPACE + CLOSE_CURLY + CLOSE_CURLY, builder.buildString());
    builder.setVar(v, NodeFactory.createURI("three"));
    assertContainsRegex(WHERE + OPEN_CURLY + "OPTIONAL" + SPACE + OPEN_CURLY + uri("one") + SPACE + uri("two") + SPACE + uri("three") + OPT_SPACE + CLOSE_CURLY + CLOSE_CURLY, builder.buildString());
}
Also used : Triple(org.apache.jena.graph.Triple) Var(org.apache.jena.sparql.core.Var) ContractTest(org.xenei.junit.contract.ContractTest)

Example 67 with ContractTest

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

the class SelectClauseTest method getSelectHandlerTest.

@ContractTest
public void getSelectHandlerTest() {
    SelectClause<?> selectClause = getProducer().newInstance();
    SelectHandler handler = selectClause.getSelectHandler();
    assertNotNull(handler);
}
Also used : SelectHandler(org.apache.jena.arq.querybuilder.handlers.SelectHandler) ContractTest(org.xenei.junit.contract.ContractTest)

Example 68 with ContractTest

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

the class SelectClauseTest method testAddVarVar.

@ContractTest
public void testAddVarVar() throws Exception {
    Var v = Var.alloc("one");
    SelectClause<?> selectClause = getProducer().newInstance();
    Query query = getQuery(selectClause.addVar(v));
    VarExprList expr = query.getProject();
    assertEquals(1, expr.size());
    assertTrue(expr.contains(v));
}
Also used : Query(org.apache.jena.query.Query) Var(org.apache.jena.sparql.core.Var) VarExprList(org.apache.jena.sparql.core.VarExprList) ContractTest(org.xenei.junit.contract.ContractTest)

Example 69 with ContractTest

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

Example 70 with ContractTest

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

the class GraphContractTest method testDelete_Triple_FromNothing.

@ContractTest
public void testDelete_Triple_FromNothing() {
    Graph g = producer.newInstance();
    g.getEventManager().register(GL);
    txnBegin(g);
    g.delete(triple("quint rdf:subject S"));
    txnCommit(g);
    GL.assertContains("delete", g, triple("quint rdf:subject S"));
}
Also used : GraphHelper.memGraph(org.apache.jena.testing_framework.GraphHelper.memGraph) 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