use of org.apache.samza.system.descriptors.GenericInputDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testGetSameInputStreamTwice.
@Test(expected = IllegalStateException.class)
public void testGetSameInputStreamTwice() {
String streamId = "test-stream-1";
GenericSystemDescriptor sd = new GenericSystemDescriptor("mockSystem", "mockSystemFactoryClass");
GenericInputDescriptor isd1 = sd.getInputDescriptor(streamId, mock(Serde.class));
GenericInputDescriptor isd2 = sd.getInputDescriptor(streamId, mock(Serde.class));
new StreamApplicationDescriptorImpl(appDesc -> {
appDesc.getInputStream(isd1);
// should throw exception
appDesc.getInputStream(isd2);
}, getConfig());
}
use of org.apache.samza.system.descriptors.GenericInputDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testGetInputStreamWithKeyValueSerde.
@Test
public void testGetInputStreamWithKeyValueSerde() {
String streamId = "test-stream-1";
KVSerde mockKVSerde = mock(KVSerde.class);
Serde mockKeySerde = mock(Serde.class);
Serde mockValueSerde = mock(Serde.class);
doReturn(mockKeySerde).when(mockKVSerde).getKeySerde();
doReturn(mockValueSerde).when(mockKVSerde).getValueSerde();
GenericSystemDescriptor sd = new GenericSystemDescriptor("mockSystem", "mockSystemFactoryClass");
GenericInputDescriptor isd = sd.getInputDescriptor(streamId, mockKVSerde);
StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(appDesc -> {
appDesc.getInputStream(isd);
}, getConfig());
InputOperatorSpec inputOpSpec = streamAppDesc.getInputOperators().get(streamId);
assertEquals(OpCode.INPUT, inputOpSpec.getOpCode());
assertEquals(streamId, inputOpSpec.getStreamId());
assertEquals(isd, streamAppDesc.getInputDescriptors().get(streamId));
assertEquals(mockKeySerde, inputOpSpec.getKeySerde());
assertEquals(mockValueSerde, inputOpSpec.getValueSerde());
}
use of org.apache.samza.system.descriptors.GenericInputDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testGetInputStreamWithRelaxedTypes.
@Test
public void testGetInputStreamWithRelaxedTypes() {
String streamId = "test-stream-1";
GenericSystemDescriptor sd = new GenericSystemDescriptor("mockSystem", "mockSystemFactoryClass");
GenericInputDescriptor isd = sd.getInputDescriptor(streamId, mock(Serde.class));
StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(appDesc -> {
appDesc.getInputStream(isd);
}, getConfig());
InputOperatorSpec inputOpSpec = streamAppDesc.getInputOperators().get(streamId);
assertEquals(OpCode.INPUT, inputOpSpec.getOpCode());
assertEquals(streamId, inputOpSpec.getStreamId());
assertEquals(isd, streamAppDesc.getInputDescriptors().get(streamId));
}
use of org.apache.samza.system.descriptors.GenericInputDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testMultipleGetInputStreams.
@Test
public void testMultipleGetInputStreams() {
String streamId1 = "test-stream-1";
String streamId2 = "test-stream-2";
GenericSystemDescriptor sd = new GenericSystemDescriptor("mockSystem", "mockSystemFactoryClass");
GenericInputDescriptor isd1 = sd.getInputDescriptor(streamId1, mock(Serde.class));
GenericInputDescriptor isd2 = sd.getInputDescriptor(streamId2, mock(Serde.class));
StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(appDesc -> {
appDesc.getInputStream(isd1);
appDesc.getInputStream(isd2);
}, getConfig());
InputOperatorSpec inputOpSpec1 = streamAppDesc.getInputOperators().get(streamId1);
InputOperatorSpec inputOpSpec2 = streamAppDesc.getInputOperators().get(streamId2);
assertEquals(2, streamAppDesc.getInputOperators().size());
assertEquals(streamId1, inputOpSpec1.getStreamId());
assertEquals(streamId2, inputOpSpec2.getStreamId());
assertEquals(2, streamAppDesc.getInputDescriptors().size());
assertEquals(isd1, streamAppDesc.getInputDescriptors().get(streamId1));
assertEquals(isd2, streamAppDesc.getInputDescriptors().get(streamId2));
}
use of org.apache.samza.system.descriptors.GenericInputDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testMultipleSystemDescriptorForSameSystemName.
@Test
public void testMultipleSystemDescriptorForSameSystemName() {
GenericSystemDescriptor sd1 = new GenericSystemDescriptor("mockSystem", "mockSystemFactoryClass");
GenericSystemDescriptor sd2 = new GenericSystemDescriptor("mockSystem", "mockSystemFactoryClass");
GenericInputDescriptor isd1 = sd1.getInputDescriptor("test-stream-1", mock(Serde.class));
GenericInputDescriptor isd2 = sd2.getInputDescriptor("test-stream-2", mock(Serde.class));
GenericOutputDescriptor osd1 = sd2.getOutputDescriptor("test-stream-3", mock(Serde.class));
new StreamApplicationDescriptorImpl(appDesc -> {
appDesc.getInputStream(isd1);
try {
appDesc.getInputStream(isd2);
fail("Adding input stream with the same system name but different SystemDescriptor should have failed");
} catch (IllegalStateException e) {
}
try {
appDesc.getOutputStream(osd1);
fail("adding output stream with the same system name but different SystemDescriptor should have failed");
} catch (IllegalStateException e) {
}
}, getConfig());
new StreamApplicationDescriptorImpl(appDesc -> {
appDesc.withDefaultSystem(sd2);
try {
appDesc.getInputStream(isd1);
fail("Adding input stream with the same system name as the default system but different SystemDescriptor should have failed");
} catch (IllegalStateException e) {
}
}, getConfig());
}
Aggregations