### Question:
OMVolumeSetOwnerResponse extends OMClientResponse { @Override protected void addToDBBatch(OMMetadataManager omMetadataManager, BatchOperation batchOperation) throws IOException { String oldOwnerKey = omMetadataManager.getUserKey(oldOwner); String newOwnerKey = omMetadataManager.getUserKey(newOwnerVolumeArgs.getOwnerName()); if (oldOwnerVolumeList.getVolumeNamesList().size() == 0) { omMetadataManager.getUserTable().deleteWithBatch(batchOperation, oldOwnerKey); } else { omMetadataManager.getUserTable().putWithBatch(batchOperation, oldOwnerKey, oldOwnerVolumeList); } omMetadataManager.getUserTable().putWithBatch(batchOperation, newOwnerKey, newOwnerVolumeList); String dbVolumeKey = omMetadataManager.getVolumeKey(newOwnerVolumeArgs.getVolume()); omMetadataManager.getVolumeTable().putWithBatch(batchOperation, dbVolumeKey, newOwnerVolumeArgs); } OMVolumeSetOwnerResponse(@Nonnull OMResponse omResponse,
      @Nonnull String oldOwner, @Nonnull UserVolumeInfo oldOwnerVolumeList,
      @Nonnull UserVolumeInfo newOwnerVolumeList,
      @Nonnull OmVolumeArgs newOwnerVolumeArgs);  OMVolumeSetOwnerResponse(@Nonnull OMResponse omResponse); @Override void checkAndUpdateDB(OMMetadataManager omMetadataManager,
      BatchOperation batchOperation);  }### Answer:
@Test public void testAddToDBBatch() throws Exception { String volumeName = UUID.randomUUID().toString(); String oldOwner = "user1"; UserVolumeInfo volumeList = UserVolumeInfo.newBuilder() .setObjectID(1) .setUpdateID(1) .addVolumeNames(volumeName).build(); OMResponse omResponse = OMResponse.newBuilder() .setCmdType(OzoneManagerProtocolProtos.Type.SetVolumeProperty) .setStatus(OzoneManagerProtocolProtos.Status.OK) .setSuccess(true) .setCreateVolumeResponse(CreateVolumeResponse.getDefaultInstance()) .build(); OmVolumeArgs omVolumeArgs = OmVolumeArgs.newBuilder() .setOwnerName(oldOwner).setAdminName(oldOwner) .setVolume(volumeName).setCreationTime(Time.now()).build(); OMVolumeCreateResponse omVolumeCreateResponse = new OMVolumeCreateResponse(omResponse, omVolumeArgs, volumeList); String newOwner = "user2"; UserVolumeInfo newOwnerVolumeList = UserVolumeInfo.newBuilder() .setObjectID(1) .setUpdateID(1) .addVolumeNames(volumeName).build(); UserVolumeInfo oldOwnerVolumeList = UserVolumeInfo.newBuilder() .setObjectID(2) .setUpdateID(2) .build(); OmVolumeArgs newOwnerVolumeArgs = OmVolumeArgs.newBuilder() .setOwnerName(newOwner).setAdminName(newOwner) .setVolume(volumeName).setCreationTime(omVolumeArgs.getCreationTime()) .build(); OMVolumeSetOwnerResponse omVolumeSetOwnerResponse = new OMVolumeSetOwnerResponse(omResponse, oldOwner, oldOwnerVolumeList, newOwnerVolumeList, newOwnerVolumeArgs); omVolumeCreateResponse.addToDBBatch(omMetadataManager, batchOperation); omVolumeSetOwnerResponse.addToDBBatch(omMetadataManager, batchOperation); omMetadataManager.getStore().commitBatchOperation(batchOperation); Assert.assertEquals(1, omMetadataManager.countRowsInTable(omMetadataManager.getVolumeTable())); Table.KeyValue<String, OmVolumeArgs> keyValue = omMetadataManager.getVolumeTable().iterator().next(); Assert.assertEquals(omMetadataManager.getVolumeKey(volumeName), keyValue.getKey()); Assert.assertEquals(newOwnerVolumeArgs, keyValue.getValue()); Assert.assertEquals(volumeList, omMetadataManager.getUserTable().get( omMetadataManager.getUserKey(newOwner))); }