Search in sources :

Example 1 with UnaryResult

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

the class StatementOutputFormatterTest method missingSubject.

@Test
public void missingSubject() {
    // Create the input binding set.
    final ValueFactory vf = new ValueFactoryImpl();
    final MapBindingSet bindingSet = new MapBindingSet();
    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 UnaryResult(visBs)));
    // Verify the mock was never invoked.
    verify(context, times(0)).forward(any(), any());
}
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) 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)

Example 2 with UnaryResult

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

the class StatementOutputFormatterTest method subjectWrongType.

@Test
public void subjectWrongType() {
    // Create the input binding set.
    final ValueFactory vf = new ValueFactoryImpl();
    final MapBindingSet bindingSet = new MapBindingSet();
    bindingSet.addBinding("subject", vf.createLiteral("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 UnaryResult(visBs)));
    // Verify the mock was never invoked.
    verify(context, times(0)).forward(any(), any());
}
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) 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)

Example 3 with UnaryResult

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

the class StatementOutputFormatterTest method missingObject.

@Test
public void missingObject() {
    // 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"));
    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 UnaryResult(visBs)));
    // Verify the mock was never invoked.
    verify(context, times(0)).forward(any(), any());
}
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) 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)

Example 4 with UnaryResult

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

the class StatementOutputFormatterTest method unaryResult.

@Test
public void unaryResult() {
    // 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 UnaryResult(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) UnaryResult(org.apache.rya.streams.kafka.processors.ProcessorResult.UnaryResult) 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) Test(org.junit.Test)

Example 5 with UnaryResult

use of org.apache.rya.streams.kafka.processors.ProcessorResult.UnaryResult 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)10 VisibilityBindingSet (org.apache.rya.api.model.VisibilityBindingSet)10 UnaryResult (org.apache.rya.streams.kafka.processors.ProcessorResult.UnaryResult)10 Test (org.junit.Test)10 ValueFactory (org.openrdf.model.ValueFactory)10 ValueFactoryImpl (org.openrdf.model.impl.ValueFactoryImpl)10 MapBindingSet (org.openrdf.query.impl.MapBindingSet)10 StatementOutputFormatter (org.apache.rya.streams.kafka.processors.output.StatementOutputFormatterSupplier.StatementOutputFormatter)6 ProcessorResult (org.apache.rya.streams.kafka.processors.ProcessorResult)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 UUID (java.util.UUID)1 Collectors (java.util.stream.Collectors)1 MultiProjectionEvaluator (org.apache.rya.api.function.projection.MultiProjectionEvaluator)1 VisibilityStatement (org.apache.rya.api.model.VisibilityStatement)1 RdfTestUtil (org.apache.rya.streams.kafka.RdfTestUtil)1 ResultType (org.apache.rya.streams.kafka.processors.ProcessorResult.ResultType)1 FilterProcessor (org.apache.rya.streams.kafka.processors.filter.FilterProcessorSupplier.FilterProcessor)1 BindingSetOutputFormatter (org.apache.rya.streams.kafka.processors.output.BindingSetOutputFormatterSupplier.BindingSetOutputFormatter)1 MultiProjectionProcessor (org.apache.rya.streams.kafka.processors.projection.MultiProjectionProcessorSupplier.MultiProjectionProcessor)1