Search in sources :

Example 91 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class ConstructHandlerTest method setup.

@Before
public void setup() {
    query = new Query();
    handler = new ConstructHandler(query);
}
Also used : Query(org.apache.jena.query.Query) Before(org.junit.Before)

Example 92 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class ExprFactoryTest method existsTest.

// expr op
@Test
public void existsTest() {
    WhereHandler handler = new WhereHandler(new Query());
    WhereClause<?> whereClause = mock(WhereClause.class);
    when(whereClause.getWhereHandler()).thenReturn(handler);
    Expr e = factory.exists(whereClause);
    assertTrue(e instanceof E_Exists);
}
Also used : Query(org.apache.jena.query.Query) WhereHandler(org.apache.jena.arq.querybuilder.handlers.WhereHandler) Test(org.junit.Test)

Example 93 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class ExprFactoryTest method notexistsTest.

@Test
public void notexistsTest() {
    WhereHandler handler = new WhereHandler(new Query());
    WhereClause<?> whereClause = mock(WhereClause.class);
    when(whereClause.getWhereHandler()).thenReturn(handler);
    Expr e = factory.notexists(whereClause);
    assertTrue(e instanceof E_NotExists);
}
Also used : Query(org.apache.jena.query.Query) WhereHandler(org.apache.jena.arq.querybuilder.handlers.WhereHandler) Test(org.junit.Test)

Example 94 with Query

use of org.apache.jena.query.Query 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 95 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class SelectBuilderTest method setDistinctTest.

@Test
public void setDistinctTest() throws Exception {
    Query query = builder.query;
    assertFalse(query.isDistinct());
    assertFalse(query.isReduced());
    query = builder.setDistinct(true).query;
    assertTrue(query.isDistinct());
    assertFalse(query.isReduced());
    query = builder.setReduced(false).query;
    assertTrue(query.isDistinct());
    assertFalse(query.isReduced());
    query = builder.setReduced(true).query;
    assertFalse(query.isDistinct());
    assertTrue(query.isReduced());
    query = builder.setDistinct(true).query;
    assertTrue(query.isDistinct());
    assertFalse(query.isReduced());
    query = builder.setDistinct(false).query;
    assertFalse(query.isDistinct());
    assertFalse(query.isReduced());
}
Also used : Query(org.apache.jena.query.Query) Test(org.junit.Test) AbstractRegexpBasedTest(org.apache.jena.arq.AbstractRegexpBasedTest)

Aggregations

Query (org.apache.jena.query.Query)102 Test (org.junit.Test)22 Op (org.apache.jena.sparql.algebra.Op)17 Var (org.apache.jena.sparql.core.Var)11 HashMap (java.util.HashMap)9 QueryExecution (org.apache.jena.query.QueryExecution)9 ContractTest (org.xenei.junit.contract.ContractTest)9 Node (org.apache.jena.graph.Node)8 WhereHandler (org.apache.jena.arq.querybuilder.handlers.WhereHandler)7 ResultSet (org.apache.jena.query.ResultSet)7 VarExprList (org.apache.jena.sparql.core.VarExprList)7 Element (org.apache.jena.sparql.syntax.Element)7 Triple (org.apache.jena.graph.Triple)6 Before (org.junit.Before)6 Map (java.util.Map)5 QuerySolution (org.apache.jena.query.QuerySolution)5 QueryEngineHTTP (org.apache.jena.sparql.engine.http.QueryEngineHTTP)5 Context (org.apache.jena.sparql.util.Context)5 StringReader (java.io.StringReader)4 TriplePath (org.apache.jena.sparql.core.TriplePath)4