### Question:
BranchRegisterRequestConvertor implements PbConvertor<BranchRegisterRequest, BranchRegisterRequestProto> { @Override public BranchRegisterRequestProto convert2Proto(BranchRegisterRequest branchRegisterRequest) { final short typeCode = branchRegisterRequest.getTypeCode(); final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType( MessageTypeProto.forNumber(typeCode)).build(); final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto .newBuilder().setAbstractMessage(abstractMessage).build(); final String applicationData = branchRegisterRequest.getApplicationData(); final String resourceId = branchRegisterRequest.getResourceId(); final String lockKey = branchRegisterRequest.getLockKey(); BranchRegisterRequestProto result = BranchRegisterRequestProto.newBuilder().setAbstractTransactionRequest( abstractTransactionRequestProto).setApplicationData(applicationData == null ? "" : applicationData) .setBranchType(BranchTypeProto.valueOf(branchRegisterRequest.getBranchType().name())).setLockKey( lockKey == null ? "" : lockKey).setResourceId(resourceId == null ? "" : resourceId).setXid( branchRegisterRequest.getXid()).build(); return result; }  @Override BranchRegisterRequestProto convert2Proto(BranchRegisterRequest branchRegisterRequest); @Override BranchRegisterRequest convert2Model(BranchRegisterRequestProto branchRegisterRequestProto);  }### Answer:
@Test public void convert2Proto() { BranchRegisterRequest branchRegisterRequest = new BranchRegisterRequest(); branchRegisterRequest.setApplicationData("data"); branchRegisterRequest.setBranchType(BranchType.AT); branchRegisterRequest.setLockKey("localKey"); branchRegisterRequest.setResourceId("resourceId"); branchRegisterRequest.setXid("xid"); BranchRegisterRequestConvertor convertor = new BranchRegisterRequestConvertor(); BranchRegisterRequestProto proto = convertor.convert2Proto( branchRegisterRequest); BranchRegisterRequest real = convertor.convert2Model(proto); assertThat(real.getTypeCode()).isEqualTo(branchRegisterRequest.getTypeCode()); assertThat(real.getApplicationData()).isEqualTo(branchRegisterRequest.getApplicationData()); assertThat(real.getXid()).isEqualTo(branchRegisterRequest.getXid()); assertThat(real.getBranchType()).isEqualTo(branchRegisterRequest.getBranchType()); assertThat(real.getLockKey()).isEqualTo(branchRegisterRequest.getLockKey()); assertThat(real.getResourceId()).isEqualTo(branchRegisterRequest.getResourceId()); }