Search in sources :

Example 6 with Person

use of com.twitter.elephantbird.thrift.test.Person in project elephant-bird by twitter.

the class TestThriftToDynamicProto method genPerson.

private Person genPerson() {
    Person person = new Person();
    person.setName(new Name("Johnny", "Appleseed"));
    person.setId(123);
    person.setEmail("email@address.com");
    person.setPhones(genPhoneList());
    return person;
}
Also used : Person(com.twitter.elephantbird.thrift.test.Person) Name(com.twitter.elephantbird.thrift.test.Name)

Example 7 with Person

use of com.twitter.elephantbird.thrift.test.Person in project elephant-bird by twitter.

the class TestThriftToDynamicProto method testNestedStructsWhenDisabled.

@Test
public void testNestedStructsWhenDisabled() throws DescriptorValidationException {
    ThriftToDynamicProto<Person> thriftToProto = new ThriftToDynamicProto<Person>(Person.class);
    Person person = genPerson();
    Message msg = thriftToProto.convert(person);
    assertEquals(person.id, Protobufs.getFieldByName(msg, "id"));
    assertEquals(person.email, Protobufs.getFieldByName(msg, "email"));
    // nested structs not converted
    assertTrue(!Protobufs.hasFieldByName(msg, "name"));
    assertTrue(!Protobufs.hasFieldByName(msg, "phones"));
}
Also used : Message(com.google.protobuf.Message) Person(com.twitter.elephantbird.thrift.test.Person) Test(org.junit.Test)

Aggregations

Person (com.twitter.elephantbird.thrift.test.Person)7 Test (org.junit.Test)5 Message (com.google.protobuf.Message)4 Name (com.twitter.elephantbird.thrift.test.Name)2 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)1 FileDescriptor (com.google.protobuf.Descriptors.FileDescriptor)1 MapKeyTest (com.twitter.elephantbird.pig.test.thrift.MapKeyTest)1 PhoneNumber (com.twitter.elephantbird.thrift.test.PhoneNumber)1 TestName (com.twitter.elephantbird.thrift.test.TestName)1 TestPerson (com.twitter.elephantbird.thrift.test.TestPerson)1 TestUnion (com.twitter.elephantbird.thrift.test.TestUnion)1 Configuration (org.apache.hadoop.conf.Configuration)1 HolyMoley (thrift.test.HolyMoley)1 Nesting (thrift.test.Nesting)1 OneOfEach (thrift.test.OneOfEach)1