use of org.apache.jena.query.Query in project jena by apache.
the class PrologHandlerTest method testAddPrefixHandler.
@Test
public void testAddPrefixHandler() {
PrologHandler handler2 = new PrologHandler(new Query());
handler2.addPrefix("pfx", "uri");
handler.addAll(handler2);
String[] lst = byLine(query.toString());
assertContainsRegex("PREFIX\\s+pfx:\\s+\\<uri\\>", lst);
}
use of org.apache.jena.query.Query in project jena by apache.
the class SelectHandlerTest method setup.
@Before
public void setup() {
query = new Query();
AggregationHandler aggHandler = new AggregationHandler(query);
handler = new SelectHandler(aggHandler);
}
use of org.apache.jena.query.Query in project jena by apache.
the class SolutionModifierHandlerTest method testAddAll.
@Test
public void testAddAll() throws ParseException {
SolutionModifierHandler solutionModifier2 = new SolutionModifierHandler(new Query());
solutionModifier2.addOrderBy(Var.alloc("orderBy"));
solutionModifier2.addGroupBy(Var.alloc("groupBy"));
solutionModifier2.addHaving("?having<10");
solutionModifier2.setLimit(500);
solutionModifier2.setOffset(200);
solutionModifier.addAll(solutionModifier2);
String[] s = byLine(query.toString());
assertContainsRegex(GROUP_BY + var("groupBy"), s);
assertContainsRegex(HAVING + OPEN_PAREN + var("having") + OPT_SPACE + LT + OPT_SPACE + "10" + CLOSE_PAREN, s);
assertContainsRegex(ORDER_BY + var("orderBy"), s);
assertContainsRegex(LIMIT + "500", s);
assertContainsRegex(OFFSET + "200", s);
}
use of org.apache.jena.query.Query in project jena by apache.
the class SolutionModifierHandlerTest method setup.
@Before
public void setup() {
query = new Query();
solutionModifier = new SolutionModifierHandler(query);
}
use of org.apache.jena.query.Query in project jena by apache.
the class WhereHandlerTest method testAddOptionalWhereHandler.
@Test
public void testAddOptionalWhereHandler() throws ParseException {
WhereHandler pattern = new WhereHandler(new Query());
Var s = Var.alloc("s");
Node q = NodeFactory.createURI("urn:q");
Node v = NodeFactory.createURI("urn:v");
Var x = Var.alloc("x");
Node n123 = NodeFactory.createLiteral(LiteralLabelFactory.createTypedLiteral(123));
pattern.addWhere(new TriplePath(new Triple(s, q, n123)));
pattern.addWhere(new TriplePath(new Triple(s, v, x)));
pattern.addFilter("?x>56");
handler.addOptional(pattern);
Query expected = QueryFactory.create("SELECT * WHERE { OPTIONAL { ?s <urn:q> '123'^^<http://www.w3.org/2001/XMLSchema#int> . ?s <urn:v> ?x . FILTER(?x>56) }}");
Assert.assertEquals(expected.getQueryPattern(), query.getQueryPattern());
}
Aggregations