@Test
  public void testGetOneMetadata() throws Exception {
    //
    // Test 1: isVcr = false (already setup)
    //
    // Get for existing blob
    Response<BlobProperties> mockResponse = mock(Response.class);
    BlobProperties mockProperties = mock(BlobProperties.class);
    CloudBlobMetadata blobMetadata = new CloudBlobMetadata(blobId, 0, -1, 0, null);
    Map<String, String> propertyMap = blobMetadata.toMap();
    when(mockProperties.getMetadata()).thenReturn(propertyMap);
    when(mockResponse.getValue()).thenReturn(mockProperties);
    when(mockBlockBlobAsyncClient.getPropertiesWithResponse(any())).thenReturn(Mono.just(mockResponse));
    List<BlobId> singleBlobList = Collections.singletonList(blobId);
    Map<String, CloudBlobMetadata> metadataMap = azureDest.getBlobMetadata(singleBlobList);
    assertEquals("Expected map of one", 1, metadataMap.size());
    verifyZeroInteractions(mockCosmosAsyncContainer);
    verify(mockBlockBlobAsyncClient).getPropertiesWithResponse(any());

    // Get for nonexistent blob
    BlobStorageException ex = mockStorageException(BlobErrorCode.BLOB_NOT_FOUND);
    when(mockBlockBlobAsyncClient.getPropertiesWithResponse(any())).thenReturn(Mono.error(ex));
    metadataMap = azureDest.getBlobMetadata(singleBlobList);
    assertTrue("Expected empty map", metadataMap.isEmpty());
    verifyZeroInteractions(mockCosmosAsyncContainer);
    verify(mockBlockBlobAsyncClient, times(2)).getPropertiesWithResponse(any());

    //
    // Test 2: isVcr = true
    //
    azureDest.close();
    azureDest = new AzureCloudDestination(mockServiceAsyncClient, mockBlobBatchAsyncClient, mockCosmosAsyncClient,
        mockCosmosAsyncDatabase, mockCosmosAsyncContainer, "ambry", "metadata", "deletedContainer", clusterName,
        azureMetrics, defaultAzureReplicationFeedType, clusterMap, true, configProps);
    // Existing blob
    FeedResponse feedResponse = mock(FeedResponse.class);
    when(feedResponse.getResults()).thenReturn(Collections.singletonList(blobMetadata));
    CosmosPagedFlux cosmosPagedFlux = mock(CosmosPagedFlux.class);
    when(cosmosPagedFlux.byPage()).thenReturn(Flux.just(feedResponse));
    when(mockCosmosAsyncContainer.queryItems((SqlQuerySpec) any(), any(), any())).thenReturn(cosmosPagedFlux);
    metadataMap = azureDest.getBlobMetadata(singleBlobList);
    assertEquals("Expected map of one", 1, metadataMap.size());
    verify(mockBlockBlobAsyncClient, times(2)).getPropertiesWithResponse(any());
  }
Test to make sure that getting metadata for single blob calls ABS when not vcr and Cosmos when vcr.
ambry-cloud/src/test/java/com/github/ambry/cloud/azure/AzureCloudDestinationTest.java