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