ProtoDynamicMessageSchema implements Serializable { public SerializableFunction<Row, T> getFromRowFunction() { return fromRowFunction; } private  ProtoDynamicMessageSchema(String messageName, ProtoDomain domain); private  ProtoDynamicMessageSchema(Context context); static ProtoDynamicMessageSchema forDescriptor(ProtoDomain domain, String messageName); static ProtoDynamicMessageSchema<DynamicMessage> forDescriptor(
      ProtoDomain domain, Descriptors.Descriptor descriptor); Schema getSchema(); SerializableFunction<T, Row> getToRowFunction(); SerializableFunction<Row, T> getFromRowFunction(); static final long serialVersionUID; }
@Test public void testPrimitiveRowToProto() { ProtoDynamicMessageSchema schemaProvider = schemaFromDescriptor(Primitive.getDescriptor()); SerializableFunction<Row, DynamicMessage> fromRow = schemaProvider.getFromRowFunction(); assertEquals(PRIMITIVE_PROTO.toString(), fromRow.apply(PRIMITIVE_ROW).toString()); }
@Test public void testRepeatedRowToProto() { ProtoDynamicMessageSchema schemaProvider = schemaFromDescriptor(RepeatPrimitive.getDescriptor()); SerializableFunction<Row, DynamicMessage> fromRow = schemaProvider.getFromRowFunction(); assertEquals(REPEATED_PROTO.toString(), fromRow.apply(REPEATED_ROW).toString()); }
@Test public void testNullRepeatedRowToProto() { ProtoDynamicMessageSchema schemaProvider = schemaFromDescriptor(RepeatPrimitive.getDescriptor()); SerializableFunction<Row, DynamicMessage> fromRow = schemaProvider.getFromRowFunction(); assertEquals(NULL_REPEATED_PROTO.toString(), fromRow.apply(NULL_REPEATED_ROW).toString()); }
@Test public void testMapRowToProto() { ProtoDynamicMessageSchema schemaProvider = schemaFromDescriptor(MapPrimitive.getDescriptor()); SerializableFunction<Row, DynamicMessage> fromRow = schemaProvider.getFromRowFunction(); assertEquals(MAP_PRIMITIVE_PROTO.toString(), fromRow.apply(MAP_PRIMITIVE_ROW).toString()); }
@Test public void testNullMapRowToProto() { ProtoDynamicMessageSchema schemaProvider = schemaFromDescriptor(MapPrimitive.getDescriptor()); SerializableFunction<Row, DynamicMessage> fromRow = schemaProvider.getFromRowFunction(); assertEquals( NULL_MAP_PRIMITIVE_PROTO.toString(), fromRow.apply(NULL_MAP_PRIMITIVE_ROW).toString()); }
@Test public void testNestedRowToProto() throws InvalidProtocolBufferException { ProtoDynamicMessageSchema schemaProvider = schemaFromDescriptor(Nested.getDescriptor()); SerializableFunction<Row, DynamicMessage> fromRow = schemaProvider.getFromRowFunction(); assertEquals(NESTED_PROTO.toString(), fromRow.apply(NESTED_ROW).toString()); }
@Test public void testOneOfRowToProto() { ProtoDynamicMessageSchema schemaProvider = schemaFromDescriptor(OneOf.getDescriptor()); SerializableFunction<Row, DynamicMessage> fromRow = schemaProvider.getFromRowFunction(); assertEquals(ONEOF_PROTO_INT32.toString(), fromRow.apply(ONEOF_ROW_INT32).toString()); assertEquals(ONEOF_PROTO_BOOL.toString(), fromRow.apply(ONEOF_ROW_BOOL).toString()); assertEquals(ONEOF_PROTO_STRING.toString(), fromRow.apply(ONEOF_ROW_STRING).toString()); assertEquals(ONEOF_PROTO_PRIMITIVE.toString(), fromRow.apply(ONEOF_ROW_PRIMITIVE).toString()); }
@Test public void testOuterOneOfRowToProto() { ProtoDynamicMessageSchema schemaProvider = schemaFromDescriptor(OuterOneOf.getDescriptor()); SerializableFunction<Row, DynamicMessage> fromRow = schemaProvider.getFromRowFunction(); assertEquals(OUTER_ONEOF_PROTO.toString(), fromRow.apply(OUTER_ONEOF_ROW).toString()); }
@Test public void testEnumRowToProto() { ProtoDynamicMessageSchema schemaProvider = schemaFromDescriptor(EnumMessage.getDescriptor()); SerializableFunction<Row, DynamicMessage> fromRow = schemaProvider.getFromRowFunction(); assertEquals(ENUM_PROTO.toString(), fromRow.apply(ENUM_ROW).toString()); }
@Test public void testWktRowToProto() { ProtoDynamicMessageSchema schemaProvider = schemaFromDescriptor(WktMessage.getDescriptor()); SerializableFunction<Row, DynamicMessage> fromRow = schemaProvider.getFromRowFunction(); assertEquals(WKT_MESSAGE_PROTO.toString(), fromRow.apply(WKT_MESSAGE_ROW).toString()); }