From de4a89ffd30d23667d28e3c3b5b068e87a4f2d06 Mon Sep 17 00:00:00 2001 From: Aman Verma Date: Wed, 26 Aug 2020 16:51:47 +0530 Subject: [PATCH 1/9] changing method signature to add container name --- .../osdu/azure/blobstorage/BlobStore.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java b/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java index cf88d09a..8f795771 100644 --- a/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java +++ b/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java @@ -41,19 +41,19 @@ import java.util.Collections;; * * String readFromBlobExample() * { - * String content = blobStorage.readFromBlob("dataPartitionId", "filePath"); + * String content = blobStorage.readFromBlob("dataPartitionId", "filePath", "containerName"); * if (content != null) * return content; * } * * void writeToBlobExample() * { - * blobStorage.writeToBlob("dataPartitionId", "filePath", "content"); + * blobStorage.writeToBlob("dataPartitionId", "filePath", "content", "containerName"); * } * * void deleteFromBlobExample() * { - * Boolean success = blobStorage.deleteFromBlob("dataPartitionId", "filePath"); + * Boolean success = blobStorage.deleteFromBlob("dataPartitionId", "filePath", "containerName"); * } * } * @@ -75,9 +75,13 @@ public class BlobStore { * * @param filePath Path of file to be read. * @param dataPartitionId Data partition id + * @param containerName Name of the storage container * @return the content of file with provided file path. */ - public String readFromBlob(final String dataPartitionId, final String filePath) { + public String readFromBlob( + final String dataPartitionId, + final String filePath, + final String containerName) { BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId); BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(filePath).getBlockBlobClient(); try (ByteArrayOutputStream downloadStream = new ByteArrayOutputStream()) { @@ -108,9 +112,13 @@ public class BlobStore { * * @param filePath Path of file to be deleted. * @param dataPartitionId Data partition id + * @param containerName Name of the storage container * @return boolean indicating whether the deletion of given file was successful or not. */ - public boolean deleteFromBlob(final String dataPartitionId, final String filePath) { + public boolean deleteFromBlob( + final String dataPartitionId, + final String filePath, + final String containerName) { BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId); BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(filePath).getBlockBlobClient(); try { @@ -134,10 +142,13 @@ public class BlobStore { * @param filePath Path of file to be written at. * @param content Content to be written in the file. * @param dataPartitionId Data partition id + * @param containerName Name of the storage container */ - public void writeToBlob(final String dataPartitionId, - final String filePath, - final String content) { + public void writeToBlob( + final String dataPartitionId, + final String filePath, + final String content, + final String containerName) { byte[] bytes = content.getBytes(StandardCharsets.UTF_8); int bytesSize = bytes.length; BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId); -- GitLab From 1fb047420135ff15e503a3e60686e0902ea1df9e Mon Sep 17 00:00:00 2001 From: Aman Verma Date: Wed, 26 Aug 2020 16:56:59 +0530 Subject: [PATCH 2/9] updating UTs --- .../osdu/azure/blobstorage/BlobStoreTest.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobStoreTest.java b/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobStoreTest.java index 453367ae..592cdf16 100644 --- a/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobStoreTest.java +++ b/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobStoreTest.java @@ -44,6 +44,7 @@ public class BlobStoreTest { private static final String PARTITION_ID = "dataPartitionId"; private static final String FILE_PATH = "filePath"; private static final String CONTENT = "hello world"; + private static final String STORAGE_CONTAINER_NAME = "containerName"; @InjectMocks BlobStore blobStore; @@ -80,7 +81,7 @@ public class BlobStoreTest { { doThrow(AppException.class).when(blobContainerClientFactory).getClient(eq(PARTITION_ID)); try { - String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH); + String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -91,7 +92,7 @@ public class BlobStoreTest { @Test public void readFromBlob_Success() { - String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH); + String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); ArgumentCaptor outputStream = ArgumentCaptor.forClass(ByteArrayOutputStream.class); // validate that the download method is being invoked appropriately. @@ -104,7 +105,7 @@ public class BlobStoreTest { BlobStorageException exception = mockStorageException(BlobErrorCode.BLOB_NOT_FOUND); doThrow(exception).when(blockBlobClient).download(any()); try { - String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH); + String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(404, ex.getError().getCode()); } catch (Exception ex) { @@ -118,7 +119,7 @@ public class BlobStoreTest { BlobStorageException exception = mockStorageException(BlobErrorCode.INTERNAL_ERROR); doThrow(exception).when(blockBlobClient).download(any()); try { - String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH); + String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -131,7 +132,7 @@ public class BlobStoreTest { { doThrow(AppException.class).when(blobContainerClientFactory).getClient(eq(PARTITION_ID)); try { - blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH); + blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -145,7 +146,7 @@ public class BlobStoreTest { BlobStorageException exception = mockStorageException(BlobErrorCode.BLOB_NOT_FOUND); doThrow(exception).when(blockBlobClient).delete(); try { - blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH); + blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(404, ex.getError().getCode()); } catch (Exception ex) { @@ -159,7 +160,7 @@ public class BlobStoreTest { BlobStorageException exception = mockStorageException(BlobErrorCode.INTERNAL_ERROR); doThrow(exception).when(blockBlobClient).delete(); try { - blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH); + blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -172,7 +173,7 @@ public class BlobStoreTest { { doNothing().when(blockBlobClient).delete(); try { - blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH); + blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (Exception ex) { fail("should not get any exception."); } @@ -183,7 +184,7 @@ public class BlobStoreTest { { doThrow(AppException.class).when(blobContainerClientFactory).getClient(eq(PARTITION_ID)); try { - blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT); + blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -197,7 +198,7 @@ public class BlobStoreTest { BlobStorageException exception = mockStorageException(BlobErrorCode.INTERNAL_ERROR); doThrow(exception).when(blockBlobClient).upload(any(), anyLong(), eq(true)); try { - blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT); + blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -210,7 +211,7 @@ public class BlobStoreTest { { doReturn(blockBlobItem).when(blockBlobClient).upload(any(), anyLong(), eq(true)); try { - blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT); + blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT, STORAGE_CONTAINER_NAME); } catch (Exception ex) { fail("should not get any exception."); } -- GitLab From e869a98c70f0ba5d30648c9d7954673dcd8e0dd2 Mon Sep 17 00:00:00 2001 From: Aman Verma Date: Wed, 26 Aug 2020 18:01:58 +0530 Subject: [PATCH 3/9] updating UTs to use the blobServiceCleintFactory --- .../osdu/azure/blobstorage/BlobStore.java | 17 ++++++---- .../osdu/azure/blobstorage/BlobStoreTest.java | 32 +++++++++++++++---- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java b/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java index 8f795771..e9211f59 100644 --- a/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java +++ b/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java @@ -15,6 +15,7 @@ package org.opengroup.osdu.azure.blobstorage; import com.azure.storage.blob.BlobContainerClient; +import com.azure.storage.blob.BlobServiceClient; import com.azure.storage.blob.models.BlobErrorCode; import com.azure.storage.blob.models.BlobStorageException; import com.azure.storage.blob.specialized.BlockBlobClient; @@ -64,7 +65,7 @@ import java.util.Collections;; public class BlobStore { @Autowired - private IBlobContainerClientFactory blobContainerClientFactory; + private IBlobServiceClientFactory blobServiceClientFactory; @Autowired private ILogger logger; @@ -82,7 +83,7 @@ public class BlobStore { final String dataPartitionId, final String filePath, final String containerName) { - BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId); + BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId, containerName); BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(filePath).getBlockBlobClient(); try (ByteArrayOutputStream downloadStream = new ByteArrayOutputStream()) { blockBlobClient.download(downloadStream); @@ -119,7 +120,7 @@ public class BlobStore { final String dataPartitionId, final String filePath, final String containerName) { - BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId); + BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId, containerName); BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(filePath).getBlockBlobClient(); try { blockBlobClient.delete(); @@ -151,7 +152,7 @@ public class BlobStore { final String containerName) { byte[] bytes = content.getBytes(StandardCharsets.UTF_8); int bytesSize = bytes.length; - BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId); + BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId, containerName); BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(filePath).getBlockBlobClient(); try (ByteArrayInputStream dataStream = new ByteArrayInputStream(bytes)) { blockBlobClient.upload(dataStream, bytesSize, true); @@ -168,12 +169,14 @@ public class BlobStore { /** * - * @param dataPartitionId Data partition id + * @param dataPartitionId Data partition id. + * @param containerName Name of storage container. * @return blob container client corresponding to the dataPartitionId. */ - private BlobContainerClient getBlobContainerClient(final String dataPartitionId) { + private BlobContainerClient getBlobContainerClient(final String dataPartitionId, final String containerName) { try { - return blobContainerClientFactory.getClient(dataPartitionId); + BlobServiceClient serviceClient = blobServiceClientFactory.getBlobServiceClient(dataPartitionId); + return serviceClient.getBlobContainerClient(containerName); } catch (Exception ex) { String errorMessage = "Error creating creating blob container client."; logger.warning(LOG_PREFIX, errorMessage, Collections.emptyMap()); diff --git a/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobStoreTest.java b/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobStoreTest.java index 592cdf16..d15afc7d 100644 --- a/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobStoreTest.java +++ b/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobStoreTest.java @@ -16,6 +16,7 @@ package org.opengroup.osdu.azure.blobstorage; import com.azure.storage.blob.BlobClient; import com.azure.storage.blob.BlobContainerClient; +import com.azure.storage.blob.BlobServiceClient; import com.azure.storage.blob.models.BlobErrorCode; import com.azure.storage.blob.models.BlobStorageException; import com.azure.storage.blob.models.BlockBlobItem; @@ -50,7 +51,10 @@ public class BlobStoreTest { BlobStore blobStore; @Mock - IBlobContainerClientFactory blobContainerClientFactory; + IBlobServiceClientFactory blobServiceClientFactory; + + @Mock + BlobServiceClient blobServiceClient; @Mock BlobContainerClient blobContainerClient; @@ -70,16 +74,30 @@ public class BlobStoreTest { @BeforeEach void init() { initMocks(this); - lenient().doReturn(blobContainerClient).when(blobContainerClientFactory).getClient(PARTITION_ID); - lenient().doReturn(blobClient).when(blobContainerClient).getBlobClient(FILE_PATH); - lenient().doReturn(blockBlobClient).when(blobClient).getBlockBlobClient(); + lenient().when(blobClient.getBlockBlobClient()).thenReturn(blockBlobClient); + lenient().when(blobContainerClient.getBlobClient(FILE_PATH)).thenReturn(blobClient); + lenient().when(blobServiceClient.getBlobContainerClient(STORAGE_CONTAINER_NAME)).thenReturn(blobContainerClient); + lenient().when(blobServiceClientFactory.getBlobServiceClient(PARTITION_ID)).thenReturn(blobServiceClient); lenient().doNothing().when(logger).warning(eq("azure-core-lib"), any(), anyMap()); } @Test public void readFromBlob_ErrorCreatingBlobContainerClient() { - doThrow(AppException.class).when(blobContainerClientFactory).getClient(eq(PARTITION_ID)); + doThrow(AppException.class).when(blobServiceClientFactory).getBlobServiceClient(eq(PARTITION_ID)); + try { + String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); + } catch (AppException ex) { + assertEquals(500, ex.getError().getCode()); + } catch (Exception ex) { + fail("should not get different error code"); + } + } + + @Test + public void readFromBlob_ErrorCreatingBlobContainerClient_FromServiceClient() + { + doThrow(AppException.class).when(blobServiceClient).getBlobContainerClient(eq(STORAGE_CONTAINER_NAME)); try { String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { @@ -130,7 +148,7 @@ public class BlobStoreTest { @Test public void deleteFromBlob_ErrorCreatingBlobContainerClient() { - doThrow(AppException.class).when(blobContainerClientFactory).getClient(eq(PARTITION_ID)); + doThrow(AppException.class).when(blobServiceClientFactory).getBlobServiceClient(eq(PARTITION_ID)); try { blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { @@ -182,7 +200,7 @@ public class BlobStoreTest { @Test public void writeToBlob_ErrorCreatingBlobContainerClient() { - doThrow(AppException.class).when(blobContainerClientFactory).getClient(eq(PARTITION_ID)); + doThrow(AppException.class).when(blobServiceClientFactory).getBlobServiceClient(eq(PARTITION_ID)); try { blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT, STORAGE_CONTAINER_NAME); } catch (AppException ex) { -- GitLab From 0816c8268bdc8a9090adf51a442a92c7f9ea2c83 Mon Sep 17 00:00:00 2001 From: Aman Verma Date: Wed, 26 Aug 2020 18:02:39 +0530 Subject: [PATCH 4/9] updating the artifact version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f91cd79f..955c93f1 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.opengroup.osdu core-lib-azure jar - 0.0.21 + 0.0.22 core-lib-azure -- GitLab From d18bb60a1bb06a6d6957af9dfe7afb66e435b56a Mon Sep 17 00:00:00 2001 From: Aman Verma Date: Fri, 28 Aug 2020 13:14:49 +0530 Subject: [PATCH 5/9] adding equivalent methods instead of replacing existing ones --- .../osdu/azure/blobstorage/BlobStore.java | 134 +++++++++++- .../osdu/azure/blobstorage/BlobStoreTest.java | 191 +++++++++++++++--- 2 files changed, 295 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java b/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java index e9211f59..fb2748f3 100644 --- a/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java +++ b/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java @@ -42,19 +42,36 @@ import java.util.Collections;; * * String readFromBlobExample() * { - * String content = blobStorage.readFromBlob("dataPartitionId", "filePath", "containerName"); + * String content = blobStorage.readFromBlob("dataPartitionId", "filePath"); * if (content != null) * return content; * } * * void writeToBlobExample() * { - * blobStorage.writeToBlob("dataPartitionId", "filePath", "content", "containerName"); + * blobStorage.writeToBlob("dataPartitionId", "filePath", "content"); * } * * void deleteFromBlobExample() * { - * Boolean success = blobStorage.deleteFromBlob("dataPartitionId", "filePath", "containerName"); + * Boolean success = blobStorage.deleteFromBlob("dataPartitionId", "filePath"); + * } + * + * String readFromStorageContainerExamole() + * { + * String content = blobStorage.readFromStorageContainer("dataPartitionId", "filePath", "containerName"); + * if (content != null) + * return content; + * } + * + * void writeToStorageContainerExample() + * { + * blobStorage.writeToStorageContainer("dataPartitionId", "filePath", "content", "containerName"); + * } + * + * void deleteFromStorageContainerExample() + * { + * Boolean success = blobStorage.deleteFromStorageContainer("dataPartitionId", "filePath", "containerName"); * } * } * @@ -64,6 +81,9 @@ import java.util.Collections;; @Lazy public class BlobStore { + @Autowired + private IBlobContainerClientFactory blobContainerClientFactory; + @Autowired private IBlobServiceClientFactory blobServiceClientFactory; @@ -72,6 +92,90 @@ public class BlobStore { private static final String LOG_PREFIX = "azure-core-lib"; + /** + * + * @param filePath Path of file to be read. + * @param dataPartitionId Data partition id + * @return the content of file with provided file path. + */ + public String readFromBlob(final String dataPartitionId, final String filePath) { + BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId); + BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(filePath).getBlockBlobClient(); + try (ByteArrayOutputStream downloadStream = new ByteArrayOutputStream()) { + blockBlobClient.download(downloadStream); + return downloadStream.toString(StandardCharsets.UTF_8.name()); + } catch (BlobStorageException ex) { + if (ex.getErrorCode().equals(BlobErrorCode.BLOB_NOT_FOUND)) { + String errorMessage = "Specified blob was not found"; + logger.warning(LOG_PREFIX, errorMessage, Collections.emptyMap()); + throw new AppException(404, errorMessage, ex.getMessage(), ex); + } else { + String errorMessage = "Failed to read specified blob"; + logger.warning(LOG_PREFIX, errorMessage, Collections.emptyMap()); + throw new AppException(500, errorMessage, ex.getMessage(), ex); + } + } catch (UnsupportedEncodingException ex) { + String errorMessage = String.format("Encoding was not correct for item with name=%s", filePath); + logger.warning(LOG_PREFIX, errorMessage, Collections.emptyMap()); + throw new AppException(400, errorMessage, ex.getMessage(), ex); + } catch (IOException ex) { + String errorMessage = String.format("Malformed document for item with name=%s", filePath); + logger.warning(LOG_PREFIX, errorMessage, Collections.emptyMap()); + throw new AppException(500, errorMessage, ex.getMessage(), ex); + } + } + + /** + * + * @param filePath Path of file to be deleted. + * @param dataPartitionId Data partition id + * @return boolean indicating whether the deletion of given file was successful or not. + */ + public boolean deleteFromBlob(final String dataPartitionId, final String filePath) { + BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId); + BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(filePath).getBlockBlobClient(); + try { + blockBlobClient.delete(); + return true; + } catch (BlobStorageException ex) { + if (ex.getErrorCode().equals(BlobErrorCode.BLOB_NOT_FOUND)) { + String errorMessage = "Specified blob was not found"; + logger.warning(LOG_PREFIX, errorMessage, Collections.emptyMap()); + throw new AppException(404, errorMessage, ex.getMessage(), ex); + } else { + String errorMessage = "Failed to delete blob"; + logger.warning(LOG_PREFIX, errorMessage, Collections.emptyMap()); + throw new AppException(500, errorMessage, ex.getMessage(), ex); + } + } + } + + /** + * + * @param filePath Path of file to be written at. + * @param content Content to be written in the file. + * @param dataPartitionId Data partition id + */ + public void writeToBlob(final String dataPartitionId, + final String filePath, + final String content) { + byte[] bytes = content.getBytes(StandardCharsets.UTF_8); + int bytesSize = bytes.length; + BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId); + BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(filePath).getBlockBlobClient(); + try (ByteArrayInputStream dataStream = new ByteArrayInputStream(bytes)) { + blockBlobClient.upload(dataStream, bytesSize, true); + } catch (BlobStorageException ex) { + String errorMessage = "Failed to upload file content."; + logger.warning(LOG_PREFIX, errorMessage, Collections.emptyMap()); + throw new AppException(500, errorMessage, ex.getMessage(), ex); + } catch (IOException ex) { + String errorMessage = String.format("Malformed document for item with name=%s", filePath); + logger.warning(LOG_PREFIX, errorMessage, Collections.emptyMap()); + throw new AppException(500, errorMessage, ex.getMessage(), ex); + } + } + /** * * @param filePath Path of file to be read. @@ -79,7 +183,7 @@ public class BlobStore { * @param containerName Name of the storage container * @return the content of file with provided file path. */ - public String readFromBlob( + public String readFromStorageContainer( final String dataPartitionId, final String filePath, final String containerName) { @@ -116,7 +220,7 @@ public class BlobStore { * @param containerName Name of the storage container * @return boolean indicating whether the deletion of given file was successful or not. */ - public boolean deleteFromBlob( + public boolean deleteFromStorageContainer( final String dataPartitionId, final String filePath, final String containerName) { @@ -145,7 +249,7 @@ public class BlobStore { * @param dataPartitionId Data partition id * @param containerName Name of the storage container */ - public void writeToBlob( + public void writeToStorageContainer( final String dataPartitionId, final String filePath, final String content, @@ -167,6 +271,22 @@ public class BlobStore { } } + + /** + * + * @param dataPartitionId Data partition id + * @return blob container client corresponding to the dataPartitionId. + */ + private BlobContainerClient getBlobContainerClient(final String dataPartitionId) { + try { + return blobContainerClientFactory.getClient(dataPartitionId); + } catch (Exception ex) { + String errorMessage = "Error creating creating blob container client."; + logger.warning(LOG_PREFIX, errorMessage, Collections.emptyMap()); + throw new AppException(500, errorMessage, ex.getMessage(), ex); + } + } + /** * * @param dataPartitionId Data partition id. @@ -183,5 +303,5 @@ public class BlobStore { throw new AppException(500, errorMessage, ex.getMessage(), ex); } } -} +} diff --git a/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobStoreTest.java b/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobStoreTest.java index d15afc7d..b7c1f53c 100644 --- a/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobStoreTest.java +++ b/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobStoreTest.java @@ -50,6 +50,9 @@ public class BlobStoreTest { @InjectMocks BlobStore blobStore; + @Mock + IBlobContainerClientFactory blobContainerClientFactory; + @Mock IBlobServiceClientFactory blobServiceClientFactory; @@ -78,15 +81,157 @@ public class BlobStoreTest { lenient().when(blobContainerClient.getBlobClient(FILE_PATH)).thenReturn(blobClient); lenient().when(blobServiceClient.getBlobContainerClient(STORAGE_CONTAINER_NAME)).thenReturn(blobContainerClient); lenient().when(blobServiceClientFactory.getBlobServiceClient(PARTITION_ID)).thenReturn(blobServiceClient); + lenient().when(blobContainerClientFactory.getClient(PARTITION_ID)).thenReturn(blobContainerClient); lenient().doNothing().when(logger).warning(eq("azure-core-lib"), any(), anyMap()); } @Test public void readFromBlob_ErrorCreatingBlobContainerClient() + { + doThrow(AppException.class).when(blobContainerClientFactory).getClient(eq(PARTITION_ID)); + try { + String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH); + } catch (AppException ex) { + assertEquals(500, ex.getError().getCode()); + } catch (Exception ex) { + fail("should not get different error code"); + } + } + + @Test + public void readFromBlob_Success() + { + String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH); + ArgumentCaptor outputStream = ArgumentCaptor.forClass(ByteArrayOutputStream.class); + + // validate that the download method is being invoked appropriately. + verify(blockBlobClient).download(outputStream.capture()); + } + + @Test + public void readFromBlob_BlobNotFound() + { + BlobStorageException exception = mockStorageException(BlobErrorCode.BLOB_NOT_FOUND); + doThrow(exception).when(blockBlobClient).download(any()); + try { + String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH); + } catch (AppException ex) { + assertEquals(404, ex.getError().getCode()); + } catch (Exception ex) { + fail("should not get different error code"); + } + } + + @Test + public void readFromBlob_InternalError() + { + BlobStorageException exception = mockStorageException(BlobErrorCode.INTERNAL_ERROR); + doThrow(exception).when(blockBlobClient).download(any()); + try { + String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH); + } catch (AppException ex) { + assertEquals(500, ex.getError().getCode()); + } catch (Exception ex) { + fail("should not get different error code"); + } + } + + @Test + public void deleteFromBlob_ErrorCreatingBlobContainerClient() + { + doThrow(AppException.class).when(blobContainerClientFactory).getClient(eq(PARTITION_ID)); + try { + blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH); + } catch (AppException ex) { + assertEquals(500, ex.getError().getCode()); + } catch (Exception ex) { + fail("should not get different error code"); + } + } + + @Test + public void deleteFromBlob_BlobNotFound() + { + BlobStorageException exception = mockStorageException(BlobErrorCode.BLOB_NOT_FOUND); + doThrow(exception).when(blockBlobClient).delete(); + try { + blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH); + } catch (AppException ex) { + assertEquals(404, ex.getError().getCode()); + } catch (Exception ex) { + fail("should not get different error code"); + } + } + + @Test + public void deleteFromBlob_InternalError() + { + BlobStorageException exception = mockStorageException(BlobErrorCode.INTERNAL_ERROR); + doThrow(exception).when(blockBlobClient).delete(); + try { + blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH); + } catch (AppException ex) { + assertEquals(500, ex.getError().getCode()); + } catch (Exception ex) { + fail("should not get different error code"); + } + } + + @Test + public void deleteFromBlob_Success() + { + doNothing().when(blockBlobClient).delete(); + try { + blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH); + } catch (Exception ex) { + fail("should not get any exception."); + } + } + + @Test + public void writeToBlob_ErrorCreatingBlobContainerClient() + { + doThrow(AppException.class).when(blobContainerClientFactory).getClient(eq(PARTITION_ID)); + try { + blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT); + } catch (AppException ex) { + assertEquals(500, ex.getError().getCode()); + } catch (Exception ex) { + fail("should not get different error code"); + } + } + + @Test + public void writeToBlob_InternalError() + { + BlobStorageException exception = mockStorageException(BlobErrorCode.INTERNAL_ERROR); + doThrow(exception).when(blockBlobClient).upload(any(), anyLong(), eq(true)); + try { + blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT); + } catch (AppException ex) { + assertEquals(500, ex.getError().getCode()); + } catch (Exception ex) { + fail("should not get different error code"); + } + } + + @Test + public void writeToBlob_Success() + { + doReturn(blockBlobItem).when(blockBlobClient).upload(any(), anyLong(), eq(true)); + try { + blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT); + } catch (Exception ex) { + fail("should not get any exception."); + } + } + + @Test + public void readFromStorageContainer_ErrorCreatingBlobContainerClient() { doThrow(AppException.class).when(blobServiceClientFactory).getBlobServiceClient(eq(PARTITION_ID)); try { - String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); + String content = blobStore.readFromStorageContainer(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -95,11 +240,11 @@ public class BlobStoreTest { } @Test - public void readFromBlob_ErrorCreatingBlobContainerClient_FromServiceClient() + public void readFromStorageContainer_ErrorCreatingBlobContainerClient_FromServiceClient() { doThrow(AppException.class).when(blobServiceClient).getBlobContainerClient(eq(STORAGE_CONTAINER_NAME)); try { - String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); + String content = blobStore.readFromStorageContainer(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -108,9 +253,9 @@ public class BlobStoreTest { } @Test - public void readFromBlob_Success() + public void readFromStorageContainer_Success() { - String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); + String content = blobStore.readFromStorageContainer(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); ArgumentCaptor outputStream = ArgumentCaptor.forClass(ByteArrayOutputStream.class); // validate that the download method is being invoked appropriately. @@ -118,12 +263,12 @@ public class BlobStoreTest { } @Test - public void readFromBlob_BlobNotFound() + public void readFromStorageContainer_BlobNotFound() { BlobStorageException exception = mockStorageException(BlobErrorCode.BLOB_NOT_FOUND); doThrow(exception).when(blockBlobClient).download(any()); try { - String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); + String content = blobStore.readFromStorageContainer(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(404, ex.getError().getCode()); } catch (Exception ex) { @@ -132,12 +277,12 @@ public class BlobStoreTest { } @Test - public void readFromBlob_InternalError() + public void readFromStorageContainer_InternalError() { BlobStorageException exception = mockStorageException(BlobErrorCode.INTERNAL_ERROR); doThrow(exception).when(blockBlobClient).download(any()); try { - String content = blobStore.readFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); + String content = blobStore.readFromStorageContainer(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -146,11 +291,11 @@ public class BlobStoreTest { } @Test - public void deleteFromBlob_ErrorCreatingBlobContainerClient() + public void deleteFromStorageContainer_ErrorCreatingBlobContainerClient() { doThrow(AppException.class).when(blobServiceClientFactory).getBlobServiceClient(eq(PARTITION_ID)); try { - blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); + blobStore.deleteFromStorageContainer(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -159,12 +304,12 @@ public class BlobStoreTest { } @Test - public void deleteFromBlob_BlobNotFound() + public void deleteFromStorageContainer_BlobNotFound() { BlobStorageException exception = mockStorageException(BlobErrorCode.BLOB_NOT_FOUND); doThrow(exception).when(blockBlobClient).delete(); try { - blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); + blobStore.deleteFromStorageContainer(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(404, ex.getError().getCode()); } catch (Exception ex) { @@ -173,12 +318,12 @@ public class BlobStoreTest { } @Test - public void deleteFromBlob_InternalError() + public void deleteFromStorageContainer_InternalError() { BlobStorageException exception = mockStorageException(BlobErrorCode.INTERNAL_ERROR); doThrow(exception).when(blockBlobClient).delete(); try { - blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); + blobStore.deleteFromStorageContainer(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -187,22 +332,22 @@ public class BlobStoreTest { } @Test - public void deleteFromBlob_Success() + public void deleteFromStorageContainer_Success() { doNothing().when(blockBlobClient).delete(); try { - blobStore.deleteFromBlob(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); + blobStore.deleteFromStorageContainer(PARTITION_ID, FILE_PATH, STORAGE_CONTAINER_NAME); } catch (Exception ex) { fail("should not get any exception."); } } @Test - public void writeToBlob_ErrorCreatingBlobContainerClient() + public void writeToStorageContainer_ErrorCreatingBlobContainerClient() { doThrow(AppException.class).when(blobServiceClientFactory).getBlobServiceClient(eq(PARTITION_ID)); try { - blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT, STORAGE_CONTAINER_NAME); + blobStore.writeToStorageContainer(PARTITION_ID, FILE_PATH, CONTENT, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -211,12 +356,12 @@ public class BlobStoreTest { } @Test - public void writeToBlob_InternalError() + public void writeToStorageContainer_InternalError() { BlobStorageException exception = mockStorageException(BlobErrorCode.INTERNAL_ERROR); doThrow(exception).when(blockBlobClient).upload(any(), anyLong(), eq(true)); try { - blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT, STORAGE_CONTAINER_NAME); + blobStore.writeToStorageContainer(PARTITION_ID, FILE_PATH, CONTENT, STORAGE_CONTAINER_NAME); } catch (AppException ex) { assertEquals(500, ex.getError().getCode()); } catch (Exception ex) { @@ -225,11 +370,11 @@ public class BlobStoreTest { } @Test - public void writeToBlob_Success() + public void writeToStorageContainer_Success() { doReturn(blockBlobItem).when(blockBlobClient).upload(any(), anyLong(), eq(true)); try { - blobStore.writeToBlob(PARTITION_ID, FILE_PATH, CONTENT, STORAGE_CONTAINER_NAME); + blobStore.writeToStorageContainer(PARTITION_ID, FILE_PATH, CONTENT, STORAGE_CONTAINER_NAME); } catch (Exception ex) { fail("should not get any exception."); } -- GitLab From b39331399ebcf1992b177b9b17ee490b27b31b66 Mon Sep 17 00:00:00 2001 From: Aman Verma Date: Mon, 31 Aug 2020 15:14:35 +0530 Subject: [PATCH 6/9] fixing comment --- pom.xml | 2 +- .../blobstorage/BlobServiceClientFactoryImpl.java | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 955c93f1..7a97ede9 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.opengroup.osdu core-lib-azure jar - 0.0.22 + 0.0.23 core-lib-azure diff --git a/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImpl.java b/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImpl.java index 1a62a81a..61a4d703 100644 --- a/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImpl.java +++ b/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImpl.java @@ -20,27 +20,30 @@ import com.azure.storage.blob.BlobServiceClientBuilder; import org.opengroup.osdu.azure.di.BlobStoreConfiguration; import org.opengroup.osdu.common.Validators; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; /** * Implementation for IBlobServiceClientFactory. */ +@Component public class BlobServiceClientFactoryImpl implements IBlobServiceClientFactory { @Autowired private DefaultAzureCredential defaultAzureCredential; @Autowired - @Lazy private BlobStoreConfiguration blobStoreConfiguration; private BlobServiceClient blobServiceClient; + /** - * Parameter-less constructor. * This initializes the blobServiceClient. */ - public BlobServiceClientFactoryImpl() { + @PostConstruct + public void initBlobServiceClient() { Validators.checkNotNull(defaultAzureCredential, "Credential cannot be null"); Validators.checkNotNullAndNotEmpty(blobStoreConfiguration.getStorageAccountName(), "Storage account name cannot be null"); -- GitLab From 41efda876d984955d21293d0b3d4c17c13a28544 Mon Sep 17 00:00:00 2001 From: Aman Verma Date: Mon, 31 Aug 2020 20:14:25 +0530 Subject: [PATCH 7/9] addressing MR comments --- .../BlobServiceClientFactoryImpl.java | 21 ++--- .../BlobServiceClientFactoryImplTest.java | 85 +++++++++++++++++++ 2 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 src/test/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImplTest.java diff --git a/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImpl.java b/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImpl.java index 61a4d703..72403bc6 100644 --- a/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImpl.java +++ b/src/main/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImpl.java @@ -22,29 +22,24 @@ import org.opengroup.osdu.common.Validators; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; - /** * Implementation for IBlobServiceClientFactory. */ @Component public class BlobServiceClientFactoryImpl implements IBlobServiceClientFactory { - @Autowired - private DefaultAzureCredential defaultAzureCredential; - - @Autowired - private BlobStoreConfiguration blobStoreConfiguration; - private BlobServiceClient blobServiceClient; - /** - * This initializes the blobServiceClient. + * Constructor to initialize blobServiceClient. + * @param defaultAzureCredential Default azure credentials. + * @param blobStoreConfiguration Configuration details for blob storage. */ - @PostConstruct - public void initBlobServiceClient() { - Validators.checkNotNull(defaultAzureCredential, "Credential cannot be null"); + @Autowired + public BlobServiceClientFactoryImpl( + final DefaultAzureCredential defaultAzureCredential, + final BlobStoreConfiguration blobStoreConfiguration) { + Validators.checkNotNull(defaultAzureCredential, "Default credentials"); Validators.checkNotNullAndNotEmpty(blobStoreConfiguration.getStorageAccountName(), "Storage account name cannot be null"); String endpoint = String.format("https://%s.blob.core.windows.net", blobStoreConfiguration.getStorageAccountName()); diff --git a/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImplTest.java b/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImplTest.java new file mode 100644 index 00000000..d60bd530 --- /dev/null +++ b/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImplTest.java @@ -0,0 +1,85 @@ +// Copyright © Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.opengroup.osdu.azure.blobstorage; + +import com.azure.identity.DefaultAzureCredential; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.opengroup.osdu.azure.di.BlobStoreConfiguration; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.lenient; +import static org.mockito.MockitoAnnotations.initMocks; + +@ExtendWith(MockitoExtension.class) +public class BlobServiceClientFactoryImplTest { + + @Mock + DefaultAzureCredential credential; + + @Mock + BlobStoreConfiguration configuration; + + BlobServiceClientFactoryImpl clientFactory; + + private static final String ACCOUNT_NAME = "testAccount"; + private static final String PARTITION_ID = "dataPartitionId"; + + @BeforeEach + void init() { + initMocks(this); + lenient().doReturn(ACCOUNT_NAME).when(configuration).getStorageAccountName(); + } + + @Test + public void ConstructorThrowsException_IfDefaultAzureCredentialIsNull() { + try { + clientFactory = new BlobServiceClientFactoryImpl(null, configuration); + } catch (NullPointerException ex) { + assertEquals("Default credentials cannot be null!", ex.getMessage()); + } catch (Exception ex) { + fail("Should not get any other exception. Received " + ex.getClass()); + } + } + + @Test + public void ConstructorThrowsException_IfBlobStoreConfigurationIsNull() { + doReturn("").when(configuration).getStorageAccountName(); + + try { + clientFactory = new BlobServiceClientFactoryImpl(credential, configuration); + } catch (IllegalArgumentException ex) { + assertEquals("Storage account name cannot be null cannot be empty!", ex.getMessage()); + } catch (Exception ex) { + fail("Should not get any other exception. Received " + ex.getClass()); + } + } + + @Test + public void testGetBlobServiceClient_Success() + { + try { + clientFactory = new BlobServiceClientFactoryImpl(credential, configuration); + clientFactory.getBlobServiceClient(PARTITION_ID); + } catch (Exception ex) { + fail("Should not fail."); + } + } +} -- GitLab From f9d582a00632f4f2ba91c0b7dac64a4f9baddc99 Mon Sep 17 00:00:00 2001 From: Aman Verma Date: Tue, 1 Sep 2020 11:25:51 +0530 Subject: [PATCH 8/9] asserting account name --- .../azure/blobstorage/BlobServiceClientFactoryImplTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImplTest.java b/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImplTest.java index d60bd530..305dcd80 100644 --- a/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImplTest.java +++ b/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImplTest.java @@ -15,6 +15,7 @@ package org.opengroup.osdu.azure.blobstorage; import com.azure.identity.DefaultAzureCredential; +import com.azure.storage.blob.BlobServiceClient; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -77,7 +78,8 @@ public class BlobServiceClientFactoryImplTest { { try { clientFactory = new BlobServiceClientFactoryImpl(credential, configuration); - clientFactory.getBlobServiceClient(PARTITION_ID); + BlobServiceClient client = clientFactory.getBlobServiceClient(PARTITION_ID); + assertEquals("testAccount", client.getAccountName()); } catch (Exception ex) { fail("Should not fail."); } -- GitLab From 6d30eb729bb7d46d9167faf3974975b7bd854eee Mon Sep 17 00:00:00 2001 From: Aman Verma Date: Tue, 1 Sep 2020 11:28:45 +0530 Subject: [PATCH 9/9] using predefined variable --- .../azure/blobstorage/BlobServiceClientFactoryImplTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImplTest.java b/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImplTest.java index 305dcd80..c06fc6ca 100644 --- a/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImplTest.java +++ b/src/test/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImplTest.java @@ -79,7 +79,7 @@ public class BlobServiceClientFactoryImplTest { try { clientFactory = new BlobServiceClientFactoryImpl(credential, configuration); BlobServiceClient client = clientFactory.getBlobServiceClient(PARTITION_ID); - assertEquals("testAccount", client.getAccountName()); + assertEquals(ACCOUNT_NAME, client.getAccountName()); } catch (Exception ex) { fail("Should not fail."); } -- GitLab