Search in sources :

Example 1 with BinaryResult

use of org.apache.rya.streams.kafka.processors.ProcessorResult.BinaryResult in project incubator-rya by apache.

the class StatementOutputFormatterTest method binaryResult.

@Test
public void binaryResult() {
    // Create the input binding set.
    final ValueFactory vf = new ValueFactoryImpl();
    final MapBindingSet bindingSet = new MapBindingSet();
    bindingSet.addBinding("subject", vf.createURI("urn:Alice"));
    bindingSet.addBinding("predicate", vf.createURI("urn:age"));
    bindingSet.addBinding("object", 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 StatementOutputFormatter formatter = new StatementOutputFormatter();
    formatter.init(context);
    formatter.process("key", ProcessorResult.make(new BinaryResult(Side.LEFT, visBs)));
    // Verify the mock was invoked with the expected output.
    final VisibilityStatement expectedStmt = new VisibilityStatement(vf.createStatement(vf.createURI("urn:Alice"), vf.createURI("urn:age"), vf.createLiteral(34)), "a");
    verify(context, times(1)).forward(eq("key"), eq(expectedStmt));
}
Also used : VisibilityBindingSet(org.apache.rya.api.model.VisibilityBindingSet) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) StatementOutputFormatter(org.apache.rya.streams.kafka.processors.output.StatementOutputFormatterSupplier.StatementOutputFormatter) ValueFactory(org.openrdf.model.ValueFactory) MapBindingSet(org.openrdf.query.impl.MapBindingSet) VisibilityStatement(org.apache.rya.api.model.VisibilityStatement) ProcessorContext(org.apache.kafka.streams.processor.ProcessorContext) BinaryResult(org.apache.rya.streams.kafka.processors.ProcessorResult.BinaryResult) Test(org.junit.Test)

Example 2 with BinaryResult

use of org.apache.rya.streams.kafka.processors.ProcessorResult.BinaryResult 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)

Aggregations

ProcessorContext (org.apache.kafka.streams.processor.ProcessorContext)2 VisibilityBindingSet (org.apache.rya.api.model.VisibilityBindingSet)2 BinaryResult (org.apache.rya.streams.kafka.processors.ProcessorResult.BinaryResult)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 VisibilityStatement (org.apache.rya.api.model.VisibilityStatement)1 BindingSetOutputFormatter (org.apache.rya.streams.kafka.processors.output.BindingSetOutputFormatterSupplier.BindingSetOutputFormatter)1 StatementOutputFormatter (org.apache.rya.streams.kafka.processors.output.StatementOutputFormatterSupplier.StatementOutputFormatter)1