@Test public void convert2Proto() { GlobalRollbackResponse globalRollbackResponse = new GlobalRollbackResponse(); globalRollbackResponse.setGlobalStatus(GlobalStatus.AsyncCommitting); globalRollbackResponse.setMsg("msg"); globalRollbackResponse.setResultCode(ResultCode.Failed); globalRollbackResponse.setTransactionExceptionCode(TransactionExceptionCode.BranchRegisterFailed); GlobalRollbackResponseConvertor convertor = new GlobalRollbackResponseConvertor(); GlobalRollbackResponseProto proto = convertor.convert2Proto( globalRollbackResponse); GlobalRollbackResponse real = convertor.convert2Model(proto); assertThat((real.getTypeCode())).isEqualTo(globalRollbackResponse.getTypeCode()); assertThat((real.getMsg())).isEqualTo(globalRollbackResponse.getMsg()); assertThat((real.getResultCode())).isEqualTo(globalRollbackResponse.getResultCode()); assertThat((real.getTransactionExceptionCode())).isEqualTo( globalRollbackResponse.getTransactionExceptionCode()); }
@Override public GlobalRollbackResponseProto convert2Proto(GlobalRollbackResponse globalRollbackResponse) { final short typeCode = globalRollbackResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = globalRollbackResponse.getMsg(); final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(globalRollbackResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); AbstractTransactionResponseProto abstractTransactionResponseProto = AbstractTransactionResponseProto .newBuilder().setAbstractResultMessage(abstractResultMessageProto) .setTransactionExceptionCode( TransactionExceptionCodeProto.valueOf(globalRollbackResponse.getTransactionExceptionCode().name())) .build(); AbstractGlobalEndResponseProto abstractGlobalEndResponseProto = AbstractGlobalEndResponseProto.newBuilder() .setAbstractTransactionResponse(abstractTransactionResponseProto) .setGlobalStatus(GlobalStatusProto.valueOf(globalRollbackResponse.getGlobalStatus().name())) .build(); GlobalRollbackResponseProto result = GlobalRollbackResponseProto.newBuilder().setAbstractGlobalEndResponse( abstractGlobalEndResponseProto).build(); return result; }
GlobalRollbackResponseConvertor implements PbConvertor<GlobalRollbackResponse, GlobalRollbackResponseProto> { @Override public GlobalRollbackResponseProto convert2Proto(GlobalRollbackResponse globalRollbackResponse) { final short typeCode = globalRollbackResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = globalRollbackResponse.getMsg(); final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(globalRollbackResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); AbstractTransactionResponseProto abstractTransactionResponseProto = AbstractTransactionResponseProto .newBuilder().setAbstractResultMessage(abstractResultMessageProto) .setTransactionExceptionCode( TransactionExceptionCodeProto.valueOf(globalRollbackResponse.getTransactionExceptionCode().name())) .build(); AbstractGlobalEndResponseProto abstractGlobalEndResponseProto = AbstractGlobalEndResponseProto.newBuilder() .setAbstractTransactionResponse(abstractTransactionResponseProto) .setGlobalStatus(GlobalStatusProto.valueOf(globalRollbackResponse.getGlobalStatus().name())) .build(); GlobalRollbackResponseProto result = GlobalRollbackResponseProto.newBuilder().setAbstractGlobalEndResponse( abstractGlobalEndResponseProto).build(); return result; } }
GlobalRollbackResponseConvertor implements PbConvertor<GlobalRollbackResponse, GlobalRollbackResponseProto> { @Override public GlobalRollbackResponseProto convert2Proto(GlobalRollbackResponse globalRollbackResponse) { final short typeCode = globalRollbackResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = globalRollbackResponse.getMsg(); final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(globalRollbackResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); AbstractTransactionResponseProto abstractTransactionResponseProto = AbstractTransactionResponseProto .newBuilder().setAbstractResultMessage(abstractResultMessageProto) .setTransactionExceptionCode( TransactionExceptionCodeProto.valueOf(globalRollbackResponse.getTransactionExceptionCode().name())) .build(); AbstractGlobalEndResponseProto abstractGlobalEndResponseProto = AbstractGlobalEndResponseProto.newBuilder() .setAbstractTransactionResponse(abstractTransactionResponseProto) .setGlobalStatus(GlobalStatusProto.valueOf(globalRollbackResponse.getGlobalStatus().name())) .build(); GlobalRollbackResponseProto result = GlobalRollbackResponseProto.newBuilder().setAbstractGlobalEndResponse( abstractGlobalEndResponseProto).build(); return result; }  }
GlobalRollbackResponseConvertor implements PbConvertor<GlobalRollbackResponse, GlobalRollbackResponseProto> { @Override public GlobalRollbackResponseProto convert2Proto(GlobalRollbackResponse globalRollbackResponse) { final short typeCode = globalRollbackResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = globalRollbackResponse.getMsg(); final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(globalRollbackResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); AbstractTransactionResponseProto abstractTransactionResponseProto = AbstractTransactionResponseProto .newBuilder().setAbstractResultMessage(abstractResultMessageProto) .setTransactionExceptionCode( TransactionExceptionCodeProto.valueOf(globalRollbackResponse.getTransactionExceptionCode().name())) .build(); AbstractGlobalEndResponseProto abstractGlobalEndResponseProto = AbstractGlobalEndResponseProto.newBuilder() .setAbstractTransactionResponse(abstractTransactionResponseProto) .setGlobalStatus(GlobalStatusProto.valueOf(globalRollbackResponse.getGlobalStatus().name())) .build(); GlobalRollbackResponseProto result = GlobalRollbackResponseProto.newBuilder().setAbstractGlobalEndResponse( abstractGlobalEndResponseProto).build(); return result; }  @Override GlobalRollbackResponseProto convert2Proto(GlobalRollbackResponse globalRollbackResponse); @Override GlobalRollbackResponse convert2Model(GlobalRollbackResponseProto globalRollbackResponseProto); }
GlobalRollbackResponseConvertor implements PbConvertor<GlobalRollbackResponse, GlobalRollbackResponseProto> { @Override public GlobalRollbackResponseProto convert2Proto(GlobalRollbackResponse globalRollbackResponse) { final short typeCode = globalRollbackResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = globalRollbackResponse.getMsg(); final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(globalRollbackResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); AbstractTransactionResponseProto abstractTransactionResponseProto = AbstractTransactionResponseProto .newBuilder().setAbstractResultMessage(abstractResultMessageProto) .setTransactionExceptionCode( TransactionExceptionCodeProto.valueOf(globalRollbackResponse.getTransactionExceptionCode().name())) .build(); AbstractGlobalEndResponseProto abstractGlobalEndResponseProto = AbstractGlobalEndResponseProto.newBuilder() .setAbstractTransactionResponse(abstractTransactionResponseProto) .setGlobalStatus(GlobalStatusProto.valueOf(globalRollbackResponse.getGlobalStatus().name())) .build(); GlobalRollbackResponseProto result = GlobalRollbackResponseProto.newBuilder().setAbstractGlobalEndResponse( abstractGlobalEndResponseProto).build(); return result; }  @Override GlobalRollbackResponseProto convert2Proto(GlobalRollbackResponse globalRollbackResponse); @Override GlobalRollbackResponse convert2Model(GlobalRollbackResponseProto globalRollbackResponseProto);  }