use of org.apache.samza.operators.spec.InputOperatorSpec 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.operators.spec.InputOperatorSpec in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testGetIntermediateStreamWithValueSerde.
@Test
public void testGetIntermediateStreamWithValueSerde() {
String streamId = "stream-1";
StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(appDesc -> {
}, getConfig());
Serde mockValueSerde = mock(Serde.class);
IntermediateMessageStreamImpl<TestMessageEnvelope> intermediateStreamImpl = streamAppDesc.getIntermediateStream(streamId, mockValueSerde, false);
assertEquals(streamAppDesc.getInputOperators().get(streamId), intermediateStreamImpl.getOperatorSpec());
assertEquals(streamAppDesc.getOutputStreams().get(streamId), intermediateStreamImpl.getOutputStream());
assertEquals(streamId, intermediateStreamImpl.getStreamId());
assertTrue(intermediateStreamImpl.getOutputStream().getKeySerde() instanceof NoOpSerde);
assertEquals(mockValueSerde, intermediateStreamImpl.getOutputStream().getValueSerde());
assertTrue(((InputOperatorSpec) (OperatorSpec) intermediateStreamImpl.getOperatorSpec()).getKeySerde() instanceof NoOpSerde);
assertEquals(mockValueSerde, ((InputOperatorSpec) (OperatorSpec) intermediateStreamImpl.getOperatorSpec()).getValueSerde());
}
use of org.apache.samza.operators.spec.InputOperatorSpec 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.operators.spec.InputOperatorSpec 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.operators.spec.InputOperatorSpec 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));
}
Aggregations