Search in sources :

Example 1 with MapPrimitive

use of org.apache.beam.sdk.extensions.protobuf.Proto3SchemaMessages.MapPrimitive in project beam by apache.

the class ProtoDynamicMessageSchemaTest method testMapRowToProto.

@Test
public void testMapRowToProto() {
    ProtoDynamicMessageSchema schemaProvider = schemaFromDescriptor(MapPrimitive.getDescriptor());
    SerializableFunction<Row, DynamicMessage> fromRow = schemaProvider.getFromRowFunction();
    MapPrimitive proto = parseFrom(fromRow.apply(MAP_PRIMITIVE_ROW).toString(), MapPrimitive.newBuilder()).build();
    assertEquals(MAP_PRIMITIVE_PROTO, proto);
}
Also used : MapPrimitive(org.apache.beam.sdk.extensions.protobuf.Proto3SchemaMessages.MapPrimitive) Row(org.apache.beam.sdk.values.Row) DynamicMessage(com.google.protobuf.DynamicMessage) Test(org.junit.Test)

Example 2 with MapPrimitive

use of org.apache.beam.sdk.extensions.protobuf.Proto3SchemaMessages.MapPrimitive in project beam by apache.

the class ProtoDynamicMessageSchemaTest method testNullMapRowToProto.

@Test
public void testNullMapRowToProto() {
    ProtoDynamicMessageSchema schemaProvider = schemaFromDescriptor(MapPrimitive.getDescriptor());
    SerializableFunction<Row, DynamicMessage> fromRow = schemaProvider.getFromRowFunction();
    MapPrimitive proto = parseFrom(fromRow.apply(NULL_MAP_PRIMITIVE_ROW).toString(), MapPrimitive.newBuilder()).build();
    assertEquals(NULL_MAP_PRIMITIVE_PROTO, proto);
}
Also used : MapPrimitive(org.apache.beam.sdk.extensions.protobuf.Proto3SchemaMessages.MapPrimitive) Row(org.apache.beam.sdk.values.Row) DynamicMessage(com.google.protobuf.DynamicMessage) Test(org.junit.Test)

Aggregations

DynamicMessage (com.google.protobuf.DynamicMessage)2 MapPrimitive (org.apache.beam.sdk.extensions.protobuf.Proto3SchemaMessages.MapPrimitive)2 Row (org.apache.beam.sdk.values.Row)2 Test (org.junit.Test)2