Package com.twitter.elephantbird.thrift.test

Examples of com.twitter.elephantbird.thrift.test.Person


    PhoneNumber ph = new PhoneNumber();
    ph.setNumber("415-555-5555");
    ph.setType(PhoneType.HOME);
    assertEquals("415-555-5555,HOME", toTuple(type, ph).toDelimitedString(","));

    Person person = new Person(new Name("bob", "jenkins"), 42, "foo@bar.com", Lists.newArrayList(ph));
    assertEquals("(bob,jenkins),42,foo@bar.com,{(415-555-5555,HOME)}", toTuple(type, person).toDelimitedString(","));

    // test Enum map
    TestPerson testPerson = new TestPerson(
                                  new TestName("bob", "jenkins"),
View Full Code Here


    phoneList.add(genPhoneNumber("789", PhoneType.WORK));
    return phoneList;
  }

  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;
  }
View Full Code Here

  @Test
  public void testNestedStructsWhenEnabled() throws DescriptorValidationException {
    ThriftToDynamicProto<Person> thriftToProto =
      new ThriftToDynamicProto<Person>(Person.class, true, false);
    Person person = genPerson();
    Message msg = thriftToProto.convert(person);
    assertEquals(person.id, Protobufs.getFieldByName(msg, "id"));
    assertEquals(person.email, Protobufs.getFieldByName(msg, "email"));
    compareName(person.name, (Message) Protobufs.getFieldByName(msg, "name"));
    comparePhoneNumbers(person.phones, (List) Protobufs.getFieldByName(msg, "phones"));
View Full Code Here

  @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"));
View Full Code Here

  }

  @Test
  public void testGetFieldTypeDescriptor() throws DescriptorValidationException {
    ThriftToDynamicProto<Person> converter = new ThriftToDynamicProto<Person>(Person.class);
    Person person = genPerson();
    Message msg = converter.convert(person);

    FieldDescriptor expectedFd = msg.getDescriptorForType().findFieldByName("email");
    FieldDescriptor actualFd = converter.getFieldDescriptor(Person.class, "email");
View Full Code Here

  }

  @Test
  public void testGetFileDescriptor() throws DescriptorValidationException {
    ThriftToDynamicProto<Person> converter = new ThriftToDynamicProto<Person>(Person.class);
    Person person = genPerson();
    Message msg = converter.convert(person);

    FileDescriptor expectedFd = msg.getDescriptorForType().getFile();
    FileDescriptor actualFd = converter.getFileDescriptor();
View Full Code Here

    return TF.newTupleNoCopy(Lists.newArrayList(values));
  }

  private static Person personMessage(String name, int id, String email, String phoneNumber,
      String phoneType) {
    return new Person(new Name(name, null), id, email, Lists.newArrayList(new PhoneNumber(
        phoneNumber).setType(PhoneType.valueOf(phoneType))));
  }
View Full Code Here

        new NonSpillableDataBag(Lists.<Tuple>newArrayList(tuple(phoneNumber, phoneType))));
  }

  @Test
  public void testPerson() {
    Person expected = personMessage("Joe", 1, null, "123-456-7890", "HOME");
    Person actual = PigToThrift.newInstance(Person.class).getThriftObject(
        personTuple("Joe", 1, null, "123-456-7890", "HOME"));
    assertNotNull(actual);
    assertEquals(expected, actual);
  }
View Full Code Here

TOP

Related Classes of com.twitter.elephantbird.thrift.test.Person

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.