use of org.apache.jena.query.Query in project jena by apache.
the class TestQueryExecDataset method queryExec_substitution_01.
// Most QueryExec testing gets tested via QueryExecution usage
@Test
public void queryExec_substitution_01() {
QueryExec queryExec = QueryExec.dataset(DatasetGraphFactory.empty()).query("SELECT * { ?s ?p ?o }").substitution(Var.alloc("s"), SSE.parseNode(":x")).build();
Query query = queryExec.getQuery();
String s = query.toString();
assertTrue(s.contains("http://example/x"));
}
use of org.apache.jena.query.Query in project jena by apache.
the class TestSerialization method testOpToSyntax.
private void testOpToSyntax(String opStr, String queryString) {
Op op = SSE.parseOp(opStr);
Query queryConverted = OpAsQuery.asQuery(op);
Query queryExpected = QueryFactory.create(queryString, queryConverted.getSyntax());
// if ( ! queryExpected.equals(queryConverted) )
// {
// System.err.println("Query Expected: "+queryExpected.getSyntax()) ;
// System.err.println(queryExpected) ;
//
// System.err.println("Query Converted: "+queryConverted.getSyntax()) ;
// System.err.println(queryConverted) ;
// System.err.println() ;
// }
assertEquals(queryExpected, queryConverted);
}
use of org.apache.jena.query.Query in project jena by apache.
the class TestSyntaxTransform method testQueryModel.
private void testQueryModel(String input, String output, String varStr, String valStr) {
Query q1 = QueryFactory.create(PREFIX + input);
Query qExpected = QueryFactory.create(PREFIX + output);
Map<String, RDFNode> map = Map.of(varStr, fromString(valStr));
Query qTrans = QueryTransformOps.transformQuery(q1, map);
assertEquals(qExpected, qTrans);
}
use of org.apache.jena.query.Query in project jena by apache.
the class TestSyntaxTransform method testQuery.
private void testQuery(String input, String output, String varStr, String valStr) {
Query q1 = QueryFactory.create(PREFIX + input);
Query qExpected = QueryFactory.create(PREFIX + output);
Map<Var, Node> map = new HashMap<>();
map.put(Var.alloc(varStr), SSE.parseNode(valStr));
Query qTrans = QueryTransformOps.transform(q1, map);
if (!qExpected.equals(qTrans)) {
System.out.println(qExpected.getProject());
System.out.print(qExpected);
System.out.println(qTrans.getProject());
System.out.print(qTrans);
}
assertEquals(qExpected, qTrans);
}
use of org.apache.jena.query.Query in project jena by apache.
the class TestQueryOps method testShallowCopy.
private static void testShallowCopy(String queryString) {
Query q1 = QueryFactory.create(queryString);
Query q2 = QueryTransformOps.shallowCopy(q1);
assertEquals(q1, q2);
}
Aggregations