use of org.apache.jena.sparql.core.TriplePath 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.sparql.core.TriplePath in project jena by apache.
the class WhereHandlerTest method testListInTriple.
@Test
public void testListInTriple() {
handler.addWhere(new TriplePath(new Triple(handler.list("<one>", "?var", "'three'"), ResourceFactory.createResource("foo").asNode(), ResourceFactory.createResource("bar").asNode())));
assertContainsRegex("_:b0" + SPACE + uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#first") + SPACE + uri("one") + SEMI + SPACE + uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest") + SPACE + "_:b1" + DOT + SPACE + "_:b1" + SPACE + uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#first") + SPACE + var("var") + SEMI + SPACE + uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest") + SPACE + "_:b2" + DOT + SPACE + "_:b2" + SPACE + uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#first") + SPACE + quote("three") + SEMI + SPACE + uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest") + SPACE + uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"), query.toString());
assertContainsRegex("_:b0" + SPACE + uri("foo") + SPACE + uri("bar"), query.toString());
}
use of org.apache.jena.sparql.core.TriplePath in project jena by apache.
the class WhereHandlerTest method testAddWhereObjectsWithPath.
@Test
public void testAddWhereObjectsWithPath() {
PrefixMapping pmap = new PrefixMappingImpl();
pmap.setNsPrefix("ts", "urn:test:");
Path path = PathParser.parse("ts:two/ts:dos", pmap);
handler.addWhere(new TriplePath(NodeFactory.createURI("one"), path, ResourceFactory.createLangLiteral("three", "en-US").asNode()));
assertContainsRegex(WHERE + OPEN_CURLY + uri("one") + SPACE + uri("urn:test:two") + "/" + uri("urn:test:dos") + SPACE + quote("three") + "@en-US" + OPT_SPACE + CLOSE_CURLY, query.toString());
}
use of org.apache.jena.sparql.core.TriplePath in project jena by apache.
the class WhereHandlerTest method testAddOptionalObjectsWithPath.
@Test
public void testAddOptionalObjectsWithPath() {
PrefixMapping pmap = new PrefixMappingImpl();
pmap.setNsPrefix("ts", "urn:test:");
Path path = PathParser.parse("ts:two/ts:dos", pmap);
handler.addOptional(new TriplePath(NodeFactory.createURI("one"), path, ResourceFactory.createLangLiteral("three", "en-US").asNode()));
assertContainsRegex(WHERE + OPEN_CURLY + "OPTIONAL" + SPACE + OPEN_CURLY + uri("one") + SPACE + uri("urn:test:two") + "/" + uri("urn:test:dos") + SPACE + quote("three") + "@en-US" + OPT_SPACE + CLOSE_CURLY + CLOSE_CURLY, query.toString());
}
use of org.apache.jena.sparql.core.TriplePath in project jena by apache.
the class WhereHandlerTest method addWhereTriple.
@Test
public void addWhereTriple() {
handler.addWhere(new TriplePath(new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createURI("three"))));
assertContainsRegex(WHERE + OPEN_CURLY + uri("one") + SPACE + uri("two") + SPACE + uri("three") + OPT_SPACE + CLOSE_CURLY, query.toString());
}
Aggregations