### Question:
BranchCommitResponseConvertor implements PbConvertor<BranchCommitResponse, BranchCommitResponseProto> { @Override public BranchCommitResponseProto convert2Proto(BranchCommitResponse branchCommitResponse) { final short typeCode = branchCommitResponse.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final String msg = branchCommitResponse.getMsg(); final AbstractResultMessageProto abstractResultMessageProto = AbstractResultMessageProto.newBuilder().setMsg( msg == null ? "" : msg).setResultCode(ResultCodeProto.valueOf(branchCommitResponse.getResultCode().name())) .setAbstractMessage(abstractMessage).build(); final AbstractTransactionResponseProto abstractTransactionRequestProto = AbstractTransactionResponseProto .newBuilder().setAbstractResultMessage(abstractResultMessageProto).setTransactionExceptionCode( TransactionExceptionCodeProto.valueOf(branchCommitResponse.getTransactionExceptionCode().name())) .build(); final AbstractBranchEndResponseProto abstractBranchEndResponse = AbstractBranchEndResponseProto.newBuilder(). setAbstractTransactionResponse(abstractTransactionRequestProto).setXid(branchCommitResponse.getXid()) .setBranchId(branchCommitResponse.getBranchId()).setBranchStatus( BranchStatusProto.forNumber(branchCommitResponse.getBranchStatus().getCode())).build(); BranchCommitResponseProto result = BranchCommitResponseProto.newBuilder().setAbstractBranchEndResponse( abstractBranchEndResponse).build(); return result; }  @Override BranchCommitResponseProto convert2Proto(BranchCommitResponse branchCommitResponse); @Override BranchCommitResponse convert2Model(BranchCommitResponseProto branchCommitResponseProto);  }### Answer:
@Test public void convert2Proto() { BranchCommitResponse branchCommitResponse = new BranchCommitResponse(); branchCommitResponse.setTransactionExceptionCode(TransactionExceptionCode.BranchTransactionNotExist); branchCommitResponse.setResultCode(ResultCode.Success); branchCommitResponse.setMsg("xx"); branchCommitResponse.setXid("xid"); branchCommitResponse.setBranchStatus(BranchStatus.PhaseTwo_Rollbacked); branchCommitResponse.setBranchId(123); BranchCommitResponseConvertor convertor = new BranchCommitResponseConvertor(); BranchCommitResponseProto proto = convertor.convert2Proto(branchCommitResponse); BranchCommitResponse real = convertor.convert2Model(proto); assertThat(real.getTypeCode()).isEqualTo(branchCommitResponse.getTypeCode()); assertThat(real.getMsg()).isEqualTo(branchCommitResponse.getMsg()); assertThat(real.getXid()).isEqualTo(branchCommitResponse.getXid()); assertThat(real.getTransactionExceptionCode()).isEqualTo(branchCommitResponse.getTransactionExceptionCode()); assertThat(real.getBranchStatus()).isEqualTo(branchCommitResponse.getBranchStatus()); assertThat(real.getResultCode()).isEqualTo(branchCommitResponse.getResultCode()); }