Search in sources :

Example 1 with BindingSetOutputFormatter

use of org.apache.rya.streams.kafka.processors.output.BindingSetOutputFormatterSupplier.BindingSetOutputFormatter in project incubator-rya by apache.

the class BindingSetOutputFormatterTest method binaryResult.

@Test
public void binaryResult() {
    // Create the input binding set.
    final ValueFactory vf = new ValueFactoryImpl();
    final MapBindingSet bindingSet = new MapBindingSet();
    bindingSet.addBinding("person", vf.createURI("urn:Alice"));
    bindingSet.addBinding("age", vf.createLiteral(34));
    final VisibilityBindingSet visBs = new VisibilityBindingSet(bindingSet, "a");
    // Mock the processor context that will be invoked.
    final ProcessorContext context = mock(ProcessorContext.class);
    // Run the test.
    final BindingSetOutputFormatter formatter = new BindingSetOutputFormatter();
    formatter.init(context);
    formatter.process("key", ProcessorResult.make(new BinaryResult(Side.LEFT, visBs)));
    // Verify the mock was invoked with the expected output.
    verify(context, times(1)).forward(eq("key"), eq(visBs));
}
Also used : VisibilityBindingSet(org.apache.rya.api.model.VisibilityBindingSet) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) BindingSetOutputFormatter(org.apache.rya.streams.kafka.processors.output.BindingSetOutputFormatterSupplier.BindingSetOutputFormatter) ValueFactory(org.openrdf.model.ValueFactory) MapBindingSet(org.openrdf.query.impl.MapBindingSet) ProcessorContext(org.apache.kafka.streams.processor.ProcessorContext) BinaryResult(org.apache.rya.streams.kafka.processors.ProcessorResult.BinaryResult) Test(org.junit.Test)

Example 2 with BindingSetOutputFormatter

use of org.apache.rya.streams.kafka.processors.output.BindingSetOutputFormatterSupplier.BindingSetOutputFormatter in project incubator-rya by apache.

the class BindingSetOutputFormatterTest method unaryResult.

@Test
public void unaryResult() {
    // Create the input binding set.
    final ValueFactory vf = new ValueFactoryImpl();
    final MapBindingSet bindingSet = new MapBindingSet();
    bindingSet.addBinding("person", vf.createURI("urn:Alice"));
    bindingSet.addBinding("age", vf.createLiteral(34));
    final VisibilityBindingSet visBs = new VisibilityBindingSet(bindingSet, "a");
    // Mock the processor context that will be invoked.
    final ProcessorContext context = mock(ProcessorContext.class);
    // Run the test.
    final BindingSetOutputFormatter formatter = new BindingSetOutputFormatter();
    formatter.init(context);
    formatter.process("key", ProcessorResult.make(new UnaryResult(visBs)));
    // Verify the mock was invoked with the expected output.
    verify(context, times(1)).forward(eq("key"), eq(visBs));
}
Also used : VisibilityBindingSet(org.apache.rya.api.model.VisibilityBindingSet) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) BindingSetOutputFormatter(org.apache.rya.streams.kafka.processors.output.BindingSetOutputFormatterSupplier.BindingSetOutputFormatter) UnaryResult(org.apache.rya.streams.kafka.processors.ProcessorResult.UnaryResult) ValueFactory(org.openrdf.model.ValueFactory) MapBindingSet(org.openrdf.query.impl.MapBindingSet) ProcessorContext(org.apache.kafka.streams.processor.ProcessorContext) Test(org.junit.Test)

Aggregations

ProcessorContext (org.apache.kafka.streams.processor.ProcessorContext)2 VisibilityBindingSet (org.apache.rya.api.model.VisibilityBindingSet)2 BindingSetOutputFormatter (org.apache.rya.streams.kafka.processors.output.BindingSetOutputFormatterSupplier.BindingSetOutputFormatter)2 Test (org.junit.Test)2 ValueFactory (org.openrdf.model.ValueFactory)2 ValueFactoryImpl (org.openrdf.model.impl.ValueFactoryImpl)2 MapBindingSet (org.openrdf.query.impl.MapBindingSet)2 BinaryResult (org.apache.rya.streams.kafka.processors.ProcessorResult.BinaryResult)1 UnaryResult (org.apache.rya.streams.kafka.processors.ProcessorResult.UnaryResult)1