Skip to content

Commit

Permalink
Merge branch 'master' into DMP-3396
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Edwards-cgi authored Feb 26, 2025
2 parents 04308fe + e69a0d8 commit 6b66a3d
Show file tree
Hide file tree
Showing 113 changed files with 1,954 additions and 1,365 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ plugins {
id 'org.owasp.dependencycheck' version '12.1.0'
id 'com.github.ben-manes.versions' version '0.52.0'
id 'org.sonarqube' version '6.0.1.5171'
id "io.freefair.lombok" version "8.12.1"
id "io.freefair.lombok" version "8.12.2"
id "org.openapi.generator" version "7.11.0"
id "org.flywaydb.flyway" version "11.3.3"
id 'maven-publish'
Expand Down Expand Up @@ -230,13 +230,13 @@ pmd {
pmdMain {
ruleSetFiles = files("config/pmd/main-ruleset.xml")
//Ensures we don't passively increase pmd errors but we should aim to reduce this
maxFailures = 558
maxFailures = 540
}

pmdTestCommon {
ruleSetFiles = files("config/pmd/test-ruleset.xml")
//Ensures we don't passively increase pmd errors but we should aim to reduce this
maxFailures = 407
maxFailures = 365
}
pmdTest {
ruleSetFiles = files("config/pmd/test-ruleset.xml")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;

class ArmRpoApiAddAsyncSearchIntTest extends PostgresIntegrationBase {
class AddAsyncSearchServiceIntTest extends PostgresIntegrationBase {

@MockitoBean
private ArmRpoClient armRpoClient;

@Autowired
private ArmRpoApi armRpoApi;
private AddAsyncSearchService addAsyncSearchService;

private static final String TOKEN = "some token";
private static final String SEARCH_ID = "some search id";
Expand All @@ -51,7 +51,7 @@ void addAsyncSearch_shouldSucceedWhenASuccessResponseIsObtainedFromArm() {
Integer executionId = executionDetailEntity.getId();

// When
armRpoApi.addAsyncSearch(TOKEN, executionId, userAccount);
addAsyncSearchService.addAsyncSearch(TOKEN, executionId, userAccount);

// Then
executionDetailEntity = dartsPersistence.getArmRpoExecutionDetailRepository().findById(executionId)
Expand All @@ -72,7 +72,7 @@ void addAsyncSearch_shouldThrowExceptionWhenArmRequestCannotBeConstructed() {

// When
String exceptionMessage = assertThrows(ArmRpoException.class, () ->
armRpoApi.addAsyncSearch(TOKEN, executionId, userAccount))
addAsyncSearchService.addAsyncSearch(TOKEN, executionId, userAccount))
.getMessage();

// Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;

class ArmRpoApiCreateExportBasedOnSearchResultsTableIntTest extends PostgresIntegrationBase {
class CreateExportBasedOnSearchResultsTableServiceIntTest extends PostgresIntegrationBase {

private static final String PRODUCTION_NAME = "DARTS_RPO_2024-08-13";

Expand All @@ -43,7 +43,7 @@ class ArmRpoApiCreateExportBasedOnSearchResultsTableIntTest extends PostgresInte
private CurrentTimeHelper currentTimeHelper;

@Autowired
private ArmRpoApi armRpoApi;
private CreateExportBasedOnSearchResultsTableService createExportBasedOnSearchResultsTableService;

private final Duration pollDuration = Duration.ofHours(4);

Expand All @@ -69,7 +69,7 @@ void createExportBasedOnSearchResultsTable_ReturnsTrue() {
var bearerAuth = "Bearer some-token";

// when
boolean result = armRpoApi.createExportBasedOnSearchResultsTable(
boolean result = createExportBasedOnSearchResultsTableService.createExportBasedOnSearchResultsTable(
bearerAuth, armRpoExecutionDetail.getId(), createHeaderColumns(), PRODUCTION_NAME, pollDuration, userAccount);

// then
Expand Down Expand Up @@ -103,7 +103,7 @@ void createExportBasedOnSearchResultsTable_ReturnsFalse_WhenInProgress() {
var bearerAuth = "Bearer some-token";

// when
boolean result = armRpoApi.createExportBasedOnSearchResultsTable(
boolean result = createExportBasedOnSearchResultsTableService.createExportBasedOnSearchResultsTable(
bearerAuth, armRpoExecutionDetail.getId(), createHeaderColumns(), PRODUCTION_NAME, pollDuration, userAccount);

// then
Expand Down Expand Up @@ -138,8 +138,10 @@ void createExportBasedOnSearchResultsTable_ReturnsFalse_WhenPollingOutOfRange()
var bearerAuth = "Bearer some-token";

// when
ArmRpoException armRpoException = assertThrows(ArmRpoException.class, () -> armRpoApi.createExportBasedOnSearchResultsTable(
bearerAuth, armRpoExecutionDetail.getId(), createHeaderColumns(), PRODUCTION_NAME, pollDuration, userAccount));
ArmRpoException armRpoException = assertThrows(ArmRpoException.class,
() -> createExportBasedOnSearchResultsTableService.createExportBasedOnSearchResultsTable(
bearerAuth, armRpoExecutionDetail.getId(), createHeaderColumns(), PRODUCTION_NAME, pollDuration,
userAccount));

// then
MatcherAssert.assertThat(armRpoException.getMessage(), containsString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@

@TestPropertySource(properties = {"darts.storage.arm.is-mock-arm-rpo-download-csv=false"})
@SuppressWarnings("PMD.CloseResource")
class ArmRpoApiDownloadProductionIntTest extends IntegrationBase {
class DownloadProductionServiceIntTest extends IntegrationBase {

@MockitoBean
private ArmRpoClient armRpoClient;

@Autowired
private ArmRpoApi armRpoApi;

private DownloadProductionService downloadProductionService;

@Test
void downloadProductionSuccess() throws IOException {
Expand All @@ -56,7 +55,7 @@ void downloadProductionSuccess() throws IOException {

// when
try (InputStream result =
armRpoApi.downloadProduction("token", armRpoExecutionDetailEntity.getId(), "productionExportId", userAccount)) {
downloadProductionService.downloadProduction("token", armRpoExecutionDetailEntity.getId(), "productionExportId", userAccount)) {
// then
assertNotNull(result);
}
Expand All @@ -81,7 +80,7 @@ void downloadProductionThrowsFeignException() {

// when
ArmRpoException armRpoException = assertThrows(ArmRpoException.class, () ->
armRpoApi.downloadProduction("token", armRpoExecutionDetailEntity.getId(), "productionExportId", userAccount));
downloadProductionService.downloadProduction("token", armRpoExecutionDetailEntity.getId(), "productionExportId", userAccount));


// then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;

class ArmRpoApiGetExtendedProductionsByMatterIntTest extends IntegrationBase {
class GetExtendedProductionsByMatterServiceIntTest extends IntegrationBase {

private static final String PRODUCTION_NAME = "DARTS_RPO_2024-08-13";
public static final String END_PRODUCTION_TIME = "2025-01-16T12:30:09.9129726+00:00";
Expand All @@ -30,7 +30,7 @@ class ArmRpoApiGetExtendedProductionsByMatterIntTest extends IntegrationBase {
private ArmRpoClient armRpoClient;

@Autowired
private ArmRpoApi armRpoApi;
private GetExtendedProductionsByMatterService getExtendedProductionsByMatterService;

private UserAccountEntity userAccount;
private ArmRpoExecutionDetailEntity armRpoExecutionDetail;
Expand Down Expand Up @@ -58,7 +58,8 @@ void getExtendedProductionsByMatter_ReturnsTrue() {
var bearerAuth = "Bearer some-token";

// when
var result = armRpoApi.getExtendedProductionsByMatter(bearerAuth, armRpoExecutionDetail.getId(), PRODUCTION_NAME, userAccount);
var result = getExtendedProductionsByMatterService.getExtendedProductionsByMatter(bearerAuth, armRpoExecutionDetail.getId(), PRODUCTION_NAME,
userAccount);

// then
assertTrue(result);
Expand All @@ -81,7 +82,8 @@ void getExtendedProductionsByMatter_ReturnsFalseForInProgress_WhenEndProductionT
var bearerAuth = "Bearer some-token";

// when
var result = armRpoApi.getExtendedProductionsByMatter(bearerAuth, armRpoExecutionDetail.getId(), PRODUCTION_NAME, userAccount);
var result = getExtendedProductionsByMatterService.getExtendedProductionsByMatter(bearerAuth, armRpoExecutionDetail.getId(), PRODUCTION_NAME,
userAccount);

// then
assertFalse(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;

class ArmRpoApiGetExtendedSearchesByMatterIntTest extends IntegrationBase {
class GetExtendedSearchesByMatterServiceIntTest extends IntegrationBase {

private static final String SEARCH_ID = "8271f101-8c14-4c41-8865-edc5d8baed99";
private static final String PRODUCTION_NAME = "DARTS_RPO_2024-08-13";
Expand All @@ -30,7 +30,7 @@ class ArmRpoApiGetExtendedSearchesByMatterIntTest extends IntegrationBase {
private ArmApiConfigurationProperties armApiConfigurationProperties;

@Autowired
private ArmRpoApi armRpoApi;
private GetExtendedSearchesByMatterService getExtendedSearchesByMatterService;


@Test
Expand Down Expand Up @@ -60,7 +60,7 @@ void getExtendedSearchesByMatterSuccess() {
var bearerAuth = "Bearer some-token";

// when
String result = armRpoApi.getExtendedSearchesByMatter(bearerAuth, armRpoExecutionDetail.getId(), userAccount);
String result = getExtendedSearchesByMatterService.getExtendedSearchesByMatter(bearerAuth, armRpoExecutionDetail.getId(), userAccount);

// then
assertEquals(PRODUCTION_NAME, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;

class ArmRpoApiGetIndexesByMatterIdIntTest extends IntegrationBase {
class GetIndexesByMatterIdServiceIntTest extends IntegrationBase {
@MockitoBean
private ArmRpoClient armRpoClient;

@Autowired
private ArmRpoApi armRpoApi;
private GetIndexesByMatterIdService getIndexesByMatterIdService;


@Test
Expand Down Expand Up @@ -57,7 +57,7 @@ void getIndexesByMatterIdSuccess() {
var bearerAuth = "Bearer some-token";

// when
armRpoApi.getIndexesByMatterId(bearerAuth, armRpoExecutionDetail.getId(), "matterId", userAccount);
getIndexesByMatterIdService.getIndexesByMatterId(bearerAuth, armRpoExecutionDetail.getId(), "matterId", userAccount);

// then
var armRpoExecutionDetailEntityUpdated = dartsPersistence.getArmRpoExecutionDetailRepository().findById(armRpoExecutionDetail.getId()).orElseThrow();
Expand Down Expand Up @@ -86,7 +86,7 @@ void getIndexesByMatterIdShouldFailWithMissingMatterId() {

// when
ArmRpoException armRpoException = assertThrows(ArmRpoException.class, () ->
armRpoApi.getIndexesByMatterId(bearerAuth, armRpoExecutionDetail.getId(), "matterId", userAccount));
getIndexesByMatterIdService.getIndexesByMatterId(bearerAuth, armRpoExecutionDetail.getId(), "matterId", userAccount));

// then
assertThat(armRpoException.getMessage(), containsString(
Expand All @@ -113,7 +113,7 @@ void getIndexesByMatterIdFailsWhenClientReturns400Error() {

// when
ArmRpoException armRpoException = assertThrows(ArmRpoException.class, () ->
armRpoApi.getIndexesByMatterId(bearerAuth, armRpoExecutionDetail.getId(), "matterId", userAccount));
getIndexesByMatterIdService.getIndexesByMatterId(bearerAuth, armRpoExecutionDetail.getId(), "matterId", userAccount));

// then
assertThat(armRpoException.getMessage(), containsString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
import static org.mockito.Mockito.when;


class ArpRpoApiGetMasterIndexFieldByRecordClassSchemaIntTest extends IntegrationBase {
class GetMasterIndexFieldByRecordClassSchemaServiceIntTest extends IntegrationBase {

@MockitoBean
private ArmRpoClient armRpoClient;

@Autowired
private ArmRpoApi armRpoApi;
private GetMasterIndexFieldByRecordClassSchemaService getMasterIndexFieldByRecordClassSchemaService;

@Test
void getMasterIndexFieldByRecordClassSchemaSuccess() {

Expand All @@ -52,7 +52,7 @@ void getMasterIndexFieldByRecordClassSchemaSuccess() {
var bearerAuth = "Bearer some-token";

// when
List<MasterIndexFieldByRecordClassSchema> result = armRpoApi.getMasterIndexFieldByRecordClassSchema(
List<MasterIndexFieldByRecordClassSchema> result = getMasterIndexFieldByRecordClassSchemaService.getMasterIndexFieldByRecordClassSchema(
bearerAuth, armRpoExecutionDetail.getId(), ArmRpoHelper.getMasterIndexFieldByRecordClassSchemaPrimaryRpoState(), userAccount);

// then
Expand Down Expand Up @@ -90,7 +90,7 @@ void getMasterIndexFieldByRecordClassSchemaWhereMasterIndexIsToBeIgnoredAndMissi

// when
assertThrows(ArmRpoException.class, () ->
armRpoApi.getMasterIndexFieldByRecordClassSchema(
getMasterIndexFieldByRecordClassSchemaService.getMasterIndexFieldByRecordClassSchema(
bearerAuth, armRpoExecutionDetail.getId(), ArmRpoHelper.getMasterIndexFieldByRecordClassSchemaPrimaryRpoState(), userAccount));

// then
Expand Down Expand Up @@ -120,7 +120,7 @@ void getMasterIndexFieldByRecordClassSchemaShouldFailIfServerReturnsResponseWith

// when
assertThrows(ArmRpoException.class, () ->
armRpoApi.getMasterIndexFieldByRecordClassSchema(
getMasterIndexFieldByRecordClassSchemaService.getMasterIndexFieldByRecordClassSchema(
bearerAuth, armRpoExecutionDetail.getId(), ArmRpoHelper.getMasterIndexFieldByRecordClassSchemaPrimaryRpoState(), userAccount));

// then
Expand All @@ -145,7 +145,7 @@ void getMasterIndexFieldByRecordClassSchemaFailsWhenClientReturns400Error() {
var bearerAuth = "Bearer some-token";

// when
assertThrows(ArmRpoException.class, () -> armRpoApi.getMasterIndexFieldByRecordClassSchema(
assertThrows(ArmRpoException.class, () -> getMasterIndexFieldByRecordClassSchemaService.getMasterIndexFieldByRecordClassSchema(
bearerAuth, armRpoExecutionDetail.getId(), ArmRpoHelper.getMasterIndexFieldByRecordClassSchemaPrimaryRpoState(), userAccount));

// then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
import static uk.gov.hmcts.darts.arm.enums.ArmRpoResponseStatusCode.READY_STATUS;

@SuppressWarnings("checkstyle:linelength")
class ArmRpoApiGetProductionOutputFilesIntTest extends PostgresIntegrationBase {
class GetProductionOutputFilesServiceIntTest extends PostgresIntegrationBase {

@MockitoBean
private ArmRpoClient armRpoClient;

@Autowired
private ArmRpoApi armRpoApi;
private GetProductionOutputFilesService getProductionOutputFilesService;

private static final String TOKEN = "some token";
private static final String PRODUCTION_ID = UUID.randomUUID().toString();
Expand All @@ -54,7 +54,7 @@ void getProductionOutputFiles_shouldSucceedAndReturnSingleItem_whenSuccessRespon
Integer executionId = executionDetailEntity.getId();

// When
List<String> productionOutputFiles = armRpoApi.getProductionOutputFiles(TOKEN, executionId, userAccount);
List<String> productionOutputFiles = getProductionOutputFilesService.getProductionOutputFiles(TOKEN, executionId, userAccount);

// Then
assertEquals(1, productionOutputFiles.size());
Expand All @@ -80,7 +80,7 @@ void getProductionOutputFiles_shouldSucceedAndReturnMultipleItems_whenSuccessRes
Integer executionId = executionDetailEntity.getId();

// When
List<String> productionOutputFiles = armRpoApi.getProductionOutputFiles(TOKEN, executionId, userAccount);
List<String> productionOutputFiles = getProductionOutputFilesService.getProductionOutputFiles(TOKEN, executionId, userAccount);

// Then
assertEquals(2, productionOutputFiles.size());
Expand All @@ -105,7 +105,7 @@ void getProductionOutputFiles_shouldThrowException_whenArmReturnsNoProductionExp

// When
String exceptionMessage = assertThrows(ArmRpoException.class, () ->
armRpoApi.getProductionOutputFiles(TOKEN, executionId, userAccount))
getProductionOutputFilesService.getProductionOutputFiles(TOKEN, executionId, userAccount))
.getMessage();

// Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
@TestPropertySource(properties = {
"darts.storage.arm-api.arm-service-entitlement=SRV-DARTS-RW-E"
})
class ArmRpoGetProfileEntitlementsIntTest extends PostgresIntegrationBase {
class GetProfileEntitlementsServiceIntTest extends PostgresIntegrationBase {

@MockitoBean
private ArmRpoClient armRpoClient;

@Autowired
private ArmRpoApi armRpoApi;
private GetProfileEntitlementsService getProfileEntitlementsService;

private static final String TOKEN = "some token";
private static final String ENTITLEMENT_ID = "some entitlement id";
Expand All @@ -55,7 +55,7 @@ void getProfileEntitlements_shouldSucceed_whenASuccessResponseIsObtainedFromArmT
createEntitlementResponseAndSetMock(Collections.singletonList(profileEntitlement));

// When
armRpoApi.getProfileEntitlements(TOKEN, executionId, userAccount);
getProfileEntitlementsService.getProfileEntitlements(TOKEN, executionId, userAccount);

// Then
executionDetailEntity = dartsPersistence.getArmRpoExecutionDetailRepository().findById(executionId)
Expand All @@ -81,7 +81,7 @@ void getProfileEntitlements_shouldFail_whenArmResponseDoesNotContainAMatchingEnt

// When
String exceptionMessage = assertThrows(ArmRpoException.class, () ->
armRpoApi.getProfileEntitlements(TOKEN, executionId, userAccount))
getProfileEntitlementsService.getProfileEntitlements(TOKEN, executionId, userAccount))
.getMessage();

// Then
Expand Down
Loading

0 comments on commit 6b66a3d

Please sign in to comment.