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