use of org.apache.samza.operators.stream.InputStreamInternalImpl in project samza by apache.
the class TestStreamGraphImpl method testGetInputStream.
@Test
public void testGetInputStream() {
ApplicationRunner mockRunner = mock(ApplicationRunner.class);
Config mockConfig = mock(Config.class);
StreamSpec testStreamSpec = new StreamSpec("test-stream-1", "physical-stream-1", "test-system");
when(mockRunner.getStreamSpec("test-stream-1")).thenReturn(testStreamSpec);
StreamGraphImpl graph = new StreamGraphImpl(mockRunner, mockConfig);
BiFunction<String, MessageType, TestInputMessageEnvelope> xMsgBuilder = (k, v) -> new TestInputMessageEnvelope(k, v.getValue(), v.getEventTime(), "input-id-1");
MessageStream<TestMessageEnvelope> mInputStream = graph.getInputStream("test-stream-1", xMsgBuilder);
assertEquals(graph.getInputStreams().get(testStreamSpec), mInputStream);
assertTrue(mInputStream instanceof InputStreamInternalImpl);
assertEquals(((InputStreamInternalImpl) mInputStream).getMsgBuilder(), xMsgBuilder);
String key = "test-input-key";
MessageType msgBody = new MessageType("test-msg-value", 333333L);
TestMessageEnvelope xInputMsg = ((InputStreamInternalImpl<String, MessageType, TestMessageEnvelope>) mInputStream).getMsgBuilder().apply(key, msgBody);
assertEquals(xInputMsg.getKey(), key);
assertEquals(xInputMsg.getMessage().getValue(), msgBody.getValue());
assertEquals(xInputMsg.getMessage().getEventTime(), msgBody.getEventTime());
assertEquals(((TestInputMessageEnvelope) xInputMsg).getInputId(), "input-id-1");
}
Aggregations