use of org.apache.samza.test.framework.system.descriptors.InMemoryOutputDescriptor in project samza by apache.
the class AsyncStreamTaskIntegrationTest method testAsyncTaskWithSinglePartitionUsingStreamAssert.
@Test
public void testAsyncTaskWithSinglePartitionUsingStreamAssert() throws Exception {
List<Integer> inputList = Arrays.asList(1, 2, 3, 4, 5);
List<Integer> outputList = Arrays.asList(50, 10, 20, 30, 40);
InMemorySystemDescriptor isd = new InMemorySystemDescriptor("async-test");
InMemoryInputDescriptor<Integer> imid = isd.getInputDescriptor("ints", new NoOpSerde<Integer>());
InMemoryOutputDescriptor imod = isd.getOutputDescriptor("ints-out", new NoOpSerde<>());
TestRunner.of(MyAsyncStreamTask.class).addInputStream(imid, inputList).addOutputStream(imod, 1).run(Duration.ofSeconds(2));
StreamAssert.containsInAnyOrder(outputList, imod, Duration.ofMillis(1000));
}
use of org.apache.samza.test.framework.system.descriptors.InMemoryOutputDescriptor in project samza by apache.
the class AsyncStreamTaskIntegrationTest method testSamzaJobTimeoutFailureForAsyncTask.
/**
* Job should fail because it times out too soon
*/
@Test(expected = SamzaException.class)
public void testSamzaJobTimeoutFailureForAsyncTask() {
InMemorySystemDescriptor isd = new InMemorySystemDescriptor("async-test");
InMemoryInputDescriptor<Integer> imid = isd.getInputDescriptor("ints", new NoOpSerde<>());
InMemoryOutputDescriptor imod = isd.getOutputDescriptor("ints-out", new NoOpSerde<>());
TestRunner.of(MyAsyncStreamTask.class).addInputStream(imid, Arrays.asList(1, 2, 3, 4)).addOutputStream(imod, 1).run(Duration.ofMillis(1));
}
use of org.apache.samza.test.framework.system.descriptors.InMemoryOutputDescriptor in project samza by apache.
the class AsyncStreamTaskIntegrationTest method testAsyncTaskWithMultiplePartition.
@Test
public void testAsyncTaskWithMultiplePartition() throws Exception {
Map<Integer, List<KV>> inputPartitionData = new HashMap<>();
Map<Integer, List<Integer>> expectedOutputPartitionData = new HashMap<>();
genData(inputPartitionData, expectedOutputPartitionData);
InMemorySystemDescriptor isd = new InMemorySystemDescriptor("async-test");
InMemoryInputDescriptor<KV> imid = isd.getInputDescriptor("ints", new NoOpSerde<KV>());
InMemoryOutputDescriptor imod = isd.getOutputDescriptor("ints-out", new NoOpSerde<>());
TestRunner.of(MyAsyncStreamTask.class).addInputStream(imid, inputPartitionData).addOutputStream(imod, 5).run(Duration.ofSeconds(2));
StreamAssert.containsInOrder(expectedOutputPartitionData, imod, Duration.ofMillis(1000));
}
Aggregations