use of org.apache.samza.system.descriptors.GenericSystemDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testGetOutputStreamWithKeyValueSerde.
@Test
public void testGetOutputStreamWithKeyValueSerde() {
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");
GenericOutputDescriptor osd = sd.getOutputDescriptor(streamId, mockKVSerde);
StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(appDesc -> {
appDesc.getOutputStream(osd);
}, getConfig());
OutputStreamImpl<TestMessageEnvelope> outputStreamImpl = streamAppDesc.getOutputStreams().get(streamId);
assertEquals(streamId, outputStreamImpl.getStreamId());
assertEquals(osd, streamAppDesc.getOutputDescriptors().get(streamId));
assertEquals(mockKeySerde, outputStreamImpl.getKeySerde());
assertEquals(mockValueSerde, outputStreamImpl.getValueSerde());
}
use of org.apache.samza.system.descriptors.GenericSystemDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testGetOutputStreamWithValueSerde.
@Test
public void testGetOutputStreamWithValueSerde() {
String streamId = "test-stream-1";
Serde mockValueSerde = mock(Serde.class);
GenericSystemDescriptor sd = new GenericSystemDescriptor("mockSystem", "mockSystemFactoryClass");
GenericOutputDescriptor osd = sd.getOutputDescriptor(streamId, mockValueSerde);
StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(appDesc -> {
appDesc.getOutputStream(osd);
}, getConfig());
OutputStreamImpl<TestMessageEnvelope> outputStreamImpl = streamAppDesc.getOutputStreams().get(streamId);
assertEquals(streamId, outputStreamImpl.getStreamId());
assertEquals(osd, streamAppDesc.getOutputDescriptors().get(streamId));
assertTrue(outputStreamImpl.getKeySerde() instanceof NoOpSerde);
assertEquals(mockValueSerde, outputStreamImpl.getValueSerde());
}
use of org.apache.samza.system.descriptors.GenericSystemDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testGetInputStreamWithValueSerde.
@Test
public void testGetInputStreamWithValueSerde() {
String streamId = "test-stream-1";
Serde mockValueSerde = mock(Serde.class);
GenericSystemDescriptor sd = new GenericSystemDescriptor("mockSystem", "mockSystemFactoryClass");
GenericInputDescriptor isd = sd.getInputDescriptor(streamId, mockValueSerde);
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));
assertTrue(inputOpSpec.getKeySerde() instanceof NoOpSerde);
assertEquals(mockValueSerde, inputOpSpec.getValueSerde());
}
use of org.apache.samza.system.descriptors.GenericSystemDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testGetSameOutputStreamTwice.
@Test(expected = IllegalStateException.class)
public void testGetSameOutputStreamTwice() {
String streamId = "test-stream-1";
GenericSystemDescriptor sd = new GenericSystemDescriptor("mockSystem", "mockSystemFactoryClass");
GenericOutputDescriptor osd1 = sd.getOutputDescriptor(streamId, mock(Serde.class));
GenericOutputDescriptor osd2 = sd.getOutputDescriptor(streamId, mock(Serde.class));
new StreamApplicationDescriptorImpl(appDesc -> {
appDesc.getOutputStream(osd1);
// should throw exception
appDesc.getOutputStream(osd2);
}, getConfig());
}
use of org.apache.samza.system.descriptors.GenericSystemDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testGetInputStreamWithNullSerde.
@Test(expected = IllegalArgumentException.class)
public void testGetInputStreamWithNullSerde() {
GenericSystemDescriptor sd = new GenericSystemDescriptor("mockSystem", "mockSystemFactoryClass");
GenericInputDescriptor isd = sd.getInputDescriptor("mockStreamId", null);
new StreamApplicationDescriptorImpl(appDesc -> {
appDesc.getInputStream(isd);
}, getConfig());
}
Aggregations