github-advanced-security[bot] commented on code in PR #15287:
URL: https://github.com/apache/druid/pull/15287#discussion_r1394502069


##########
extensions-core/azure-extensions/src/test/java/org/apache/druid/storage/azure/AzureStorageTest.java:
##########
@@ -19,53 +19,91 @@
 
 package org.apache.druid.storage.azure;
 
+import com.azure.core.http.rest.PagedIterable;
+import com.azure.core.http.rest.PagedResponse;
+import com.azure.storage.blob.BlobContainerClient;
+import com.azure.storage.blob.BlobServiceClient;
+import com.azure.storage.blob.models.BlobItem;
+import com.azure.storage.blob.models.BlobItemProperties;
+import com.azure.storage.blob.models.BlobStorageException;
 import com.google.common.collect.ImmutableList;
-import com.microsoft.azure.storage.StorageException;
-import com.microsoft.azure.storage.blob.CloudBlobClient;
-import com.microsoft.azure.storage.blob.CloudBlobContainer;
-import com.microsoft.azure.storage.blob.CloudBlockBlob;
-import com.microsoft.azure.storage.blob.ListBlobItem;
+import org.apache.druid.common.guava.SettableSupplier;
+import org.easymock.EasyMock;
+import org.easymock.EasyMockRunner;
+import org.easymock.EasyMockSupport;
+import org.easymock.Mock;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.List;
 
-public class AzureStorageTest
+@RunWith(EasyMockRunner.class)
+public class AzureStorageTest extends EasyMockSupport
 {
 
   AzureStorage azureStorage;
-  CloudBlobClient cloudBlobClient = Mockito.mock(CloudBlobClient.class);
-  CloudBlobContainer cloudBlobContainer = 
Mockito.mock(CloudBlobContainer.class);
+  BlobServiceClient blobServiceClient = Mockito.mock(BlobServiceClient.class);
+  BlobContainerClient blobContainerClient = 
Mockito.mock(BlobContainerClient.class);
+
+  @Mock
+  AzureClientFactory azureClientFactory;
 
   @Before
-  public void setup() throws URISyntaxException, StorageException
+  public void setup() throws BlobStorageException
   {
-    
Mockito.doReturn(cloudBlobContainer).when(cloudBlobClient).getContainerReference(ArgumentMatchers.anyString());
-    azureStorage = new AzureStorage(() -> cloudBlobClient);
+    
Mockito.doReturn(blobContainerClient).when(blobServiceClient).createBlobContainerIfNotExists(ArgumentMatchers.anyString());
+    azureStorage = new AzureStorage(() -> blobServiceClient, 
azureClientFactory);
   }
 
   @Test
-  public void testListDir() throws URISyntaxException, StorageException
+  public void testListDir() throws BlobStorageException
   {
-    List<ListBlobItem> listBlobItems = ImmutableList.of(
-        new CloudBlockBlob(new URI("azure://dummy.com/container/blobName"))
-    );
-
-    Mockito.doReturn(listBlobItems).when(cloudBlobContainer).listBlobs(
-        ArgumentMatchers.anyString(),
-        ArgumentMatchers.anyBoolean(),
-        ArgumentMatchers.any(),
+    BlobItem blobItem = new BlobItem().setName("blobName").setProperties(new 
BlobItemProperties().setContentLength(10L));
+    SettableSupplier<PagedResponse<BlobItem>> supplier = new 
SettableSupplier<>();
+    supplier.set(new TestPagedResponse<>(ImmutableList.of(blobItem)));
+    PagedIterable<BlobItem> pagedIterable = new PagedIterable<>(supplier);
+    Mockito.doReturn(pagedIterable).when(blobContainerClient).listBlobs(
         ArgumentMatchers.any(),
         ArgumentMatchers.any()
 
     );
+    EasyMock.expect(azureClientFactory.getBlobContainerClient("test", 
null)).andReturn(blobContainerClient).times(1);
+
+    replayAll();
     Assert.assertEquals(ImmutableList.of("blobName"), 
azureStorage.listDir("test", ""));
+    verifyAll();
+  }
+
+  @Test
+  public void testListDir_withMaxAttempts_factoryCreatesNewContainerClient() 
throws BlobStorageException
+  {
+    Integer maxAttempts = 5;

Review Comment:
   ## Boxed variable is never null
   
   The variable 'maxAttempts' is only assigned values of primitive type and is 
never 'null', but it is declared with the boxed type 'Integer'.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/5979)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to