use of org.apache.beam.sdk.values.Row in project beam by apache.
the class AutoValueSchemaTest method testFromRow_SchemaFieldNumber.
@Test
public void testFromRow_SchemaFieldNumber() throws NoSuchSchemaException {
SchemaRegistry registry = SchemaRegistry.createDefault();
Row row = Row.withSchema(FIELD_NUMBER_SCHEMA).withFieldValue("lng", 42L).withFieldValue("str", "value!").build();
SchemaFieldNumberSimpleClass value = registry.getFromRowFunction(SchemaFieldNumberSimpleClass.class).apply(row);
assertEquals("value!", value.getStr());
assertEquals(42L, (long) value.getLng());
}
use of org.apache.beam.sdk.values.Row in project beam by apache.
the class AutoValueSchemaTest method testToRowConstructor.
@Test
public void testToRowConstructor() throws NoSuchSchemaException {
SchemaRegistry registry = SchemaRegistry.createDefault();
SimpleAutoValue value = new AutoValue_AutoValueSchemaTest_SimpleAutoValue("string", (byte) 1, (short) 2, (int) 3, (long) 4, true, DATE, BYTE_ARRAY, ByteBuffer.wrap(BYTE_ARRAY), DATE.toInstant(), BigDecimal.ONE, STRING_BUILDER);
Row row = registry.getToRowFunction(SimpleAutoValue.class).apply(value);
verifyRow(row);
}
use of org.apache.beam.sdk.values.Row in project beam by apache.
the class AutoValueSchemaTest method testFromRowBuilder.
@Test
public void testFromRowBuilder() throws NoSuchSchemaException {
SchemaRegistry registry = SchemaRegistry.createDefault();
Row row = createSimpleRow("string");
SimpleAutoValueWithBuilder value = registry.getFromRowFunction(SimpleAutoValueWithBuilder.class).apply(row);
verifyAutoValue(value);
}
use of org.apache.beam.sdk.values.Row in project beam by apache.
the class AutoValueSchemaTest method testToRowBuilder.
@Test
public void testToRowBuilder() throws NoSuchSchemaException {
SchemaRegistry registry = SchemaRegistry.createDefault();
SimpleAutoValueWithBuilder value = new AutoValue_AutoValueSchemaTest_SimpleAutoValueWithBuilder.Builder().setStr("string").setaByte((byte) 1).setaShort((short) 2).setAnInt((int) 3).setaLong((long) 4).setaBoolean(true).setDateTime(DATE).setBytes(BYTE_ARRAY).setByteBuffer(ByteBuffer.wrap(BYTE_ARRAY)).setInstant(DATE.toInstant()).setBigDecimal(BigDecimal.ONE).setStringBuilder(STRING_BUILDER).build();
Row row = registry.getToRowFunction(SimpleAutoValueWithBuilder.class).apply(value);
verifyRow(row);
}
use of org.apache.beam.sdk.values.Row in project beam by apache.
the class AutoValueSchemaTest method testFromRowNestedBuilder.
@Test
public void testFromRowNestedBuilder() throws NoSuchSchemaException {
SchemaRegistry registry = SchemaRegistry.createDefault();
Row inner = createSimpleRow("string");
Row outer = Row.withSchema(OUTER_SCHEMA).addValue(inner).build();
AutoValueOuterWithBuilder value = registry.getFromRowFunction(AutoValueOuterWithBuilder.class).apply(outer);
verifyAutoValue(value.getInner());
}
Aggregations