use of org.apache.beam.sdk.schemas.utils.TestPOJOs.PojoWithNestedArray in project beam by apache.
the class JavaFieldSchemaTest method testNestedArraysToRow.
@Test
public void testNestedArraysToRow() throws NoSuchSchemaException {
SchemaRegistry registry = SchemaRegistry.createDefault();
Schema schema = registry.getSchema(PojoWithNestedArray.class);
SchemaTestUtils.assertSchemaEquivalent(POJO_WITH_NESTED_ARRAY_SCHEMA, schema);
Row simpleRow = createSimpleRow("string");
List<Row> list = ImmutableList.of(simpleRow, simpleRow);
List<List<Row>> listOfList = ImmutableList.of(list, list);
Row nestedRow = Row.withSchema(POJO_WITH_NESTED_ARRAY_SCHEMA).addValue(listOfList).build();
SimplePOJO simplePojo = createSimple("string");
List<SimplePOJO> simplePojoList = ImmutableList.of(simplePojo, simplePojo);
List<List<SimplePOJO>> simplePojoListOfList = ImmutableList.of(simplePojoList, simplePojoList);
Row converted = registry.getToRowFunction(PojoWithNestedArray.class).apply(new PojoWithNestedArray(simplePojoListOfList));
assertEquals(nestedRow, converted);
}
use of org.apache.beam.sdk.schemas.utils.TestPOJOs.PojoWithNestedArray in project beam by apache.
the class JavaFieldSchemaTest method testNestedArraysFromRow.
@Test
public void testNestedArraysFromRow() throws NoSuchSchemaException {
SchemaRegistry registry = SchemaRegistry.createDefault();
Schema schema = registry.getSchema(PojoWithNestedArray.class);
SchemaTestUtils.assertSchemaEquivalent(POJO_WITH_NESTED_ARRAY_SCHEMA, schema);
Row simpleRow = createSimpleRow("string");
List<Row> list = ImmutableList.of(simpleRow, simpleRow);
List<List<Row>> listOfList = ImmutableList.of(list, list);
Row nestedRow = Row.withSchema(POJO_WITH_NESTED_ARRAY_SCHEMA).addValue(listOfList).build();
SimplePOJO simplePojo = createSimple("string");
List<SimplePOJO> simplePojoList = ImmutableList.of(simplePojo, simplePojo);
List<List<SimplePOJO>> simplePojoListOfList = ImmutableList.of(simplePojoList, simplePojoList);
PojoWithNestedArray converted = registry.getFromRowFunction(PojoWithNestedArray.class).apply(nestedRow);
assertEquals(simplePojoListOfList, converted.pojos);
}
Aggregations