@Test public void convert2Proto() { GlobalCommitRequest globalCommitRequest = new GlobalCommitRequest(); globalCommitRequest.setExtraData("extraData"); globalCommitRequest.setXid("xid"); GlobalCommitRequestConvertor convertor = new GlobalCommitRequestConvertor(); GlobalCommitRequestProto proto = convertor.convert2Proto(globalCommitRequest); GlobalCommitRequest real = convertor.convert2Model(proto); assertThat((real.getTypeCode())).isEqualTo(globalCommitRequest.getTypeCode()); assertThat((real.getXid())).isEqualTo(globalCommitRequest.getXid()); assertThat((real.getExtraData())).isEqualTo(globalCommitRequest.getExtraData()); }
@Override public GlobalCommitRequestProto convert2Proto(GlobalCommitRequest globalCommitRequest) { final short typeCode = globalCommitRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto .newBuilder().setAbstractMessage( abstractMessage).build(); final String extraData = globalCommitRequest.getExtraData(); AbstractGlobalEndRequestProto abstractGlobalEndRequestProto = AbstractGlobalEndRequestProto.newBuilder() .setAbstractTransactionRequest(abstractTransactionRequestProto) .setXid(globalCommitRequest.getXid()) .setExtraData(extraData == null ? "" : extraData) .build(); GlobalCommitRequestProto result = GlobalCommitRequestProto.newBuilder().setAbstractGlobalEndRequest( abstractGlobalEndRequestProto).build(); return result; }
GlobalCommitRequestConvertor implements PbConvertor<GlobalCommitRequest, GlobalCommitRequestProto> { @Override public GlobalCommitRequestProto convert2Proto(GlobalCommitRequest globalCommitRequest) { final short typeCode = globalCommitRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto .newBuilder().setAbstractMessage( abstractMessage).build(); final String extraData = globalCommitRequest.getExtraData(); AbstractGlobalEndRequestProto abstractGlobalEndRequestProto = AbstractGlobalEndRequestProto.newBuilder() .setAbstractTransactionRequest(abstractTransactionRequestProto) .setXid(globalCommitRequest.getXid()) .setExtraData(extraData == null ? "" : extraData) .build(); GlobalCommitRequestProto result = GlobalCommitRequestProto.newBuilder().setAbstractGlobalEndRequest( abstractGlobalEndRequestProto).build(); return result; } }
GlobalCommitRequestConvertor implements PbConvertor<GlobalCommitRequest, GlobalCommitRequestProto> { @Override public GlobalCommitRequestProto convert2Proto(GlobalCommitRequest globalCommitRequest) { final short typeCode = globalCommitRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto .newBuilder().setAbstractMessage( abstractMessage).build(); final String extraData = globalCommitRequest.getExtraData(); AbstractGlobalEndRequestProto abstractGlobalEndRequestProto = AbstractGlobalEndRequestProto.newBuilder() .setAbstractTransactionRequest(abstractTransactionRequestProto) .setXid(globalCommitRequest.getXid()) .setExtraData(extraData == null ? "" : extraData) .build(); GlobalCommitRequestProto result = GlobalCommitRequestProto.newBuilder().setAbstractGlobalEndRequest( abstractGlobalEndRequestProto).build(); return result; }  }
GlobalCommitRequestConvertor implements PbConvertor<GlobalCommitRequest, GlobalCommitRequestProto> { @Override public GlobalCommitRequestProto convert2Proto(GlobalCommitRequest globalCommitRequest) { final short typeCode = globalCommitRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto .newBuilder().setAbstractMessage( abstractMessage).build(); final String extraData = globalCommitRequest.getExtraData(); AbstractGlobalEndRequestProto abstractGlobalEndRequestProto = AbstractGlobalEndRequestProto.newBuilder() .setAbstractTransactionRequest(abstractTransactionRequestProto) .setXid(globalCommitRequest.getXid()) .setExtraData(extraData == null ? "" : extraData) .build(); GlobalCommitRequestProto result = GlobalCommitRequestProto.newBuilder().setAbstractGlobalEndRequest( abstractGlobalEndRequestProto).build(); return result; }  @Override GlobalCommitRequestProto convert2Proto(GlobalCommitRequest globalCommitRequest); @Override GlobalCommitRequest convert2Model(GlobalCommitRequestProto globalCommitRequestProto); }
GlobalCommitRequestConvertor implements PbConvertor<GlobalCommitRequest, GlobalCommitRequestProto> { @Override public GlobalCommitRequestProto convert2Proto(GlobalCommitRequest globalCommitRequest) { final short typeCode = globalCommitRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto .newBuilder().setAbstractMessage( abstractMessage).build(); final String extraData = globalCommitRequest.getExtraData(); AbstractGlobalEndRequestProto abstractGlobalEndRequestProto = AbstractGlobalEndRequestProto.newBuilder() .setAbstractTransactionRequest(abstractTransactionRequestProto) .setXid(globalCommitRequest.getXid()) .setExtraData(extraData == null ? "" : extraData) .build(); GlobalCommitRequestProto result = GlobalCommitRequestProto.newBuilder().setAbstractGlobalEndRequest( abstractGlobalEndRequestProto).build(); return result; }  @Override GlobalCommitRequestProto convert2Proto(GlobalCommitRequest globalCommitRequest); @Override GlobalCommitRequest convert2Model(GlobalCommitRequestProto globalCommitRequestProto);  }