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