private void testQueryMetadata(int numBlobs, int expectedQueries) throws Exception {
    // Reset metrics
    azureMetrics = new AzureMetrics(new MetricRegistry());
    try {
      azureDest = new AzureCloudDestination(mockServiceAsyncClient, mockBlobBatchAsyncClient, mockCosmosAsyncClient,
          mockCosmosAsyncDatabase, mockCosmosAsyncContainer, "ambry", "metadata", "deletedContainer", clusterName,
          azureMetrics, defaultAzureReplicationFeedType, clusterMap, false, configProps);
      List<BlobId> blobIdList = new ArrayList<>();
      List<CloudBlobMetadata> cloudBlobMetadataList = new ArrayList<>();
      for (int j = 0; j < numBlobs; j++) {
        BlobId blobId = generateBlobId();
        blobIdList.add(blobId);
        CloudBlobMetadata inputMetadata = new CloudBlobMetadata(blobId, creationTime, Utils.Infinite_Time, blobSize,
            CloudBlobMetadata.EncryptionOrigin.NONE);
        cloudBlobMetadataList.add(inputMetadata);
      }

      FeedResponse feedResponse = mock(FeedResponse.class);
      when(feedResponse.getResults()).thenReturn(cloudBlobMetadataList);
      CosmosPagedFlux cosmosPagedFlux = mock(CosmosPagedFlux.class);
      when(cosmosPagedFlux.byPage()).thenReturn(Flux.just(feedResponse));
      when(mockCosmosAsyncContainer.queryItems((SqlQuerySpec) any(), any(), any())).thenReturn(cosmosPagedFlux);

      Set<BlobId> blobIdSet = new HashSet<>(blobIdList);
      assertEquals(blobIdList.size(), blobIdSet.size());
      Map<String, CloudBlobMetadata> metadataMap = azureDest.getBlobMetadata(blobIdList);
      for (BlobId blobId : blobIdList) {
        assertEquals("Unexpected id in metadata", blobId.getID(), metadataMap.get(blobId.getID()).getId());
      }
      assertEquals(expectedQueries, azureMetrics.documentQueryCount.getCount());
      assertEquals(expectedQueries, azureMetrics.missingKeysQueryTime.getCount());
    } finally {
      azureDest.close();
    }
  }
Test metadata query for different input count.
@param numBlobs the number of blobs to query.
@param expectedQueries the number of internal queries made after batching.
@throws Exception
ambry-cloud/src/test/java/com/github/ambry/cloud/azure/AzureCloudDestinationTest.java