GlobalBeginRequestConvertor implements PbConvertor<GlobalBeginRequest, GlobalBeginRequestProto> { @Override public GlobalBeginRequestProto convert2Proto(GlobalBeginRequest globalBeginRequest) { final short typeCode = globalBeginRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto .newBuilder().setAbstractMessage( abstractMessage).build(); GlobalBeginRequestProto result = GlobalBeginRequestProto.newBuilder() .setTimeout(globalBeginRequest.getTimeout()) .setTransactionName(globalBeginRequest.getTransactionName()) .setAbstractTransactionRequest(abstractTransactionRequestProto) .build(); return result; }  @Override GlobalBeginRequestProto convert2Proto(GlobalBeginRequest globalBeginRequest); @Override GlobalBeginRequest convert2Model(GlobalBeginRequestProto globalBeginRequestProto);  }
@Test public void convert2Proto() { GlobalBeginRequest globalBeginRequest = new GlobalBeginRequest(); globalBeginRequest.setTimeout(3000); globalBeginRequest.setTransactionName("taa"); GlobalBeginRequestConvertor convertor = new GlobalBeginRequestConvertor(); GlobalBeginRequestProto proto = convertor.convert2Proto(globalBeginRequest); GlobalBeginRequest real = convertor.convert2Model(proto); assertThat(real.getTypeCode()).isEqualTo(globalBeginRequest.getTypeCode()); assertThat(real.getTimeout()).isEqualTo(globalBeginRequest.getTimeout()); assertThat(real.getTransactionName()).isEqualTo(globalBeginRequest.getTransactionName()); }