use of org.apache.samza.system.descriptors.GenericSystemDescriptor 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.GenericSystemDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testGetInputStreamPreservesInsertionOrder.
@Test
public void testGetInputStreamPreservesInsertionOrder() {
Config mockConfig = getConfig();
String testStreamId1 = "test-stream-1";
String testStreamId2 = "test-stream-2";
String testStreamId3 = "test-stream-3";
GenericSystemDescriptor sd = new GenericSystemDescriptor("mockSystem", "mockSystemFactoryClass");
StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(appDesc -> {
appDesc.getInputStream(sd.getInputDescriptor(testStreamId1, mock(Serde.class)));
appDesc.getInputStream(sd.getInputDescriptor(testStreamId2, mock(Serde.class)));
appDesc.getInputStream(sd.getInputDescriptor(testStreamId3, mock(Serde.class)));
}, mockConfig);
List<InputOperatorSpec> inputSpecs = new ArrayList<>(streamAppDesc.getInputOperators().values());
assertEquals(inputSpecs.size(), 3);
assertEquals(inputSpecs.get(0).getStreamId(), testStreamId1);
assertEquals(inputSpecs.get(1).getStreamId(), testStreamId2);
assertEquals(inputSpecs.get(2).getStreamId(), testStreamId3);
}
use of org.apache.samza.system.descriptors.GenericSystemDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testSetDefaultSystemDescriptorAfterGettingOutputStream.
@Test(expected = IllegalStateException.class)
public void testSetDefaultSystemDescriptorAfterGettingOutputStream() {
String streamId = "test-stream-1";
GenericSystemDescriptor sd = new GenericSystemDescriptor("mockSystem", "mockSystemFactoryClass");
GenericOutputDescriptor osd = sd.getOutputDescriptor(streamId, mock(Serde.class));
new StreamApplicationDescriptorImpl(appDesc -> {
appDesc.getOutputStream(osd);
// should throw exception
appDesc.withDefaultSystem(sd);
}, getConfig());
}
use of org.apache.samza.system.descriptors.GenericSystemDescriptor 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.GenericSystemDescriptor 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));
}
Aggregations