use of org.apache.jena.arq.querybuilder.handlers.WhereHandler in project jena by apache.
the class WhereHandlerTest method testAddAllPopulatedEmpty.
@Test
public void testAddAllPopulatedEmpty() {
handler.addWhere(new TriplePath(Triple.ANY));
Query query2 = new Query();
WhereHandler handler2 = new WhereHandler(query2);
handler2.addWhere(new TriplePath(new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createLiteral("three"))));
handler.addAll(handler2);
assertContainsRegex(WHERE + OPEN_CURLY + "ANY" + SPACE + "ANY" + SPACE + "ANY" + DOT + SPACE + uri("one") + SPACE + uri("two") + SPACE + quote("three") + OPT_SPACE + CLOSE_CURLY, query.toString());
}
use of org.apache.jena.arq.querybuilder.handlers.WhereHandler in project jena by apache.
the class WhereHandlerTest method testAddAllOnEmpty.
@Test
public void testAddAllOnEmpty() {
Query query2 = new Query();
WhereHandler handler2 = new WhereHandler(query2);
handler2.addWhere(new TriplePath(new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createLiteral("three"))));
handler.addAll(handler2);
assertContainsRegex(WHERE + OPEN_CURLY + uri("one") + SPACE + uri("two") + SPACE + quote("three") + OPT_SPACE + CLOSE_CURLY, query.toString());
}
use of org.apache.jena.arq.querybuilder.handlers.WhereHandler in project jena by apache.
the class WhereHandlerTest method addGraph.
@Test
public void addGraph() {
WhereHandler handler2 = new WhereHandler(new Query());
handler2.addWhere(new TriplePath(new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createURI("three"))));
handler.addGraph(NodeFactory.createURI("graph"), handler2);
assertContainsRegex(WHERE + OPEN_CURLY + "GRAPH" + SPACE + uri("graph") + SPACE + OPEN_CURLY + uri("one") + SPACE + uri("two") + SPACE + uri("three") + OPT_SPACE + CLOSE_CURLY + CLOSE_CURLY, query.toString());
}
use of org.apache.jena.arq.querybuilder.handlers.WhereHandler in project jena by apache.
the class WhereHandlerTest method setup.
@Before
public void setup() {
query = new Query();
handler = new WhereHandler(query);
}
use of org.apache.jena.arq.querybuilder.handlers.WhereHandler 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