### Question:
OMKeysDeleteResponse extends OMClientResponse { public void checkAndUpdateDB(OMMetadataManager omMetadataManager, BatchOperation batchOperation) throws IOException { if (getOMResponse().getStatus() == OK || getOMResponse().getStatus() == PARTIAL_DELETE) { addToDBBatch(omMetadataManager, batchOperation); } } OMKeysDeleteResponse(@Nonnull OMResponse omResponse,
      @Nonnull List<OmKeyInfo> keyDeleteList, long trxnLogIndex,
      boolean isRatisEnabled, @Nonnull OmVolumeArgs omVolumeArgs,
      @Nonnull OmBucketInfo omBucketInfo);  OMKeysDeleteResponse(@Nonnull OMResponse omResponse); void checkAndUpdateDB(OMMetadataManager omMetadataManager,
      BatchOperation batchOperation); @Override void addToDBBatch(OMMetadataManager omMetadataManager,
                           BatchOperation batchOperation);  }### Answer:
@Test public void testKeysDeleteResponse() throws Exception { createPreRequisities(); OMResponse omResponse = OMResponse.newBuilder().setCmdType(DeleteKeys).setStatus(OK) .setSuccess(true) .setDeleteKeysResponse(DeleteKeysResponse.newBuilder() .setStatus(true)).build(); OmVolumeArgs omVolumeArgs = OmVolumeArgs.newBuilder() .setOwnerName(keyName).setAdminName(keyName) .setVolume(volumeName).setCreationTime(Time.now()).build(); OmBucketInfo omBucketInfo = OmBucketInfo.newBuilder() .setVolumeName(volumeName).setBucketName(bucketName) .setCreationTime(Time.now()).build(); OMClientResponse omKeysDeleteResponse = new OMKeysDeleteResponse( omResponse, omKeyInfoList, 10L, true, omVolumeArgs, omBucketInfo); omKeysDeleteResponse.checkAndUpdateDB(omMetadataManager, batchOperation); omMetadataManager.getStore().commitBatchOperation(batchOperation); for (String ozKey : ozoneKeys) { Assert.assertNull(omMetadataManager.getKeyTable().get(ozKey)); RepeatedOmKeyInfo repeatedOmKeyInfo = omMetadataManager.getDeletedTable().get(ozKey); Assert.assertNotNull(repeatedOmKeyInfo); Assert.assertEquals(1, repeatedOmKeyInfo.getOmKeyInfoList().size()); Assert.assertEquals(10L, repeatedOmKeyInfo.getOmKeyInfoList().get(0).getUpdateID()); } }
@Test public void testKeysDeleteResponseFail() throws Exception { createPreRequisities(); OMResponse omResponse = OMResponse.newBuilder().setCmdType(DeleteKeys).setStatus(KEY_NOT_FOUND) .setSuccess(false) .setDeleteKeysResponse(DeleteKeysResponse.newBuilder() .setStatus(false)).build(); OmVolumeArgs omVolumeArgs = OmVolumeArgs.newBuilder() .setOwnerName(keyName).setAdminName(keyName) .setVolume(volumeName).setCreationTime(Time.now()).build(); OmBucketInfo omBucketInfo = OmBucketInfo.newBuilder() .setVolumeName(volumeName).setBucketName(bucketName) .setCreationTime(Time.now()).build(); OMClientResponse omKeysDeleteResponse = new OMKeysDeleteResponse( omResponse, omKeyInfoList, 10L, true, omVolumeArgs, omBucketInfo); omKeysDeleteResponse.checkAndUpdateDB(omMetadataManager, batchOperation); for (String ozKey : ozoneKeys) { Assert.assertNotNull(omMetadataManager.getKeyTable().get(ozKey)); RepeatedOmKeyInfo repeatedOmKeyInfo = omMetadataManager.getDeletedTable().get(ozKey); Assert.assertNull(repeatedOmKeyInfo); } }