### Question:
BranchCommitRequestConvertor implements PbConvertor<BranchCommitRequest, BranchCommitRequestProto> { @Override public BranchCommitRequestProto convert2Proto(BranchCommitRequest branchCommitRequest) { final short typeCode = branchCommitRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto .newBuilder().setAbstractMessage(abstractMessage).build(); final String applicationData = branchCommitRequest.getApplicationData(); final AbstractBranchEndRequestProto abstractBranchEndRequestProto = AbstractBranchEndRequestProto.newBuilder(). setAbstractTransactionRequest(abstractTransactionRequestProto).setXid(branchCommitRequest.getXid()) .setBranchId(branchCommitRequest.getBranchId()).setBranchType( BranchTypeProto.valueOf(branchCommitRequest.getBranchType().name())).setApplicationData( applicationData == null ? "" : applicationData).setResourceId(branchCommitRequest.getResourceId()) .build(); BranchCommitRequestProto result = BranchCommitRequestProto.newBuilder().setAbstractBranchEndRequest( abstractBranchEndRequestProto).build(); return result; }  @Override BranchCommitRequestProto convert2Proto(BranchCommitRequest branchCommitRequest); @Override BranchCommitRequest convert2Model(BranchCommitRequestProto branchCommitRequestProto);  }### Answer:
@Test public void convert2Proto() { BranchCommitRequest branchCommitRequest = new BranchCommitRequest(); branchCommitRequest.setBranchType(BranchType.AT); branchCommitRequest.setXid("xid"); branchCommitRequest.setResourceId("resourceId"); branchCommitRequest.setBranchId(123); branchCommitRequest.setApplicationData("app"); BranchCommitRequestConvertor branchCommitRequestConvertor = new BranchCommitRequestConvertor(); BranchCommitRequestProto proto = branchCommitRequestConvertor.convert2Proto( branchCommitRequest); BranchCommitRequest realRequest = branchCommitRequestConvertor.convert2Model(proto); assertThat(realRequest.getTypeCode()).isEqualTo(branchCommitRequest.getTypeCode()); assertThat(realRequest.getBranchType()).isEqualTo(branchCommitRequest.getBranchType()); assertThat(realRequest.getXid()).isEqualTo(branchCommitRequest.getXid()); assertThat(realRequest.getResourceId()).isEqualTo(branchCommitRequest.getResourceId()); assertThat(realRequest.getBranchId()).isEqualTo(branchCommitRequest.getBranchId()); assertThat(realRequest.getApplicationData()).isEqualTo(branchCommitRequest.getApplicationData()); }