PigToProtobuf { @SuppressWarnings("unchecked") public static <M extends Message> M tupleToMessage(Class<M> protoClass, Tuple tuple) { Builder builder = Protobufs.getMessageBuilder(protoClass); return (M) tupleToMessage(builder, tuple); } PigToProtobuf(); @SuppressWarnings("unchecked") static M tupleToMessage(Class<M> protoClass, Tuple tuple); static Message tupleToMessage(Builder builder, Tuple tuple); static Message tupleToMessage(Builder builder, List<FieldDescriptor> fieldDescriptors, Tuple tuple); static Descriptor schemaToProtoDescriptor(ResourceSchema schema); static Descriptor schemaToProtoDescriptor(ResourceSchema schema, List<Pair<String, Type>> extraFields);  }
@Test public void testPerson() { Person expected = personMessage("Joe", 1, null, "123-456-7890", "HOME"); Person actual = PigToProtobuf.tupleToMessage(Person.class, personTuple("Joe", 1, null, "123-456-7890", "HOME")); Assert.assertNotNull(actual); Assert.assertEquals(expected, actual); }
@Test(expected = RuntimeException.class) public void testPersonBadEnumValue() { PigToProtobuf.tupleToMessage(Person.class, personTuple("Joe", 1, null, "123-456-7890", "ASDF")); }