Search in sources :

Example 1 with TotalFlow

use of org.apache.beam.examples.cookbook.TriggerExample.TotalFlow 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();
}
Also used : TotalFlow(org.apache.beam.examples.cookbook.TriggerExample.TotalFlow) TableRow(com.google.api.services.bigquery.model.TableRow) KV(org.apache.beam.sdk.values.KV) ExtractFlowInfo(org.apache.beam.examples.cookbook.TriggerExample.ExtractFlowInfo) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Aggregations

TableRow (com.google.api.services.bigquery.model.TableRow)1 ExtractFlowInfo (org.apache.beam.examples.cookbook.TriggerExample.ExtractFlowInfo)1 TotalFlow (org.apache.beam.examples.cookbook.TriggerExample.TotalFlow)1 KV (org.apache.beam.sdk.values.KV)1 Test (org.junit.Test)1 Category (org.junit.experimental.categories.Category)1