use of org.apache.samza.system.StreamSpec in project samza by apache.
the class TestAbstractApplicationRunner method testgetStreamWithOutSystemInConfig.
// System is required. Throw if it cannot be determined.
@Test(expected = IllegalArgumentException.class)
public void testgetStreamWithOutSystemInConfig() {
Config config = buildStreamConfig(STREAM_ID, StreamConfig.PHYSICAL_NAME(), TEST_PHYSICAL_NAME);
AbstractApplicationRunner runner = new TestAbstractApplicationRunnerImpl(config);
StreamSpec spec = runner.getStreamSpec(STREAM_ID);
assertEquals(TEST_SYSTEM, spec.getSystemName());
}
use of org.apache.samza.system.StreamSpec in project samza by apache.
the class TestAbstractApplicationRunner method testgetStreamWithoutPhysicalNameInConfig.
// The streamId should be used as the physicalName when the physical name is not specified.
// NOTE: its either this, set to null, or exception. This seems better for backward compatibility and API brevity.
@Test
public void testgetStreamWithoutPhysicalNameInConfig() {
Config config = buildStreamConfig(STREAM_ID, StreamConfig.SYSTEM(), TEST_SYSTEM);
AbstractApplicationRunner runner = new TestAbstractApplicationRunnerImpl(config);
StreamSpec spec = runner.getStreamSpec(STREAM_ID);
assertEquals(STREAM_ID, spec.getPhysicalName());
}
use of org.apache.samza.system.StreamSpec in project samza by apache.
the class TestAbstractApplicationRunner method testGetStreamPhysicalNameArgSimple.
// When the physicalName argument is passed explicitly it should be used, regardless of whether it is also in the config
@Test
public void testGetStreamPhysicalNameArgSimple() {
Config config = buildStreamConfig(STREAM_ID, // This should be ignored because of the explicit arg
StreamConfig.PHYSICAL_NAME(), // This should be ignored because of the explicit arg
TEST_PHYSICAL_NAME2, StreamConfig.SYSTEM(), TEST_SYSTEM);
AbstractApplicationRunner runner = new TestAbstractApplicationRunnerImpl(config);
StreamSpec spec = runner.getStreamSpec(STREAM_ID, TEST_PHYSICAL_NAME);
assertEquals(STREAM_ID, spec.getId());
assertEquals(TEST_PHYSICAL_NAME, spec.getPhysicalName());
assertEquals(TEST_SYSTEM, spec.getSystemName());
}
use of org.apache.samza.system.StreamSpec in project samza by apache.
the class TestAbstractApplicationRunner method testgetStreamWithSystemAtDefaultScopeInConfig.
// If system isn't specified at stream scope, use the default system
@Test
public void testgetStreamWithSystemAtDefaultScopeInConfig() {
Config config = addConfigs(buildStreamConfig(STREAM_ID, StreamConfig.PHYSICAL_NAME(), TEST_PHYSICAL_NAME), JobConfig.JOB_DEFAULT_SYSTEM(), TEST_DEFAULT_SYSTEM);
AbstractApplicationRunner runner = new TestAbstractApplicationRunnerImpl(config);
StreamSpec spec = runner.getStreamSpec(STREAM_ID);
assertEquals(TEST_DEFAULT_SYSTEM, spec.getSystemName());
}
use of org.apache.samza.system.StreamSpec 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