use of org.apache.jena.sparql.core.Var in project jena by apache.
the class TestVarFinder method check.
private static void check(String[] varsExpected, Set<Var> varsFound) {
Var[] vars = new Var[varsExpected.length];
for (int i = 0; i < varsExpected.length; i++) {
Var v = Var.alloc(varsExpected[i]);
vars[i] = v;
}
List<Var> varList = Arrays.asList(vars);
HashSet<Var> varSet = new HashSet<>();
varSet.addAll(varList);
assertEquals(varSet, varsFound);
}
use of org.apache.jena.sparql.core.Var in project jena by apache.
the class TestOpVars method check.
private static void check(String[] varsExpected, Collection<Var> varsFound) {
Var[] vars = new Var[varsExpected.length];
for (int i = 0; i < varsExpected.length; i++) {
Var v = Var.alloc(varsExpected[i]);
vars[i] = v;
}
List<Var> varList = Arrays.asList(vars);
HashSet<Var> varSet = new HashSet<>();
varSet.addAll(varList);
assertEquals(varSet, varsFound);
}
use of org.apache.jena.sparql.core.Var in project jena by apache.
the class TestSyntaxTransform method testUpdate.
private void testUpdate(String input, String output, String varStr, String valStr) {
UpdateRequest req1 = UpdateFactory.create(PREFIX + input);
UpdateRequest reqExpected = UpdateFactory.create(PREFIX + output);
Map<Var, Node> map = new HashMap<>();
map.put(Var.alloc(varStr), SSE.parseNode(valStr));
UpdateRequest reqTrans = UpdateTransformOps.transform(req1, map);
// Crude.
String x1 = reqExpected.toString().replaceAll("[ \n\t]", "");
String x2 = reqTrans.toString().replaceAll("[ \n\t]", "");
//assertEquals(reqExpected, reqTrans) ;
assertEquals(x1, x2);
}
use of org.apache.jena.sparql.core.Var 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);
assertEquals(qExpected, qTrans);
}
use of org.apache.jena.sparql.core.Var in project jena by apache.
the class TestQuery method query_recursive_01.
@Test
public void query_recursive_01() {
String query = "SELECT * WHERE { SERVICE <" + serviceQuery() + "> { ?s ?p ?o . BIND(?o AS ?x) } }";
try (QueryExecution qExec = QueryExecutionFactory.sparqlService(serviceQuery(), query)) {
ResultSet rs = qExec.execSelect();
Var x = Var.alloc("x");
while (rs.hasNext()) {
Binding b = rs.nextBinding();
Assert.assertNotNull(b.get(x));
}
}
}
Aggregations