Package com.twitter.elephantbird.thrift.test

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


    assertEquals("(31337,)-(1,0,35,27000,16777216,6000000000,3.141592653589793,JSON THIS! \",,0,,{(1),(2),(3)},{(1),(2),(3)},{(1),(2),(3)})",
        toTuple(type, n2).toDelimitedString("-"));

    // test enum.
    ThriftToPig.setConversionProperties(new Configuration(false));
    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(","));
View Full Code Here


  }

  @SuppressWarnings({ "rawtypes", "unchecked" })
  @Test
  public void testSetConversionProperties() throws ExecException {
    PhoneNumber pn = new PhoneNumber();
    pn.setNumber("1234");
    pn.setType(PhoneType.HOME);

    ThriftToPig ttp = ThriftToPig.newInstance(PhoneNumber.class);
    Tuple tuple = ttp.getPigTuple(pn);
    assertEquals(DataType.CHARARRAY, tuple.getType(1));
    assertEquals(PhoneType.HOME.toString(), tuple.get(1));
View Full Code Here

  @Rule
  public ExpectedException exception = ExpectedException.none();

  private PhoneNumber genPhoneNumber(String number, PhoneType type) {
    PhoneNumber phoneNumber = new PhoneNumber(number);
    phoneNumber.setType(type);
    return phoneNumber;
  }
View Full Code Here

  private void comparePhoneNumbers(List<PhoneNumber> expected, List<?> actual) {
    assertNotNull(actual);
    assertEquals(expected.size(), actual.size());
    for (int i = 0; i < expected.size(); i++) {
      PhoneNumber number = expected.get(i);
      Message msg = (Message) actual.get(i);
      assertEquals(number.number, Protobufs.getFieldByName(msg, "number"));
      assertEquals(number.type.toString(), Protobufs.getFieldByName(msg, "type"));
    }
  }
View Full Code Here

    assertEquals(expectedLongs.size(), 0);
  }

  @Test
  public void testSimpleStructConversion() throws DescriptorValidationException {
    PhoneNumber thriftPhone = genPhoneNumber("123-34-5467", PhoneType.HOME);
    ThriftToDynamicProto<PhoneNumber> thriftToProto = new ThriftToDynamicProto<PhoneNumber>(PhoneNumber.class);
    Message msg = thriftToProto.convert(thriftPhone);
    assertEquals(thriftPhone.number, Protobufs.getFieldByName(msg, "number"));
    assertEquals(thriftPhone.type.toString(), Protobufs.getFieldByName(msg, "type"));
  }
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

TOP

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

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.