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