From 36c83eeb36d5433d93e00af3e56851634b2f68ce Mon Sep 17 00:00:00 2001 From: cgi-jhjsimpson Date: Thu, 9 Jul 2026 17:08:39 +0100 Subject: [PATCH 1/2] Initial test fixes. --- build.gradle | 2 +- .../darts/common/HiddenReasonFunctionalTest.java | 2 +- .../arm/rpo/DownloadProductionServiceIntTest.java | 2 +- .../rpo/GetIndexesByMatterIdServiceIntTest.java | 2 +- .../arm/rpo/RemoveProductionServiceIntTest.java | 2 +- .../AudioControllerAddAudioMetadataIntTest.java | 4 ++-- .../service/impl/MediaRequestServiceTest.java | 2 +- ...jectDataExpiryDeletionAutomatedTaskIntTest.java | 2 +- .../impl/DeleteArmResponseFilesHelperImplTest.java | 2 +- ...DetsToArmBatchProcessResponseFilesImplTest.java | 2 +- .../hmcts/darts/arm/util/ArmRpoJsonUtilTest.java | 2 +- .../impl/CloseOldCasesProcessorImplTest.java | 8 ++++---- .../service/UserManagementServiceImplTest.java | 2 +- .../gov/hmcts/darts/test/common/DataGenerator.java | 4 ++-- .../hmcts/darts/test/common/DataGeneratorTest.java | 14 +++++++------- 15 files changed, 26 insertions(+), 26 deletions(-) diff --git a/build.gradle b/build.gradle index 8222161fafc..3e3205faad0 100644 --- a/build.gradle +++ b/build.gradle @@ -513,7 +513,7 @@ dependencies { // https://mvnrepository.com/artifact/org.awaitility/awaitility-proxy testImplementation group: 'org.awaitility', name: 'awaitility-proxy', version: '3.1.6' testImplementation 'io.github.hakky54:logcaptor:2.12.6' - testImplementation 'org.testcontainers:testcontainers:1.21.4' + testImplementation 'org.testcontainers:testcontainers:2.0.5' testImplementation group: 'org.jeasy', name: 'easy-random-core', version: '5.0.0' diff --git a/src/functionalTest/java/uk/gov/hmcts/darts/common/HiddenReasonFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/darts/common/HiddenReasonFunctionalTest.java index b6a7e2ab37c..e0d36ddbd4e 100644 --- a/src/functionalTest/java/uk/gov/hmcts/darts/common/HiddenReasonFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/darts/common/HiddenReasonFunctionalTest.java @@ -10,7 +10,7 @@ import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; class HiddenReasonFunctionalTest extends FunctionalTest { diff --git a/src/integrationTest/java/uk/gov/hmcts/darts/arm/rpo/DownloadProductionServiceIntTest.java b/src/integrationTest/java/uk/gov/hmcts/darts/arm/rpo/DownloadProductionServiceIntTest.java index 9af6041ce6d..6fd039a894d 100644 --- a/src/integrationTest/java/uk/gov/hmcts/darts/arm/rpo/DownloadProductionServiceIntTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/darts/arm/rpo/DownloadProductionServiceIntTest.java @@ -18,9 +18,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertThrows; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/src/integrationTest/java/uk/gov/hmcts/darts/arm/rpo/GetIndexesByMatterIdServiceIntTest.java b/src/integrationTest/java/uk/gov/hmcts/darts/arm/rpo/GetIndexesByMatterIdServiceIntTest.java index 2c29d3ba5f2..48b1a5182f8 100644 --- a/src/integrationTest/java/uk/gov/hmcts/darts/arm/rpo/GetIndexesByMatterIdServiceIntTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/darts/arm/rpo/GetIndexesByMatterIdServiceIntTest.java @@ -19,9 +19,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertThrows; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; diff --git a/src/integrationTest/java/uk/gov/hmcts/darts/arm/rpo/RemoveProductionServiceIntTest.java b/src/integrationTest/java/uk/gov/hmcts/darts/arm/rpo/RemoveProductionServiceIntTest.java index 8c1fa636e83..cff282904fb 100644 --- a/src/integrationTest/java/uk/gov/hmcts/darts/arm/rpo/RemoveProductionServiceIntTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/darts/arm/rpo/RemoveProductionServiceIntTest.java @@ -16,8 +16,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertThrows; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; diff --git a/src/integrationTest/java/uk/gov/hmcts/darts/audio/controller/AudioControllerAddAudioMetadataIntTest.java b/src/integrationTest/java/uk/gov/hmcts/darts/audio/controller/AudioControllerAddAudioMetadataIntTest.java index f562bda0bf2..2e06bd86da5 100644 --- a/src/integrationTest/java/uk/gov/hmcts/darts/audio/controller/AudioControllerAddAudioMetadataIntTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/darts/audio/controller/AudioControllerAddAudioMetadataIntTest.java @@ -57,9 +57,9 @@ import java.util.function.Function; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNull; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; diff --git a/src/integrationTest/java/uk/gov/hmcts/darts/audio/service/impl/MediaRequestServiceTest.java b/src/integrationTest/java/uk/gov/hmcts/darts/audio/service/impl/MediaRequestServiceTest.java index d6f685c2a1a..6aa27101ad3 100644 --- a/src/integrationTest/java/uk/gov/hmcts/darts/audio/service/impl/MediaRequestServiceTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/darts/audio/service/impl/MediaRequestServiceTest.java @@ -24,9 +24,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; -import static org.junit.Assert.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/integrationTest/java/uk/gov/hmcts/darts/task/runner/impl/AssociatedObjectDataExpiryDeletionAutomatedTaskIntTest.java b/src/integrationTest/java/uk/gov/hmcts/darts/task/runner/impl/AssociatedObjectDataExpiryDeletionAutomatedTaskIntTest.java index 9ff64f4e1ef..644aea8ad8b 100644 --- a/src/integrationTest/java/uk/gov/hmcts/darts/task/runner/impl/AssociatedObjectDataExpiryDeletionAutomatedTaskIntTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/darts/task/runner/impl/AssociatedObjectDataExpiryDeletionAutomatedTaskIntTest.java @@ -2,12 +2,12 @@ import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; +import org.apache.commons.lang3.function.TriFunction; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.jpa.domain.Specification; import org.springframework.test.context.TestPropertySource; -import org.testcontainers.shaded.org.apache.commons.lang3.function.TriFunction; import uk.gov.hmcts.darts.audit.api.AuditActivity; import uk.gov.hmcts.darts.common.entity.AnnotationDocumentEntity; import uk.gov.hmcts.darts.common.entity.AnnotationEntity; diff --git a/src/test/java/uk/gov/hmcts/darts/arm/service/impl/DeleteArmResponseFilesHelperImplTest.java b/src/test/java/uk/gov/hmcts/darts/arm/service/impl/DeleteArmResponseFilesHelperImplTest.java index 7dcf2899b98..7c4e96c228c 100644 --- a/src/test/java/uk/gov/hmcts/darts/arm/service/impl/DeleteArmResponseFilesHelperImplTest.java +++ b/src/test/java/uk/gov/hmcts/darts/arm/service/impl/DeleteArmResponseFilesHelperImplTest.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.Optional; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/uk/gov/hmcts/darts/arm/service/impl/DetsToArmBatchProcessResponseFilesImplTest.java b/src/test/java/uk/gov/hmcts/darts/arm/service/impl/DetsToArmBatchProcessResponseFilesImplTest.java index 1d2a4f0629b..5f82e8f5716 100644 --- a/src/test/java/uk/gov/hmcts/darts/arm/service/impl/DetsToArmBatchProcessResponseFilesImplTest.java +++ b/src/test/java/uk/gov/hmcts/darts/arm/service/impl/DetsToArmBatchProcessResponseFilesImplTest.java @@ -39,9 +39,9 @@ import java.time.format.DateTimeFormatter; import java.util.Optional; -import static org.junit.Assert.assertThrows; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/uk/gov/hmcts/darts/arm/util/ArmRpoJsonUtilTest.java b/src/test/java/uk/gov/hmcts/darts/arm/util/ArmRpoJsonUtilTest.java index 0614de3d7b4..cb62a9078f3 100644 --- a/src/test/java/uk/gov/hmcts/darts/arm/util/ArmRpoJsonUtilTest.java +++ b/src/test/java/uk/gov/hmcts/darts/arm/util/ArmRpoJsonUtilTest.java @@ -2,8 +2,8 @@ import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertThrows; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; class ArmRpoJsonUtilTest { diff --git a/src/test/java/uk/gov/hmcts/darts/cases/service/impl/CloseOldCasesProcessorImplTest.java b/src/test/java/uk/gov/hmcts/darts/cases/service/impl/CloseOldCasesProcessorImplTest.java index 9b35f200a6a..48ddb0da45d 100644 --- a/src/test/java/uk/gov/hmcts/darts/cases/service/impl/CloseOldCasesProcessorImplTest.java +++ b/src/test/java/uk/gov/hmcts/darts/cases/service/impl/CloseOldCasesProcessorImplTest.java @@ -30,10 +30,10 @@ import java.time.ZoneOffset; import java.util.List; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.when; diff --git a/src/test/java/uk/gov/hmcts/darts/usermanagement/service/impl/usermanagement/service/UserManagementServiceImplTest.java b/src/test/java/uk/gov/hmcts/darts/usermanagement/service/impl/usermanagement/service/UserManagementServiceImplTest.java index cdc5f86456c..8bfeaeaba23 100644 --- a/src/test/java/uk/gov/hmcts/darts/usermanagement/service/impl/usermanagement/service/UserManagementServiceImplTest.java +++ b/src/test/java/uk/gov/hmcts/darts/usermanagement/service/impl/usermanagement/service/UserManagementServiceImplTest.java @@ -44,8 +44,8 @@ import java.util.Optional; import java.util.Set; -import static org.junit.Assert.assertNull; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; diff --git a/src/testCommon/java/uk/gov/hmcts/darts/test/common/DataGenerator.java b/src/testCommon/java/uk/gov/hmcts/darts/test/common/DataGenerator.java index 0f8cd26f3d2..fe49b33bbb4 100644 --- a/src/testCommon/java/uk/gov/hmcts/darts/test/common/DataGenerator.java +++ b/src/testCommon/java/uk/gov/hmcts/darts/test/common/DataGenerator.java @@ -4,8 +4,8 @@ import lombok.RequiredArgsConstructor; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.binary.Hex; +import org.apache.commons.lang3.RandomUtils; import org.springframework.util.unit.DataSize; -import org.testcontainers.shaded.org.apache.commons.lang3.RandomUtils; import java.io.ByteArrayOutputStream; import java.io.File; @@ -75,7 +75,7 @@ public static byte[] createUniqueData(DataSize dataSize, FileType fileType) { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byteArrayOutputStream.writeBytes(signatureBytes); - byte[] randomisedBytes = RandomUtils.nextBytes(contentSize); + byte[] randomisedBytes = RandomUtils.insecure().randomBytes(contentSize); byteArrayOutputStream.writeBytes(randomisedBytes); return byteArrayOutputStream.toByteArray(); diff --git a/src/testCommon/java/uk/gov/hmcts/darts/test/common/DataGeneratorTest.java b/src/testCommon/java/uk/gov/hmcts/darts/test/common/DataGeneratorTest.java index 90a3901e941..0bff7dcf272 100644 --- a/src/testCommon/java/uk/gov/hmcts/darts/test/common/DataGeneratorTest.java +++ b/src/testCommon/java/uk/gov/hmcts/darts/test/common/DataGeneratorTest.java @@ -2,19 +2,19 @@ import org.apache.tika.Tika; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.unit.DataSize; import java.io.IOException; import java.nio.file.Path; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; -public class DataGeneratorTest { +class DataGeneratorTest { @Test - public void shouldProduceAValidMP2() throws IOException { + void shouldProduceAValidMP2() throws IOException { Path audioFile = DataGenerator.createUniqueFile(DataSize.ofBytes(100), DataGenerator.FileType.MP2); assertEquals(100, audioFile.toFile().length()); @@ -22,7 +22,7 @@ public void shouldProduceAValidMP2() throws IOException { } @Test - public void shouldProduceAValidMP3() throws IOException { + void shouldProduceAValidMP3() throws IOException { Path uniqueAudioFile = DataGenerator.createUniqueFile(DataSize.ofBytes(100), DataGenerator.FileType.MP3); assertEquals(100, uniqueAudioFile.toFile().length()); @@ -30,7 +30,7 @@ public void shouldProduceAValidMP3() throws IOException { } @Test - public void showThrowExceptionIfDesiredLengthIsTooSmall() { + void showThrowExceptionIfDesiredLengthIsTooSmall() { IllegalArgumentException illegalArgumentException = assertThrows(IllegalArgumentException.class, () -> DataGenerator.createUniqueFile(DataSize.ofBytes(1), DataGenerator.FileType.MP2) ); From 2c9dee762dfdeceabfc14eff13cd1865a9ae133b Mon Sep 17 00:00:00 2001 From: cgi-jhjsimpson Date: Thu, 9 Jul 2026 17:11:00 +0100 Subject: [PATCH 2/2] CaseControllerAdminGetCaseByIdIntTest.java fixes. --- ...CaseControllerAdminGetCaseByIdIntTest.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/integrationTest/java/uk/gov/hmcts/darts/cases/controller/CaseControllerAdminGetCaseByIdIntTest.java b/src/integrationTest/java/uk/gov/hmcts/darts/cases/controller/CaseControllerAdminGetCaseByIdIntTest.java index 200b726b8cd..68b663c33c6 100644 --- a/src/integrationTest/java/uk/gov/hmcts/darts/cases/controller/CaseControllerAdminGetCaseByIdIntTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/darts/cases/controller/CaseControllerAdminGetCaseByIdIntTest.java @@ -134,8 +134,8 @@ void adminGetCaseById_WithCaseOpenAndReportingRestrictions() throws Exception { String actualResponse = mvcResult.getResponse().getContentAsString(); String expectedResponse = getContentsFromFile( "tests/cases/CaseControllerAdminGetCaseByIdTest/testCaseOpen/expectedResponse.json"); - expectedResponse = expectedResponse.replace("", courtCase.getCreatedDateTime().format(DateTimeFormatter.ISO_DATE_TIME)); - expectedResponse = expectedResponse.replace("", courtCase.getLastModifiedDateTime().format(DateTimeFormatter.ISO_DATE_TIME)); + expectedResponse = expectedResponse.replace("", formatAsUtc(courtCase.getCreatedDateTime())); + expectedResponse = expectedResponse.replace("", formatAsUtc(courtCase.getLastModifiedDateTime())); JSONAssert.assertEquals(expectedResponse, actualResponse, JSONCompareMode.NON_EXTENSIBLE); } @@ -176,8 +176,8 @@ void adminGetCaseById_WithCaseClosedAndReportingRestrictions() throws Exception String actualResponse = mvcResult.getResponse().getContentAsString(); String expectedResponse = getContentsFromFile( "tests/cases/CaseControllerAdminGetCaseByIdTest/testCaseClosed/expectedResponse.json"); - expectedResponse = expectedResponse.replace("", courtCase.getCreatedDateTime().format(DateTimeFormatter.ISO_DATE_TIME)); - expectedResponse = expectedResponse.replace("", courtCase.getLastModifiedDateTime().format(DateTimeFormatter.ISO_DATE_TIME)); + expectedResponse = expectedResponse.replace("", formatAsUtc(courtCase.getCreatedDateTime())); + expectedResponse = expectedResponse.replace("", formatAsUtc(courtCase.getLastModifiedDateTime())); JSONAssert.assertEquals(expectedResponse, actualResponse, JSONCompareMode.NON_EXTENSIBLE); } @@ -213,8 +213,8 @@ void adminGetCaseById_IsAnonymised() throws Exception { String expectedResponse = getContentsFromFile( "tests/cases/CaseControllerAdminGetCaseByIdTest/testIsAnonymised/expectedResponse.json"); expectedResponse = expectedResponse - .replace("", courtCase.getCreatedDateTime().format(DateTimeFormatter.ISO_DATE_TIME)) - .replace("", courtCase.getLastModifiedDateTime().format(DateTimeFormatter.ISO_DATE_TIME)) + .replace("", formatAsUtc(courtCase.getCreatedDateTime())) + .replace("", formatAsUtc(courtCase.getLastModifiedDateTime())) .replace("", String.valueOf(anonymisedBy.getId())); JSONAssert.assertEquals(expectedResponse, actualResponse, JSONCompareMode.NON_EXTENSIBLE); } @@ -248,8 +248,8 @@ void adminGetCaseById_IsDeleted() throws Exception { String expectedResponse = getContentsFromFile( "tests/cases/CaseControllerAdminGetCaseByIdTest/expectedResponse_isDeleted.json"); expectedResponse = expectedResponse - .replace("", courtCase.getCreatedDateTime().format(DateTimeFormatter.ISO_DATE_TIME)) - .replace("", courtCase.getLastModifiedDateTime().format(DateTimeFormatter.ISO_DATE_TIME)) + .replace("", formatAsUtc(courtCase.getCreatedDateTime())) + .replace("", formatAsUtc(courtCase.getLastModifiedDateTime())) .replace("", String.valueOf(deletedBy.getId())); JSONAssert.assertEquals(expectedResponse, actualResponse, JSONCompareMode.NON_EXTENSIBLE); } @@ -299,8 +299,8 @@ void adminGetCaseById_WithRetentionAndAdditionalCaseDetails() throws Exception { String expectedResponse = getContentsFromFile( "tests/cases/CaseControllerAdminGetCaseByIdTest/expectedResponse_withRetentionAndAdditionalCaseDetails.json"); expectedResponse = expectedResponse - .replace("", courtCase.getCreatedDateTime().format(DateTimeFormatter.ISO_DATE_TIME)) - .replace("", courtCase.getLastModifiedDateTime().format(DateTimeFormatter.ISO_DATE_TIME)); + .replace("", formatAsUtc(courtCase.getCreatedDateTime())) + .replace("", formatAsUtc(courtCase.getLastModifiedDateTime())); JSONAssert.assertEquals(expectedResponse, actualResponse, JSONCompareMode.NON_EXTENSIBLE); } @@ -328,4 +328,8 @@ private List createEventsWithDifferentTimestamps(List