use of com.google.api.services.bigquery.model.TableRow in project beam by apache.
the class BigQueryTornadoesTest method testFormatCounts.
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void testFormatCounts() throws Exception {
DoFnTester<KV<Integer, Long>, TableRow> formatCountsFn = DoFnTester.of(new FormatCountsFn());
KV[] empty = {};
List<TableRow> results = formatCountsFn.processBundle(empty);
Assert.assertTrue(results.size() == 0);
KV[] input = { KV.of(3, 0L), KV.of(4, Long.MAX_VALUE), KV.of(5, Long.MIN_VALUE) };
results = formatCountsFn.processBundle(input);
Assert.assertEquals(results.size(), 3);
Assert.assertEquals(results.get(0).get("month"), 3);
Assert.assertEquals(results.get(0).get("tornado_count"), 0L);
Assert.assertEquals(results.get(1).get("month"), 4);
Assert.assertEquals(results.get(1).get("tornado_count"), Long.MAX_VALUE);
Assert.assertEquals(results.get(2).get("month"), 5);
Assert.assertEquals(results.get(2).get("tornado_count"), Long.MIN_VALUE);
}
use of com.google.api.services.bigquery.model.TableRow in project beam by apache.
the class CombinePerKeyExamplesTest method testFormatShakespeareOutputFn.
@Test
public void testFormatShakespeareOutputFn() throws Exception {
DoFnTester<KV<String, String>, TableRow> formatShakespeareOutputFn = DoFnTester.of(new FormatShakespeareOutputFn());
List<TableRow> results = formatShakespeareOutputFn.processBundle(COMBINED_TUPLES_ARRAY);
Assert.assertThat(results, CoreMatchers.hasItem(resultRow1));
Assert.assertThat(results, CoreMatchers.hasItem(resultRow2));
}
use of com.google.api.services.bigquery.model.TableRow in project beam by apache.
the class FilterExamplesTest method testProjectionFn.
@Test
public void testProjectionFn() throws Exception {
DoFnTester<TableRow, TableRow> projectionFn = DoFnTester.of(new ProjectionFn());
List<TableRow> results = projectionFn.processBundle(ROWS_ARRAY);
Assert.assertThat(results, CoreMatchers.hasItem(outRow1));
Assert.assertThat(results, CoreMatchers.hasItem(outRow2));
Assert.assertThat(results, CoreMatchers.hasItem(outRow3));
}
use of com.google.api.services.bigquery.model.TableRow in project beam by apache.
the class FilterExamplesTest method testFilterSingleMonthDataFn.
@Test
public void testFilterSingleMonthDataFn() throws Exception {
DoFnTester<TableRow, TableRow> filterSingleMonthDataFn = DoFnTester.of(new FilterSingleMonthDataFn(7));
List<TableRow> results = filterSingleMonthDataFn.processBundle(PROJROWS_ARRAY);
Assert.assertThat(results, CoreMatchers.hasItem(outRow2));
}
use of com.google.api.services.bigquery.model.TableRow in project beam by apache.
the class JoinExamplesTest method testExtractEventDataFn.
@Test
public void testExtractEventDataFn() throws Exception {
DoFnTester<TableRow, KV<String, String>> extractEventDataFn = DoFnTester.of(new ExtractEventDataFn());
List<KV<String, String>> results = extractEventDataFn.processBundle(EVENTS);
Assert.assertThat(results, CoreMatchers.hasItem(kv1));
Assert.assertThat(results, CoreMatchers.hasItem(kv2));
}
Aggregations