use of org.openrdf.query.algebra.Not in project incubator-rya by apache.
the class AggregationPipelineQueryNodeTest method testExtend.
@Test
public void testExtend() {
final AggregationPipelineQueryNode base = new AggregationPipelineQueryNode(collection, new LinkedList<>(), Sets.newHashSet("x", "y"), Sets.newHashSet("x", "y", "opt"), HashBiMap.create());
// Extend with a mix of variables and constants
List<ExtensionElem> extensionElements = Arrays.asList(new ExtensionElem(new Var("x"), "subject"), new ExtensionElem(new ValueConstant(RDF.TYPE), "predicate"), new ExtensionElem(new Var("y"), "object"));
AggregationPipelineQueryNode node = base.clone();
boolean success = node.extend(extensionElements);
Assert.assertTrue(success);
Assert.assertEquals(1, node.getPipeline().size());
Assert.assertEquals(Sets.newHashSet("x", "y", "subject", "predicate", "object"), node.getAssuredBindingNames());
Assert.assertEquals(Sets.newHashSet("x", "y", "subject", "predicate", "object", "opt"), node.getBindingNames());
// Attempt to extend with an unsupported expression
extensionElements = Arrays.asList(new ExtensionElem(new Var("x"), "subject"), new ExtensionElem(new Not(new ValueConstant(VF.createLiteral(true))), "notTrue"));
node = base.clone();
success = node.extend(extensionElements);
Assert.assertFalse(success);
Assert.assertEquals(base, node);
}
use of org.openrdf.query.algebra.Not in project incubator-rya by apache.
the class SparqlToPipelineTransformVisitorTest method testUnsupportedExtension.
@Test
public void testUnsupportedExtension() throws Exception {
StatementPattern sp = new StatementPattern(new Var("x"), constant(TAKES), new Var("c"));
List<ExtensionElem> elements = Arrays.asList(new ExtensionElem(new Var("x"), "renamed"), new ExtensionElem(new Not(new ValueConstant(VF.createLiteral(true))), "notTrue"), new ExtensionElem(new ValueConstant(TAKES), "constant"));
Extension extensionNode = new Extension(sp, elements);
QueryRoot queryTree = new QueryRoot(extensionNode);
SparqlToPipelineTransformVisitor visitor = new SparqlToPipelineTransformVisitor(collection);
queryTree.visit(visitor);
Assert.assertTrue(queryTree.getArg() instanceof Extension);
Assert.assertEquals(elements, ((Extension) queryTree.getArg()).getElements());
TupleExpr innerQuery = ((Extension) queryTree.getArg()).getArg();
Assert.assertTrue(innerQuery instanceof AggregationPipelineQueryNode);
AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) innerQuery;
Assert.assertEquals(Sets.newHashSet("x", "c"), pipelineNode.getAssuredBindingNames());
}
Aggregations