use of org.apache.rya.streams.kafka.processors.filter.FilterProcessorSupplier.FilterProcessor in project incubator-rya by apache.
the class FilterProcessorTest method showFilterFunctionIsCalled.
@Test
public void showFilterFunctionIsCalled() throws Exception {
// Read the filter object from a SPARQL query.
final Filter filter = RdfTestUtil.getFilter("SELECT * " + "WHERE { " + "FILTER(?age < 10)" + "?person <urn:age> ?age " + "}");
// Create a Binding Set that will be passed into the Filter function based on the where clause.
final ValueFactory vf = new ValueFactoryImpl();
final MapBindingSet bs = new MapBindingSet();
bs.addBinding("person", vf.createURI("urn:Alice"));
bs.addBinding("age", vf.createLiteral(9));
final VisibilityBindingSet inputVisBs = new VisibilityBindingSet(bs, "a");
// Mock the processor context that will be invoked.
final ProcessorContext context = mock(ProcessorContext.class);
// Run the test.
final FilterProcessor processor = new FilterProcessor(FilterEvaluator.make(filter), result -> ProcessorResult.make(new UnaryResult(result)));
processor.init(context);
processor.process("key", ProcessorResult.make(new UnaryResult(inputVisBs)));
// Verify the binding set was passed through.
verify(context, times(1)).forward(eq("key"), eq(ProcessorResult.make(new UnaryResult(inputVisBs))));
}
Aggregations