@Test public void convert2Proto() { RegisterTMRequest registerRMRequest = new RegisterTMRequest(); registerRMRequest.setVersion("123"); registerRMRequest.setTransactionServiceGroup("group"); registerRMRequest.setExtraData("extraData"); registerRMRequest.setApplicationId("appId"); RegisterTMRequestConvertor convertor = new RegisterTMRequestConvertor(); RegisterTMRequestProto proto = convertor.convert2Proto(registerRMRequest); RegisterTMRequest real = convertor.convert2Model(proto); assertThat((real.getTypeCode())).isEqualTo(registerRMRequest.getTypeCode()); assertThat((real.getVersion())).isEqualTo(registerRMRequest.getVersion()); assertThat((real.getTransactionServiceGroup())).isEqualTo(registerRMRequest.getTransactionServiceGroup()); assertThat((real.getExtraData())).isEqualTo(registerRMRequest.getExtraData()); assertThat((real.getApplicationId())).isEqualTo(registerRMRequest.getApplicationId()); }
@Override public RegisterTMRequestProto convert2Proto(RegisterTMRequest registerTMRequest) { final short typeCode = registerTMRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String extraData = registerTMRequest.getExtraData(); AbstractIdentifyRequestProto abstractIdentifyRequestProto = AbstractIdentifyRequestProto.newBuilder() .setAbstractMessage(abstractMessage) .setApplicationId(registerTMRequest.getApplicationId()) .setExtraData(extraData==null?"":extraData) .setTransactionServiceGroup(registerTMRequest.getTransactionServiceGroup()) .setVersion(registerTMRequest.getVersion()) .build(); RegisterTMRequestProto result = RegisterTMRequestProto.newBuilder().setAbstractIdentifyRequest( abstractIdentifyRequestProto).build(); return result; }
RegisterTMRequestConvertor implements PbConvertor<RegisterTMRequest, RegisterTMRequestProto> { @Override public RegisterTMRequestProto convert2Proto(RegisterTMRequest registerTMRequest) { final short typeCode = registerTMRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String extraData = registerTMRequest.getExtraData(); AbstractIdentifyRequestProto abstractIdentifyRequestProto = AbstractIdentifyRequestProto.newBuilder() .setAbstractMessage(abstractMessage) .setApplicationId(registerTMRequest.getApplicationId()) .setExtraData(extraData==null?"":extraData) .setTransactionServiceGroup(registerTMRequest.getTransactionServiceGroup()) .setVersion(registerTMRequest.getVersion()) .build(); RegisterTMRequestProto result = RegisterTMRequestProto.newBuilder().setAbstractIdentifyRequest( abstractIdentifyRequestProto).build(); return result; } }
RegisterTMRequestConvertor implements PbConvertor<RegisterTMRequest, RegisterTMRequestProto> { @Override public RegisterTMRequestProto convert2Proto(RegisterTMRequest registerTMRequest) { final short typeCode = registerTMRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String extraData = registerTMRequest.getExtraData(); AbstractIdentifyRequestProto abstractIdentifyRequestProto = AbstractIdentifyRequestProto.newBuilder() .setAbstractMessage(abstractMessage) .setApplicationId(registerTMRequest.getApplicationId()) .setExtraData(extraData==null?"":extraData) .setTransactionServiceGroup(registerTMRequest.getTransactionServiceGroup()) .setVersion(registerTMRequest.getVersion()) .build(); RegisterTMRequestProto result = RegisterTMRequestProto.newBuilder().setAbstractIdentifyRequest( abstractIdentifyRequestProto).build(); return result; }  }
RegisterTMRequestConvertor implements PbConvertor<RegisterTMRequest, RegisterTMRequestProto> { @Override public RegisterTMRequestProto convert2Proto(RegisterTMRequest registerTMRequest) { final short typeCode = registerTMRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String extraData = registerTMRequest.getExtraData(); AbstractIdentifyRequestProto abstractIdentifyRequestProto = AbstractIdentifyRequestProto.newBuilder() .setAbstractMessage(abstractMessage) .setApplicationId(registerTMRequest.getApplicationId()) .setExtraData(extraData==null?"":extraData) .setTransactionServiceGroup(registerTMRequest.getTransactionServiceGroup()) .setVersion(registerTMRequest.getVersion()) .build(); RegisterTMRequestProto result = RegisterTMRequestProto.newBuilder().setAbstractIdentifyRequest( abstractIdentifyRequestProto).build(); return result; }  @Override RegisterTMRequestProto convert2Proto(RegisterTMRequest registerTMRequest); @Override RegisterTMRequest convert2Model(RegisterTMRequestProto registerTMRequestProto); }
RegisterTMRequestConvertor implements PbConvertor<RegisterTMRequest, RegisterTMRequestProto> { @Override public RegisterTMRequestProto convert2Proto(RegisterTMRequest registerTMRequest) { final short typeCode = registerTMRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String extraData = registerTMRequest.getExtraData(); AbstractIdentifyRequestProto abstractIdentifyRequestProto = AbstractIdentifyRequestProto.newBuilder() .setAbstractMessage(abstractMessage) .setApplicationId(registerTMRequest.getApplicationId()) .setExtraData(extraData==null?"":extraData) .setTransactionServiceGroup(registerTMRequest.getTransactionServiceGroup()) .setVersion(registerTMRequest.getVersion()) .build(); RegisterTMRequestProto result = RegisterTMRequestProto.newBuilder().setAbstractIdentifyRequest( abstractIdentifyRequestProto).build(); return result; }  @Override RegisterTMRequestProto convert2Proto(RegisterTMRequest registerTMRequest); @Override RegisterTMRequest convert2Model(RegisterTMRequestProto registerTMRequestProto);  }