@Test public void convert2Proto() { BranchReportResponse branchReportResponse = new BranchReportResponse(); branchReportResponse.setMsg("msg"); branchReportResponse.setResultCode(ResultCode.Failed); branchReportResponse.setTransactionExceptionCode(TransactionExceptionCode.GlobalTransactionNotExist); BranchReportResponseConvertor convertor = new BranchReportResponseConvertor(); BranchReportResponseProto proto = convertor.convert2Proto(branchReportResponse); BranchReportResponse real = convertor.convert2Model(proto); assertThat((real.getTypeCode())).isEqualTo(branchReportResponse.getTypeCode()); assertThat((real.getMsg())).isEqualTo(branchReportResponse.getMsg()); assertThat((real.getResultCode())).isEqualTo(branchReportResponse.getResultCode()); assertThat((real.getTransactionExceptionCode())).isEqualTo(branchReportResponse.getTransactionExceptionCode()); }
@Override public BranchReportResponseProto convert2Proto(BranchReportResponse branchReportResponse) { final short typeCode = branchReportResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = branchReportResponse.getMsg(); final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(branchReportResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); AbstractTransactionResponseProto abstractTransactionResponseProto = AbstractTransactionResponseProto .newBuilder().setAbstractResultMessage(abstractResultMessageProto) .setTransactionExceptionCode( TransactionExceptionCodeProto.valueOf(branchReportResponse.getTransactionExceptionCode().name())) .build(); BranchReportResponseProto result = BranchReportResponseProto.newBuilder() .setAbstractTransactionResponse(abstractTransactionResponseProto).build(); return result; }
BranchReportResponseConvertor implements PbConvertor<BranchReportResponse, BranchReportResponseProto> { @Override public BranchReportResponseProto convert2Proto(BranchReportResponse branchReportResponse) { final short typeCode = branchReportResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = branchReportResponse.getMsg(); final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(branchReportResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); AbstractTransactionResponseProto abstractTransactionResponseProto = AbstractTransactionResponseProto .newBuilder().setAbstractResultMessage(abstractResultMessageProto) .setTransactionExceptionCode( TransactionExceptionCodeProto.valueOf(branchReportResponse.getTransactionExceptionCode().name())) .build(); BranchReportResponseProto result = BranchReportResponseProto.newBuilder() .setAbstractTransactionResponse(abstractTransactionResponseProto).build(); return result; } }
BranchReportResponseConvertor implements PbConvertor<BranchReportResponse, BranchReportResponseProto> { @Override public BranchReportResponseProto convert2Proto(BranchReportResponse branchReportResponse) { final short typeCode = branchReportResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = branchReportResponse.getMsg(); final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(branchReportResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); AbstractTransactionResponseProto abstractTransactionResponseProto = AbstractTransactionResponseProto .newBuilder().setAbstractResultMessage(abstractResultMessageProto) .setTransactionExceptionCode( TransactionExceptionCodeProto.valueOf(branchReportResponse.getTransactionExceptionCode().name())) .build(); BranchReportResponseProto result = BranchReportResponseProto.newBuilder() .setAbstractTransactionResponse(abstractTransactionResponseProto).build(); return result; }  }
BranchReportResponseConvertor implements PbConvertor<BranchReportResponse, BranchReportResponseProto> { @Override public BranchReportResponseProto convert2Proto(BranchReportResponse branchReportResponse) { final short typeCode = branchReportResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = branchReportResponse.getMsg(); final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(branchReportResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); AbstractTransactionResponseProto abstractTransactionResponseProto = AbstractTransactionResponseProto .newBuilder().setAbstractResultMessage(abstractResultMessageProto) .setTransactionExceptionCode( TransactionExceptionCodeProto.valueOf(branchReportResponse.getTransactionExceptionCode().name())) .build(); BranchReportResponseProto result = BranchReportResponseProto.newBuilder() .setAbstractTransactionResponse(abstractTransactionResponseProto).build(); return result; }  @Override BranchReportResponseProto convert2Proto(BranchReportResponse branchReportResponse); @Override BranchReportResponse convert2Model(BranchReportResponseProto branchReportResponseProto); }
BranchReportResponseConvertor implements PbConvertor<BranchReportResponse, BranchReportResponseProto> { @Override public BranchReportResponseProto convert2Proto(BranchReportResponse branchReportResponse) { final short typeCode = branchReportResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = branchReportResponse.getMsg(); final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg) .setResultCode(ResultCodeProto.valueOf(branchReportResponse.getResultCode().name())).setAbstractMessage( abstractMessage).build(); AbstractTransactionResponseProto abstractTransactionResponseProto = AbstractTransactionResponseProto .newBuilder().setAbstractResultMessage(abstractResultMessageProto) .setTransactionExceptionCode( TransactionExceptionCodeProto.valueOf(branchReportResponse.getTransactionExceptionCode().name())) .build(); BranchReportResponseProto result = BranchReportResponseProto.newBuilder() .setAbstractTransactionResponse(abstractTransactionResponseProto).build(); return result; }  @Override BranchReportResponseProto convert2Proto(BranchReportResponse branchReportResponse); @Override BranchReportResponse convert2Model(BranchReportResponseProto branchReportResponseProto);  }