use of org.apache.samza.test.operator.data.PageView in project samza by apache.
the class BroadcastAssertApp method describe.
@Override
public void describe(StreamApplicationDescriptor appDescriptor) {
Config config = appDescriptor.getConfig();
String inputTopic = config.get(INPUT_TOPIC_NAME_PROP);
final JsonSerdeV2<PageView> serde = new JsonSerdeV2<>(PageView.class);
KafkaSystemDescriptor ksd = new KafkaSystemDescriptor(SYSTEM);
KafkaInputDescriptor<PageView> isd = ksd.getInputDescriptor(inputTopic, serde);
final MessageStream<PageView> broadcastPageViews = appDescriptor.getInputStream(isd).broadcast(serde, "pv");
/**
* Each task will see all the pageview events
*/
MessageStreamAssert.that("Each task contains all broadcast PageView events", broadcastPageViews, serde).forEachTask().containsInAnyOrder(Arrays.asList(new PageView("v1", "p1", "u1"), new PageView("v2", "p2", "u1"), new PageView("v3", "p1", "u2"), new PageView("v4", "p3", "u2")));
}
use of org.apache.samza.test.operator.data.PageView in project samza by apache.
the class TestAsyncFlatMap method runTest.
private List<PageView> runTest(Map<String, String> configs) {
InMemorySystemDescriptor isd = new InMemorySystemDescriptor(TEST_SYSTEM);
InMemoryInputDescriptor<PageView> pageViewStreamDesc = isd.getInputDescriptor(PAGE_VIEW_STREAM, new NoOpSerde<>());
InMemoryOutputDescriptor<PageView> outputStreamDesc = isd.getOutputDescriptor(NON_GUEST_PAGE_VIEW_STREAM, new NoOpSerde<>());
TestRunner.of(new AsyncFlatMapExample()).addInputStream(pageViewStreamDesc, PAGE_VIEWS).addOutputStream(outputStreamDesc, 1).addConfig(new MapConfig(configs)).run(Duration.ofSeconds(10));
Map<Integer, List<PageView>> result = TestRunner.consumeStream(outputStreamDesc, Duration.ofMillis(1000));
return result.values().stream().flatMap(List::stream).collect(Collectors.toList());
}
Aggregations