use of org.apache.jena.sparql.syntax.ElementData in project jena by apache.
the class WhereClauseTest method testAddWhereValueVars_InSubQuery.
@ContractTest
public void testAddWhereValueVars_InSubQuery() {
final Var v = Var.alloc("v");
Map<Object, List<?>> map = new HashMap<Object, List<?>>();
map.put(Var.alloc("v"), Arrays.asList("<one>", "<two>"));
map.put("?x", Arrays.asList("three", "four"));
WhereClause<?> whereClause = getProducer().newInstance();
WhereClause<?> whereClause2 = getProducer().newInstance();
AbstractQueryBuilder<?> builder = whereClause.addWhereValueVars(map);
builder = whereClause2.addSubQuery(builder);
Query query = builder.build();
Var x = Var.alloc("x");
ElementData edat = new ElementData();
edat.add(x);
edat.add(v);
setupBindings(edat, x, v);
WhereValidator visitor = new WhereValidator(edat);
query.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.sparql.syntax.ElementData in project jena by apache.
the class WhereClauseTest method testAddWhereValueRow_collection_Node_Variable.
@ContractTest
public void testAddWhereValueRow_collection_Node_Variable() {
WhereClause<?> whereClause = getProducer().newInstance();
whereClause = (WhereClause<?>) whereClause.addWhereValueVar(NodeFactory.createVariable("v"));
whereClause = (WhereClause<?>) whereClause.addWhereValueVar(NodeFactory.createVariable("x"));
whereClause = (WhereClause<?>) whereClause.addWhereValueRow(Arrays.asList("<one>", "three"));
AbstractQueryBuilder<?> builder = whereClause.addWhereValueRow(Arrays.asList("<two>", "four"));
Query query = builder.build();
ElementData edat = new ElementData();
final Var v = Var.alloc("v");
final Var x = Var.alloc("x");
edat.add(v);
edat.add(x);
setupBindings(edat, x, v);
WhereValidator visitor = new WhereValidator(edat);
query.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.sparql.syntax.ElementData in project jena by apache.
the class WhereHandlerTest method testAddValueVars.
@Test
public void testAddValueVars() {
final Var v = Var.alloc("v");
Map<Object, List<?>> map = new LinkedHashMap<Object, List<?>>();
map.put(Var.alloc("v"), Arrays.asList("<one>", "<two>"));
map.put("?x", Arrays.asList("three", "four"));
handler.addValueVars(query.getPrefixMapping(), map);
handler.build();
Var x = Var.alloc("x");
ElementData edat = new ElementData();
edat.add(v);
edat.add(x);
setupBindings(edat, x, v);
WhereValidator visitor = new WhereValidator(edat);
query.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.sparql.syntax.ElementData in project jena by apache.
the class WhereHandlerTest method testAddValueRow_pfx_array.
@Test
public void testAddValueRow_pfx_array() {
final Var v = Var.alloc("v");
final Var x = Var.alloc("x");
handler.addValueVar(query.getPrefixMapping(), v);
handler.addValueVar(query.getPrefixMapping(), x);
handler.addValueRow(query.getPrefixMapping(), "<one>", "three");
handler.addValueRow(query.getPrefixMapping(), "<two>", "four");
handler.build();
ElementData edat = new ElementData();
edat.add(v);
edat.add(x);
setupBindings(edat, x, v);
WhereValidator visitor = new WhereValidator(edat);
query.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.sparql.syntax.ElementData in project jena by apache.
the class WhereHandlerTest method testAddValueVar_pfx_obj_array.
@Test
public void testAddValueVar_pfx_obj_array() {
Node two = NodeFactory.createURI("two");
handler.addValueVar(query.getPrefixMapping(), "?v", "<one>", two);
handler.build();
Var v = Var.alloc("v");
ElementData edat = new ElementData();
edat.add(v);
Binding binding1 = BindingFactory.binding(v, NodeFactory.createURI("one"));
edat.add(binding1);
Binding binding2 = BindingFactory.binding(v, two);
edat.add(binding2);
WhereValidator visitor = new WhereValidator(edat);
query.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
Aggregations