use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class TikaIOTest method testParseDisplayData.
@Test
public void testParseDisplayData() {
TikaIO.Parse parse = TikaIO.parse().filepattern("file.pdf");
DisplayData displayData = DisplayData.from(parse);
assertThat(displayData, hasDisplayItem("filePattern", "file.pdf"));
assertEquals(1, displayData.items().size());
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class XmlIOTest method testDisplayData.
@Test
public void testDisplayData() {
DisplayData displayData = DisplayData.from(XmlIO.<Integer>read().from("foo.xml").withRootElement("bird").withRecordElement("cat").withMinBundleSize(1234).withRecordClass(Integer.class));
assertThat(displayData, hasDisplayItem("filePattern", "foo.xml"));
assertThat(displayData, hasDisplayItem("rootElement", "bird"));
assertThat(displayData, hasDisplayItem("recordElement", "cat"));
assertThat(displayData, hasDisplayItem("recordClass", Integer.class));
assertThat(displayData, hasDisplayItem("minBundleSize", 1234));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class BigQueryIOWriteTest method testBuildWriteDisplayData.
@Test
public void testBuildWriteDisplayData() {
String tableSpec = "project:dataset.table";
TableSchema schema = new TableSchema().set("col1", "type1").set("col2", "type2");
final String tblDescription = "foo bar table";
BigQueryIO.Write<TableRow> write = BigQueryIO.writeTableRows().to(tableSpec).withSchema(schema).withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED).withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_APPEND).withSchemaUpdateOptions(EnumSet.of(BigQueryIO.Write.SchemaUpdateOption.ALLOW_FIELD_ADDITION)).withTableDescription(tblDescription).withoutValidation();
DisplayData displayData = DisplayData.from(write);
assertThat(displayData, hasDisplayItem("table"));
assertThat(displayData, hasDisplayItem("schema"));
assertThat(displayData, hasDisplayItem("createDisposition", BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED.toString()));
assertThat(displayData, hasDisplayItem("writeDisposition", BigQueryIO.Write.WriteDisposition.WRITE_APPEND.toString()));
assertThat(displayData, hasDisplayItem("schemaUpdateOptions", EnumSet.of(BigQueryIO.Write.SchemaUpdateOption.ALLOW_FIELD_ADDITION).toString()));
assertThat(displayData, hasDisplayItem("tableDescription", tblDescription));
assertThat(displayData, hasDisplayItem("validation", false));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class BigQueryIOReadTest method testBuildSourceDisplayDataQuery.
@Test
public void testBuildSourceDisplayDataQuery() {
BigQueryIO.Read read = BigQueryIO.read().fromQuery("myQuery").withoutResultFlattening().usingStandardSql().withoutValidation();
DisplayData displayData = DisplayData.from(read);
assertThat(displayData, hasDisplayItem("query", "myQuery"));
assertThat(displayData, hasDisplayItem("flattenResults", false));
assertThat(displayData, hasDisplayItem("useLegacySql", false));
assertThat(displayData, hasDisplayItem("validation", false));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class MapElementsTest method testPrimitiveDisplayData.
@Test
@Category(ValidatesRunner.class)
public void testPrimitiveDisplayData() {
SimpleFunction<Integer, ?> mapFn = new SimpleFunction<Integer, Integer>() {
@Override
public Integer apply(Integer input) {
return input;
}
};
MapElements<Integer, ?> map = MapElements.via(mapFn);
DisplayDataEvaluator evaluator = DisplayDataEvaluator.create();
Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(map);
assertThat("MapElements should include the mapFn in its primitive display data", displayData, hasItem(hasDisplayItem("class", mapFn.getClass())));
}
Aggregations