Search in sources :

Example 1 with IsLiteral

use of org.openrdf.query.algebra.IsLiteral in project incubator-rya by apache.

the class AggregationPipelineQueryNodeTest method testFilter.

@Test
public void testFilter() {
    final AggregationPipelineQueryNode base = new AggregationPipelineQueryNode(collection, new LinkedList<>(), Sets.newHashSet("x", "y"), Sets.newHashSet("x", "y", "opt"), HashBiMap.create());
    // Extend with a supported filter
    AggregationPipelineQueryNode node = base.clone();
    boolean success = node.filter(new Compare(new Var("x"), new Var("y"), Compare.CompareOp.EQ));
    Assert.assertTrue(success);
    Assert.assertEquals(Sets.newHashSet("x", "y", "opt"), node.getBindingNames());
    Assert.assertEquals(Sets.newHashSet("x", "y"), node.getAssuredBindingNames());
    Assert.assertEquals(3, node.getPipeline().size());
    // Extend with an unsupported filter
    node = base.clone();
    success = node.filter(new IsLiteral(new Var("opt")));
    Assert.assertFalse(success);
    Assert.assertEquals(Sets.newHashSet("x", "y", "opt"), node.getBindingNames());
    Assert.assertEquals(Sets.newHashSet("x", "y"), node.getAssuredBindingNames());
    Assert.assertEquals(0, node.getPipeline().size());
}
Also used : Var(org.openrdf.query.algebra.Var) IsLiteral(org.openrdf.query.algebra.IsLiteral) Compare(org.openrdf.query.algebra.Compare) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Compare (org.openrdf.query.algebra.Compare)1 IsLiteral (org.openrdf.query.algebra.IsLiteral)1 Var (org.openrdf.query.algebra.Var)1