Search in sources :

Example 1 with TestMessageStreamImplUtil

use of org.apache.samza.operators.TestMessageStreamImplUtil in project samza by apache.

the class TestOperatorSpecs method testCreateMergeOperator.

@Test
public void testCreateMergeOperator() {
    StreamGraphImpl mockGraph = mock(StreamGraphImpl.class);
    MessageStreamImpl<TestMessageEnvelope> output = TestMessageStreamImplUtil.<TestMessageEnvelope>getMessageStreamImpl(mockGraph);
    StreamOperatorSpec<TestMessageEnvelope, TestMessageEnvelope> mergeOp = OperatorSpecs.createMergeOperatorSpec(output, 1);
    Function<TestMessageEnvelope, Collection<TestMessageEnvelope>> mergeFn = t -> new ArrayList<TestMessageEnvelope>() {

        {
            this.add(t);
        }
    };
    TestMessageEnvelope t = mock(TestMessageEnvelope.class);
    assertEquals(mergeOp.getTransformFn().apply(t), mergeFn.apply(t));
    assertEquals(mergeOp.getNextStream(), output);
}
Also used : PartialJoinFunction(org.apache.samza.operators.functions.PartialJoinFunction) TestInputMessageEnvelope(org.apache.samza.operators.data.TestInputMessageEnvelope) Function(java.util.function.Function) Supplier(java.util.function.Supplier) WindowPane(org.apache.samza.operators.windows.WindowPane) ArrayList(java.util.ArrayList) OutputStreamInternalImpl(org.apache.samza.operators.stream.OutputStreamInternalImpl) MessageCollector(org.apache.samza.task.MessageCollector) MessageStreamImpl(org.apache.samza.operators.MessageStreamImpl) SystemStream(org.apache.samza.system.SystemStream) Mockito.doAnswer(org.mockito.Mockito.doAnswer) TestOutputMessageEnvelope(org.apache.samza.operators.data.TestOutputMessageEnvelope) TestMessageEnvelope(org.apache.samza.operators.data.TestMessageEnvelope) WindowType(org.apache.samza.operators.windows.internal.WindowType) MessageType(org.apache.samza.operators.data.MessageType) Assert.assertNotNull(org.junit.Assert.assertNotNull) Collection(java.util.Collection) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) FlatMapFunction(org.apache.samza.operators.functions.FlatMapFunction) TaskCoordinator(org.apache.samza.task.TaskCoordinator) StreamGraphImpl(org.apache.samza.operators.StreamGraphImpl) Matchers.any(org.mockito.Matchers.any) List(java.util.List) SinkFunction(org.apache.samza.operators.functions.SinkFunction) OutgoingMessageEnvelope(org.apache.samza.system.OutgoingMessageEnvelope) TestMessageStreamImplUtil(org.apache.samza.operators.TestMessageStreamImplUtil) WindowInternal(org.apache.samza.operators.windows.internal.WindowInternal) FoldLeftFunction(org.apache.samza.operators.functions.FoldLeftFunction) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) TestMessageEnvelope(org.apache.samza.operators.data.TestMessageEnvelope) ArrayList(java.util.ArrayList) StreamGraphImpl(org.apache.samza.operators.StreamGraphImpl) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 MessageStreamImpl (org.apache.samza.operators.MessageStreamImpl)1 StreamGraphImpl (org.apache.samza.operators.StreamGraphImpl)1 TestMessageStreamImplUtil (org.apache.samza.operators.TestMessageStreamImplUtil)1 MessageType (org.apache.samza.operators.data.MessageType)1 TestInputMessageEnvelope (org.apache.samza.operators.data.TestInputMessageEnvelope)1 TestMessageEnvelope (org.apache.samza.operators.data.TestMessageEnvelope)1 TestOutputMessageEnvelope (org.apache.samza.operators.data.TestOutputMessageEnvelope)1 FlatMapFunction (org.apache.samza.operators.functions.FlatMapFunction)1 FoldLeftFunction (org.apache.samza.operators.functions.FoldLeftFunction)1 PartialJoinFunction (org.apache.samza.operators.functions.PartialJoinFunction)1 SinkFunction (org.apache.samza.operators.functions.SinkFunction)1 OutputStreamInternalImpl (org.apache.samza.operators.stream.OutputStreamInternalImpl)1 WindowPane (org.apache.samza.operators.windows.WindowPane)1 WindowInternal (org.apache.samza.operators.windows.internal.WindowInternal)1 WindowType (org.apache.samza.operators.windows.internal.WindowType)1