Search in sources :

Example 6 with TriplePath

use of org.apache.jena.sparql.core.TriplePath in project jena by apache.

the class WhereHandlerTest method testAddWhereObjects.

@Test
public void testAddWhereObjects() {
    handler.addWhere(new TriplePath(new Triple(NodeFactory.createURI("one"), ResourceFactory.createResource("two").asNode(), ResourceFactory.createLangLiteral("three", "en-US").asNode())));
    assertContainsRegex(WHERE + OPEN_CURLY + uri("one") + SPACE + uri("two") + SPACE + quote("three") + "@en-US" + OPT_SPACE + CLOSE_CURLY, query.toString());
}
Also used : Triple(org.apache.jena.graph.Triple) TriplePath(org.apache.jena.sparql.core.TriplePath) Test(org.junit.Test)

Example 7 with TriplePath

use of org.apache.jena.sparql.core.TriplePath 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());
}
Also used : Triple(org.apache.jena.graph.Triple) Query(org.apache.jena.query.Query) WhereHandler(org.apache.jena.arq.querybuilder.handlers.WhereHandler) TriplePath(org.apache.jena.sparql.core.TriplePath) Test(org.junit.Test)

Example 8 with TriplePath

use of org.apache.jena.sparql.core.TriplePath 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());
}
Also used : Triple(org.apache.jena.graph.Triple) Query(org.apache.jena.query.Query) WhereHandler(org.apache.jena.arq.querybuilder.handlers.WhereHandler) TriplePath(org.apache.jena.sparql.core.TriplePath) Test(org.junit.Test)

Example 9 with TriplePath

use of org.apache.jena.sparql.core.TriplePath in project jena by apache.

the class WhereHandlerTest method testAddOptionalAnonymous.

@Test
public void testAddOptionalAnonymous() {
    handler.addOptional(new TriplePath(new Triple(Node.ANY, RDF.first.asNode(), Node.ANY)));
    assertContainsRegex(WHERE + OPEN_CURLY + "OPTIONAL" + SPACE + OPEN_CURLY + "ANY" + SPACE + uri("http://www\\.w3\\.org/1999/02/22-rdf-syntax-ns#first") + SPACE + "ANY" + OPT_SPACE + CLOSE_CURLY + CLOSE_CURLY, query.toString());
}
Also used : Triple(org.apache.jena.graph.Triple) TriplePath(org.apache.jena.sparql.core.TriplePath) Test(org.junit.Test)

Example 10 with TriplePath

use of org.apache.jena.sparql.core.TriplePath in project jena by apache.

the class WhereHandlerTest method testAddWhereStrings.

@Test
public void testAddWhereStrings() {
    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());
}
Also used : Triple(org.apache.jena.graph.Triple) TriplePath(org.apache.jena.sparql.core.TriplePath) Test(org.junit.Test)

Aggregations

TriplePath (org.apache.jena.sparql.core.TriplePath)33 Triple (org.apache.jena.graph.Triple)22 Test (org.junit.Test)18 Node (org.apache.jena.graph.Node)10 WhereHandler (org.apache.jena.arq.querybuilder.handlers.WhereHandler)4 Query (org.apache.jena.query.Query)4 Path (org.apache.jena.sparql.path.Path)4 SelectBuilder (org.apache.jena.arq.querybuilder.SelectBuilder)3 PrefixMapping (org.apache.jena.shared.PrefixMapping)3 PrefixMappingImpl (org.apache.jena.shared.impl.PrefixMappingImpl)3 Var (org.apache.jena.sparql.core.Var)3 HashMap (java.util.HashMap)2 Op (org.apache.jena.sparql.algebra.Op)2 OpPath (org.apache.jena.sparql.algebra.op.OpPath)2 BasicPattern (org.apache.jena.sparql.core.BasicPattern)2 ContractTest (org.xenei.junit.contract.ContractTest)2 FrontsTriple (org.apache.jena.graph.FrontsTriple)1 PathBlock (org.apache.jena.sparql.core.PathBlock)1 ElementPathBlock (org.apache.jena.sparql.syntax.ElementPathBlock)1