use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereClauseTest method testAddOptionalTriple.
@ContractTest
public void testAddOptionalTriple() {
WhereClause<?> whereClause = getProducer().newInstance();
AbstractQueryBuilder<?> builder = whereClause.addOptional(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createURI("three"));
ElementPathBlock epb = new ElementPathBlock();
ElementOptional optional = new ElementOptional(epb);
Triple t = new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createURI("three"));
epb.addTriple(t);
WhereValidator visitor = new WhereValidator(optional);
builder.build().getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereClauseTest method testAddMinus.
@ContractTest
public void testAddMinus() {
SelectBuilder sb = new SelectBuilder();
sb.addPrefix("pfx", "uri").addVar("?x").addWhere("<one>", "<two>", "three");
WhereClause<?> whereClause = getProducer().newInstance();
AbstractQueryBuilder<?> builder = whereClause.addMinus(sb);
Query query = builder.build();
ElementPathBlock epb = new ElementPathBlock();
ElementMinus minus = new ElementMinus(epb);
epb.addTriplePath(new TriplePath(new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createLiteral("three"))));
WhereValidator visitor = new WhereValidator(minus);
query.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereClauseTest method testAddOptionalString.
@ContractTest
public void testAddOptionalString() {
WhereClause<?> whereClause = getProducer().newInstance();
AbstractQueryBuilder<?> builder = whereClause.addOptional("<one>", "<two>", "three");
ElementPathBlock epb = new ElementPathBlock();
ElementOptional optional = new ElementOptional(epb);
Triple t = new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createLiteral("three"));
epb.addTriple(t);
WhereValidator visitor = new WhereValidator(optional);
builder.build().getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereClauseTest method testAddWhereValueRow_collection.
@ContractTest
public void testAddWhereValueRow_collection() {
final Var v = Var.alloc("v");
final Var x = Var.alloc("x");
WhereClause<?> whereClause = getProducer().newInstance();
whereClause = (WhereClause<?>) whereClause.addWhereValueVar(v);
whereClause = (WhereClause<?>) whereClause.addWhereValueVar(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();
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.arq.querybuilder.WhereValidator in project jena by apache.
the class WhereClauseTest method testAddWhereStrings.
@ContractTest
public void testAddWhereStrings() {
WhereClause<?> whereClause = getProducer().newInstance();
AbstractQueryBuilder<?> builder = whereClause.addWhere("<one>", "<two>", "three");
ElementPathBlock epb = new ElementPathBlock();
Triple t = new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createLiteral("three"));
epb.addTriple(t);
WhereValidator visitor = new WhereValidator(epb);
builder.build().getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
Aggregations