@Test
  public void testPurgeWithCosmosBulkDeleteError() {
    CosmosException mockCosmosException = mock(CosmosException.class);
    when(mockCosmosException.getStatusCode()).thenReturn(HttpConstants.StatusCodes.TOO_MANY_REQUESTS);
    when(cosmosAsyncStoredProcedure.execute(any(), any())).thenReturn(Mono.error(mockCosmosException));
    try {
      AzureCompactionUtil.purgeBlobs(blobMetadataList, azureBlobDataAccessor, azureMetrics, cosmosDataAccessor);
      fail("Expected CloudStorageException");
    } catch (CloudStorageException bex) {
    }
    assertEquals(0, azureMetrics.blobDeletedCount.getCount());
    assertEquals(numBlobsPerQuery, azureMetrics.blobDeleteErrorCount.getCount());
  }
Test purgeBlobs with Cosmos bulk delete error
ambry-cloud/src/test/java/com/github/ambry/cloud/azure/AzureStorageCompactorTest.java