ThriftToProto { public ThriftToProto(T thriftObj, P protoObj) { protoBuilder_ = Protobufs.getMessageBuilder(protoObj.getClass()); protoObj_ = protoObj; } ThriftToProto(T thriftObj, P protoObj); static ThriftToProto<T, P> newInstance(T thriftObj, P protoObj); @SuppressWarnings("unchecked") P convert(T thriftObj);  }
@Test public void testThriftToProto() throws TException, IOException { OneOfEach ooe = Fixtures.oneOfEach; ThriftToProto<OneOfEach, ThriftFixtures.OneOfEach> thriftToProto = ThriftToProto.newInstance(ooe, ThriftFixtures.OneOfEach.newBuilder().build()); ThriftFixtures.OneOfEach proto = thriftToProto.convert(ooe); assertEquals(ooe.im_true, proto.getImTrue()); assertEquals(ooe.im_false, proto.getImFalse()); assertEquals(ooe.a_bite, proto.getABite()); assertEquals(ooe.integer16, proto.getInteger16()); assertEquals(ooe.integer32, proto.getInteger32()); assertEquals(ooe.integer64, proto.getInteger64()); assertEquals(ooe.double_precision, proto.getDoublePrecision(), 0.00001); assertEquals(ooe.some_characters, proto.getSomeCharacters()); assertEquals(ooe.zomg_unicode, proto.getZomgUnicode()); assertEquals(ooe.what_who, proto.getWhatWho()); assertEquals(new String(ooe.getBase64(), "UTF-8"), proto.getBase64().toStringUtf8()); }