Azure storage service tests#1260
Open
Jonopono123 wants to merge 10 commits into
Open
Conversation
|
Images built and published to ECR using a Build Id of PR-1025-d143234 |
# Conflicts: # gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/storage/AzureStorageServiceTest.java
775a5dc to
e498778
Compare
e498778 to
fae30e8
Compare
|
Looks good. All 1 mutations in this change were killed.
|
Collaborator
|
This has been addressed in a separate PR |
There was a problem hiding this comment.
Pull request overview
Adds test coverage for AzureStorageService by introducing an Azurite-backed test (via Testcontainers) and enabling dependency injection of a BlobServiceClient so the service can be exercised against a real blob endpoint.
Changes:
- Added
AzureStorageServiceTestusing Azurite/Testcontainers to cover upload, download, delete, and URL generation. - Added an additional
AzureStorageServiceconstructor that accepts aBlobServiceClientfor testability (and suppressed a SpotBugs warning). - Added the
testcontainers-azuretest dependency.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/storage/AzureStorageServiceTest.java | Adds Azurite-backed tests for Azure blob storage operations. |
| gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/storage/AzureStorageService.java | Enables injecting a BlobServiceClient (supporting the new tests) and adds SpotBugs suppression. |
| gp2gp-translator/build.gradle | Adds the testcontainers-azure dependency needed to run the Azurite tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3
to
+16
| import com.azure.core.util.BinaryData; | ||
| import com.azure.storage.blob.BlobServiceClient; | ||
| import com.azure.storage.blob.BlobServiceClientBuilder; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.testcontainers.azure.AzuriteContainer; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.charset.StandardCharsets; | ||
|
|
||
| import static org.junit.Assert.assertThrows; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; |
Comment on lines
+88
to
+90
| Exception exception = assertThrows(Exception.class, () -> azureStorageService.downloadFile(FILE_NAME)); | ||
|
|
||
| Assertions.assertEquals("Status code 404, BlobNotFound", exception.getMessage()); |
Comment on lines
+37
to
+40
| public AzureStorageService(BlobServiceClient blobServiceClient, StorageServiceConfiguration configuration) { | ||
| this.blobServiceClient = blobServiceClient; | ||
| this.containerName = configuration.getContainerName(); | ||
| } |
Comment on lines
+28
to
+36
| @BeforeEach | ||
| void setUp() { | ||
| azuriteContainer = new AzuriteContainer("mcr.microsoft.com/azure-storage/azurite:3.33.0"); | ||
| azuriteContainer.start(); | ||
|
|
||
| blobServiceClient = new BlobServiceClientBuilder() | ||
| .connectionString(azuriteContainer.getConnectionString()) | ||
| .buildClient(); | ||
| blobServiceClient.createBlobContainer(CONTAINER_NAME); |
Comment on lines
50
to
+53
| testImplementation 'org.skyscreamer:jsonassert:1.5.3' | ||
| testImplementation 'org.awaitility:awaitility:4.2.2' | ||
| testImplementation 'io.findify:s3mock_2.13:0.2.6' | ||
| testImplementation "org.testcontainers:testcontainers-azure:2.0.5" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Test coverage for AzureStorageService class
Why
Since its creation the AzureStorageService class has not had any test coverage, and it's in our best interest to add this.
Type of change
Please delete options that are not relevant.
Checklist: