use of org.apache.beam.examples.cookbook.TriggerExample.ExtractFlowInfo in project beam by apache.
the class TriggerExampleTest method testTotalFlow.
@Test
@Category(ValidatesRunner.class)
public void testTotalFlow() {
PCollection<KV<String, Integer>> flow = pipeline.apply(Create.timestamped(TIME_STAMPED_INPUT)).apply(ParDo.of(new ExtractFlowInfo()));
PCollection<TableRow> totalFlow = flow.apply(Window.<KV<String, Integer>>into(FixedWindows.of(Duration.standardMinutes(1)))).apply(new TotalFlow("default"));
PCollection<String> results = totalFlow.apply(ParDo.of(new FormatResults()));
PAssert.that(results).containsInAnyOrder(canonicalFormat(OUT_ROW_1), canonicalFormat(OUT_ROW_2));
pipeline.run().waitUntilFinish();
}
use of org.apache.beam.examples.cookbook.TriggerExample.ExtractFlowInfo in project beam by apache.
the class TriggerExampleTest method testExtractTotalFlow.
@Test
public void testExtractTotalFlow() throws Exception {
DoFnTester<String, KV<String, Integer>> extractFlowInfow = DoFnTester.of(new ExtractFlowInfo());
List<KV<String, Integer>> results = extractFlowInfow.processBundle(INPUT);
Assert.assertEquals(results.size(), 1);
Assert.assertEquals(results.get(0).getKey(), "94");
Assert.assertEquals(results.get(0).getValue(), new Integer(29));
List<KV<String, Integer>> output = extractFlowInfow.processBundle("");
Assert.assertEquals(output.size(), 0);
}
Aggregations