From e304b771fa1bb44e2ced2fa52a9e4964e792e7f5 Mon Sep 17 00:00:00 2001 From: chris-bellingham Date: Thu, 14 Nov 2024 11:02:31 +0000 Subject: [PATCH] DMP-4143: Implement ProcessE2EArmRpoPendingAutomatedTask --- ...sE2EArmRpoPendingAutomatedTaskIntTest.java | 226 ++++++++++++++++++ .../uk/gov/hmcts/darts/arm/rpo/ArmRpoApi.java | 2 +- .../darts/arm/rpo/impl/ArmRpoApiImpl.java | 7 +- .../darts/arm/service/ArmApiService.java | 2 + .../darts/arm/service/ArmRpoService.java | 2 + .../service/TriggerArmRpoSearchService.java | 5 + .../arm/service/impl/ArmApiServiceImpl.java | 3 +- .../arm/service/impl/ArmRpoServiceImpl.java | 16 ++ .../impl/TriggerArmRpoSearchServiceImpl.java | 78 ++++++ .../api/DataManagementFacadeImpl.java | 4 +- .../ProcessE2EArmRpoPendingAutomatedTask.java | 38 +++ src/main/resources/application.yaml | 2 +- 12 files changed, 379 insertions(+), 6 deletions(-) create mode 100644 src/integrationTest/java/uk/gov/hmcts/darts/task/runner/impl/ProcessE2EArmRpoPendingAutomatedTaskIntTest.java create mode 100644 src/main/java/uk/gov/hmcts/darts/arm/service/TriggerArmRpoSearchService.java create mode 100644 src/main/java/uk/gov/hmcts/darts/arm/service/impl/TriggerArmRpoSearchServiceImpl.java create mode 100644 src/main/java/uk/gov/hmcts/darts/task/runner/impl/ProcessE2EArmRpoPendingAutomatedTask.java diff --git a/src/integrationTest/java/uk/gov/hmcts/darts/task/runner/impl/ProcessE2EArmRpoPendingAutomatedTaskIntTest.java b/src/integrationTest/java/uk/gov/hmcts/darts/task/runner/impl/ProcessE2EArmRpoPendingAutomatedTaskIntTest.java new file mode 100644 index 0000000000..3dac51d4d1 --- /dev/null +++ b/src/integrationTest/java/uk/gov/hmcts/darts/task/runner/impl/ProcessE2EArmRpoPendingAutomatedTaskIntTest.java @@ -0,0 +1,226 @@ +package uk.gov.hmcts.darts.task.runner.impl; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.TestPropertySource; +import uk.gov.hmcts.darts.arm.client.ArmRpoClient; +import uk.gov.hmcts.darts.arm.client.model.rpo.ArmAsyncSearchResponse; +import uk.gov.hmcts.darts.arm.client.model.rpo.IndexesByMatterIdResponse; +import uk.gov.hmcts.darts.arm.client.model.rpo.MasterIndexFieldByRecordClassSchemaResponse; +import uk.gov.hmcts.darts.arm.client.model.rpo.ProfileEntitlementResponse; +import uk.gov.hmcts.darts.arm.client.model.rpo.RecordManagementMatterResponse; +import uk.gov.hmcts.darts.arm.client.model.rpo.SaveBackgroundSearchResponse; +import uk.gov.hmcts.darts.arm.client.model.rpo.StorageAccountResponse; +import uk.gov.hmcts.darts.arm.exception.ArmRpoException; +import uk.gov.hmcts.darts.arm.service.ArmApiService; +import uk.gov.hmcts.darts.authorisation.component.UserIdentity; +import uk.gov.hmcts.darts.common.entity.ArmRpoExecutionDetailEntity; +import uk.gov.hmcts.darts.common.entity.UserAccountEntity; +import uk.gov.hmcts.darts.common.enums.ArmRpoStateEnum; +import uk.gov.hmcts.darts.common.enums.ArmRpoStatusEnum; +import uk.gov.hmcts.darts.testutils.PostgresIntegrationBase; + +import java.util.Collections; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +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.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +@TestPropertySource(properties = { + "darts.storage.arm-api.arm-storage-account-name=SOME ARM STORAGE ACCOUNT NAME", + "darts.storage.arm-api.arm-service-entitlement=SOME ENTITLEMENT NAME" +}) +class ProcessE2EArmRpoPendingAutomatedTaskIntTest extends PostgresIntegrationBase { + + @Autowired + private ProcessE2EArmRpoPendingAutomatedTask task; + + @MockBean + private UserIdentity userIdentity; + + @MockBean + private ArmApiService armApiService; + + @MockBean + private ArmRpoClient armRpoClient; + + private static final String BEARER_TOKEN = "SOME BEARER TOKEN"; + private static final String MATTER_ID = "SOME MATTER ID"; + private static final String INDEX_ID = "SOME INDEX ID"; + private static final String STORAGE_ACCOUNT_INDEX_NAME = "SOME ARM STORAGE ACCOUNT NAME"; + private static final String STORAGE_ACCOUNT_INDEX_ID = "SOME ARM STORAGE ACCOUNT INDEX ID"; + private static final String ENTITLEMENT_NAME = "SOME ENTITLEMENT NAME"; + private static final String ENTITLEMENT_ID = "SOME ENTITLEMENT ID"; + private static final String SOME_MASTER_INDEX_FIELD_ID = "SOME MASTER INDEX FIELD ID"; + private static final String SEARCH_ID = "SOME SEARCH ID"; + + @BeforeEach + void setUp() { + UserAccountEntity user = dartsDatabase.getUserAccountStub().getSystemUserAccountEntity(); + when(userIdentity.getUserAccount()) + .thenReturn(user); + + when(armApiService.getArmBearerToken()) + .thenReturn(BEARER_TOKEN); + } + + @Test + void runTask_shouldTriggerArmRpoSearch_andSetExpectedFinalExecutionDetailStateAndStatus_whenAllDownstreamArmCallsAreSuccessful() { + // Given + createAndSetRecordManagementMatterMock(); + createAndSetIndexesByMatterIdMock(); + createAndSetGetStorageAccountsMock(); + createAndSetGetProfileEntitlementsMock(); + createAndSetGetMasterIndexFieldByRecordClassSchemaMock(); + createAndSetAddAsyncSearchMock(); + createAndSetSaveBackgroundSearchMock(); + + // When + task.runTask(); + + // Then + List allExecutionDetails = dartsDatabase.getArmRpoExecutionDetailRepository() + .findAll(); + assertEquals(1, allExecutionDetails.size()); + + var executionDetail = allExecutionDetails.getFirst(); + assertEquals(ArmRpoStateEnum.SAVE_BACKGROUND_SEARCH.getId(), executionDetail.getArmRpoState().getId()); + assertEquals(ArmRpoStatusEnum.COMPLETED.getId(), executionDetail.getArmRpoStatus().getId()); + + assertEquals(MATTER_ID, executionDetail.getMatterId()); + assertEquals(INDEX_ID, executionDetail.getIndexId()); + assertEquals(ENTITLEMENT_ID, executionDetail.getEntitlementId()); + assertEquals(STORAGE_ACCOUNT_INDEX_ID, executionDetail.getStorageAccountId()); + assertNull(executionDetail.getProductionId()); + assertEquals(SOME_MASTER_INDEX_FIELD_ID, executionDetail.getSortingField()); + assertNull(executionDetail.getSearchItemCount()); + } + + @Test + void runTask_shouldThrowException_andSetExpectedExecutionDetailStateAndStatus_whenAnyDownstreamArmCallFails() { + // Given the first API call fails + var response = new RecordManagementMatterResponse(); + response.setIsError(true); + response.setStatus(400); + + when(armRpoClient.getRecordManagementMatter(eq(BEARER_TOKEN))) + .thenReturn(response); + + // When + ArmRpoException exception = assertThrows(ArmRpoException.class, () -> task.runTask()); + assertThat(exception.getMessage(), + containsString("Failure during ARM RPO getRecordManagementMatter: ARM RPO API failed with status - 400 BAD_REQUEST")); + + // Then + List allExecutionDetails = dartsDatabase.getArmRpoExecutionDetailRepository() + .findAll(); + assertEquals(1, allExecutionDetails.size()); + + var executionDetail = allExecutionDetails.getFirst(); + assertEquals(ArmRpoStateEnum.GET_RECORD_MANAGEMENT_MATTER.getId(), executionDetail.getArmRpoState().getId()); + assertEquals(ArmRpoStatusEnum.FAILED.getId(), executionDetail.getArmRpoStatus().getId()); + } + + private void createAndSetSaveBackgroundSearchMock() { + SaveBackgroundSearchResponse saveBackgroundSearchResponse = new SaveBackgroundSearchResponse(); + saveBackgroundSearchResponse.setStatus(200); + saveBackgroundSearchResponse.setIsError(false); + + when(armRpoClient.saveBackgroundSearch(eq(BEARER_TOKEN), any())) + .thenReturn(saveBackgroundSearchResponse); + } + + private void createAndSetAddAsyncSearchMock() { + var response = new ArmAsyncSearchResponse(); + response.setStatus(200); + response.setIsError(false); + response.setSearchId(SEARCH_ID); + + when(armRpoClient.addAsyncSearch(eq(BEARER_TOKEN), anyString())) + .thenReturn(response); + } + + private void createAndSetGetMasterIndexFieldByRecordClassSchemaMock() { + var masterIndexField = new MasterIndexFieldByRecordClassSchemaResponse.MasterIndexField(); + masterIndexField.setPropertyName("ingestionDate"); + masterIndexField.setMasterIndexFieldId(SOME_MASTER_INDEX_FIELD_ID); + + var response = new MasterIndexFieldByRecordClassSchemaResponse(); + response.setMasterIndexFields(Collections.singletonList(masterIndexField)); + response.setStatus(200); + response.setIsError(false); + + when(armRpoClient.getMasterIndexFieldByRecordClassSchema(eq(BEARER_TOKEN), any())) + .thenReturn(response); + } + + private void createAndSetGetProfileEntitlementsMock() { + var profileEntitlement = new ProfileEntitlementResponse.ProfileEntitlement(); + profileEntitlement.setName(ENTITLEMENT_NAME); + profileEntitlement.setEntitlementId(ENTITLEMENT_ID); + + var response = new ProfileEntitlementResponse(); + response.setEntitlements(Collections.singletonList(profileEntitlement)); + response.setStatus(200); + response.setIsError(false); + + when(armRpoClient.getProfileEntitlementResponse(BEARER_TOKEN)) + .thenReturn(response); + } + + private void createAndSetGetStorageAccountsMock() { + var indexDetails = new StorageAccountResponse.IndexDetails(); + indexDetails.setName(STORAGE_ACCOUNT_INDEX_NAME); + indexDetails.setIndexId(STORAGE_ACCOUNT_INDEX_ID); + + var index = new StorageAccountResponse.Index(); + index.setIndex(indexDetails); + + var response = new StorageAccountResponse(); + response.setIndexes(Collections.singletonList(index)); + response.setIsError(false); + response.setStatus(200); + + when(armRpoClient.getStorageAccounts(eq(BEARER_TOKEN), any())) + .thenReturn(response); + } + + private void createAndSetIndexesByMatterIdMock() { + var indexDetails = new IndexesByMatterIdResponse.IndexDetails(); + indexDetails.setIndexId(INDEX_ID); + + var index = new IndexesByMatterIdResponse.Index(); + index.setIndex(indexDetails); + + var response = new IndexesByMatterIdResponse(); + response.setIndexes(Collections.singletonList(index)); + response.setIsError(false); + response.setStatus(200); + + when(armRpoClient.getIndexesByMatterId(eq(BEARER_TOKEN), any())) + .thenReturn(response); + } + + private void createAndSetRecordManagementMatterMock() { + var recordManagementMatter = new RecordManagementMatterResponse.RecordManagementMatter(); + recordManagementMatter.setMatterId(MATTER_ID); + + var response = new RecordManagementMatterResponse(); + response.setRecordManagementMatter(recordManagementMatter); + response.setIsError(false); + response.setStatus(200); + + when(armRpoClient.getRecordManagementMatter(BEARER_TOKEN)) + .thenReturn(response); + } + +} diff --git a/src/main/java/uk/gov/hmcts/darts/arm/rpo/ArmRpoApi.java b/src/main/java/uk/gov/hmcts/darts/arm/rpo/ArmRpoApi.java index 4e53097bd1..32b8cb9a13 100644 --- a/src/main/java/uk/gov/hmcts/darts/arm/rpo/ArmRpoApi.java +++ b/src/main/java/uk/gov/hmcts/darts/arm/rpo/ArmRpoApi.java @@ -22,7 +22,7 @@ public interface ArmRpoApi { List getMasterIndexFieldByRecordClassSchema(String bearerToken, Integer executionId, ArmRpoStateEntity rpoStateEntity, UserAccountEntity userAccount); - void addAsyncSearch(String bearerToken, Integer executionId, UserAccountEntity userAccount); + String addAsyncSearch(String bearerToken, Integer executionId, UserAccountEntity userAccount); void saveBackgroundSearch(String bearerToken, Integer executionId, String searchName, UserAccountEntity userAccount); diff --git a/src/main/java/uk/gov/hmcts/darts/arm/rpo/impl/ArmRpoApiImpl.java b/src/main/java/uk/gov/hmcts/darts/arm/rpo/impl/ArmRpoApiImpl.java index 2aa5639dbe..a3880392eb 100644 --- a/src/main/java/uk/gov/hmcts/darts/arm/rpo/impl/ArmRpoApiImpl.java +++ b/src/main/java/uk/gov/hmcts/darts/arm/rpo/impl/ArmRpoApiImpl.java @@ -87,6 +87,9 @@ public void getRecordManagementMatter(String bearerToken, Integer executionId, U // this ensures the full error body containing the ARM error detail is logged rather than a truncated version log.error("Error during ARM get record management matter: {}", e.contentUTF8()); throw handleFailureAndCreateException(ARM_GET_RECORD_MANAGEMENT_MATTER_ERROR, armRpoExecutionDetailEntity, userAccount); + } catch (Exception e) { + log.error("Error during ARM get record management matter: {}", e.getMessage()); + throw handleFailureAndCreateException(ARM_GET_RECORD_MANAGEMENT_MATTER_ERROR, armRpoExecutionDetailEntity, userAccount); } handleResponseStatus(userAccount, recordManagementMatterResponse, errorMessage, armRpoExecutionDetailEntity); @@ -284,7 +287,7 @@ public List getMasterIndexFieldByRecordClas } @Override - public void addAsyncSearch(String bearerToken, Integer executionId, UserAccountEntity userAccount) { + public String addAsyncSearch(String bearerToken, Integer executionId, UserAccountEntity userAccount) { final ArmRpoExecutionDetailEntity executionDetail = armRpoService.getArmRpoExecutionDetailEntity(executionId); armRpoService.updateArmRpoStateAndStatus(executionDetail, @@ -334,6 +337,8 @@ public void addAsyncSearch(String bearerToken, Integer executionId, UserAccountE executionDetail.setSearchId(searchId); armRpoService.updateArmRpoStatus(executionDetail, ArmRpoHelper.completedRpoStatus(), userAccount); + + return searchName; } diff --git a/src/main/java/uk/gov/hmcts/darts/arm/service/ArmApiService.java b/src/main/java/uk/gov/hmcts/darts/arm/service/ArmApiService.java index 913f45535b..22746a2fac 100644 --- a/src/main/java/uk/gov/hmcts/darts/arm/service/ArmApiService.java +++ b/src/main/java/uk/gov/hmcts/darts/arm/service/ArmApiService.java @@ -11,4 +11,6 @@ public interface ArmApiService { UpdateMetadataResponse updateMetadata(String externalRecordId, OffsetDateTime eventTimestamp, int retConfScore, String retConfReason); DownloadResponseMetaData downloadArmData(String externalRecordId, String externalFileId) throws FileNotDownloadedException; + + String getArmBearerToken(); } \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/darts/arm/service/ArmRpoService.java b/src/main/java/uk/gov/hmcts/darts/arm/service/ArmRpoService.java index 6f011ef905..f2fc23fcbb 100644 --- a/src/main/java/uk/gov/hmcts/darts/arm/service/ArmRpoService.java +++ b/src/main/java/uk/gov/hmcts/darts/arm/service/ArmRpoService.java @@ -7,6 +7,8 @@ public interface ArmRpoService { + ArmRpoExecutionDetailEntity createArmRpoExecutionDetailEntity(UserAccountEntity userAccount); + ArmRpoExecutionDetailEntity getArmRpoExecutionDetailEntity(Integer executionId); void updateArmRpoStateAndStatus(ArmRpoExecutionDetailEntity armRpoExecutionDetailEntity, ArmRpoStateEntity armRpoStateEntity, diff --git a/src/main/java/uk/gov/hmcts/darts/arm/service/TriggerArmRpoSearchService.java b/src/main/java/uk/gov/hmcts/darts/arm/service/TriggerArmRpoSearchService.java new file mode 100644 index 0000000000..694ac74e41 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/darts/arm/service/TriggerArmRpoSearchService.java @@ -0,0 +1,5 @@ +package uk.gov.hmcts.darts.arm.service; + +public interface TriggerArmRpoSearchService { + void triggerArmRpoSearch(); +} diff --git a/src/main/java/uk/gov/hmcts/darts/arm/service/impl/ArmApiServiceImpl.java b/src/main/java/uk/gov/hmcts/darts/arm/service/impl/ArmApiServiceImpl.java index d8d562679f..1ed30869b1 100644 --- a/src/main/java/uk/gov/hmcts/darts/arm/service/impl/ArmApiServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/darts/arm/service/impl/ArmApiServiceImpl.java @@ -95,7 +95,8 @@ public DownloadResponseMetaData downloadArmData(String externalRecordId, String return responseMetaData; } - private String getArmBearerToken() { + @Override + public String getArmBearerToken() { log.debug("Get ARM Bearer Token with Username: {}, Password: {}", armApiConfigurationProperties.getArmUsername(), armApiConfigurationProperties.getArmPassword()); String accessToken = null; diff --git a/src/main/java/uk/gov/hmcts/darts/arm/service/impl/ArmRpoServiceImpl.java b/src/main/java/uk/gov/hmcts/darts/arm/service/impl/ArmRpoServiceImpl.java index 85a682d9e8..b00d76ceb9 100644 --- a/src/main/java/uk/gov/hmcts/darts/arm/service/impl/ArmRpoServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/darts/arm/service/impl/ArmRpoServiceImpl.java @@ -1,8 +1,10 @@ package uk.gov.hmcts.darts.arm.service.impl; +import jakarta.persistence.EntityManager; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import uk.gov.hmcts.darts.arm.service.ArmRpoService; import uk.gov.hmcts.darts.common.entity.ArmRpoExecutionDetailEntity; import uk.gov.hmcts.darts.common.entity.ArmRpoStateEntity; @@ -20,6 +22,19 @@ public class ArmRpoServiceImpl implements ArmRpoService { public static final String ARM_RPO_EXECUTION_DETAIL_NOT_FOUND = "ArmRpoExecutionDetail not found"; private final ArmRpoExecutionDetailRepository armRpoExecutionDetailRepository; + private final EntityManager entityManager; + + @Override + @Transactional + public ArmRpoExecutionDetailEntity createArmRpoExecutionDetailEntity(UserAccountEntity userAccount) { + ArmRpoExecutionDetailEntity armRpoExecutionDetailEntity = new ArmRpoExecutionDetailEntity(); + + UserAccountEntity mergedUserAccountEntity = entityManager.merge(userAccount); + armRpoExecutionDetailEntity.setCreatedBy(mergedUserAccountEntity); + armRpoExecutionDetailEntity.setLastModifiedBy(mergedUserAccountEntity); + + return saveArmRpoExecutionDetailEntity(armRpoExecutionDetailEntity); + } @Override public ArmRpoExecutionDetailEntity getArmRpoExecutionDetailEntity(Integer executionId) { @@ -53,4 +68,5 @@ public void updateArmRpoStatus(ArmRpoExecutionDetailEntity armRpoExecutionDetail public ArmRpoExecutionDetailEntity saveArmRpoExecutionDetailEntity(ArmRpoExecutionDetailEntity armRpoExecutionDetailEntity) { return armRpoExecutionDetailRepository.save(armRpoExecutionDetailEntity); } + } diff --git a/src/main/java/uk/gov/hmcts/darts/arm/service/impl/TriggerArmRpoSearchServiceImpl.java b/src/main/java/uk/gov/hmcts/darts/arm/service/impl/TriggerArmRpoSearchServiceImpl.java new file mode 100644 index 0000000000..7c348e0878 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/darts/arm/service/impl/TriggerArmRpoSearchServiceImpl.java @@ -0,0 +1,78 @@ +package uk.gov.hmcts.darts.arm.service.impl; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.darts.arm.helper.ArmRpoHelper; +import uk.gov.hmcts.darts.arm.rpo.ArmRpoApi; +import uk.gov.hmcts.darts.arm.service.ArmApiService; +import uk.gov.hmcts.darts.arm.service.ArmRpoService; +import uk.gov.hmcts.darts.authorisation.component.UserIdentity; + +@Slf4j +@Service +@RequiredArgsConstructor +public class TriggerArmRpoSearchServiceImpl implements uk.gov.hmcts.darts.arm.service.TriggerArmRpoSearchService { + + private final ArmRpoApi armRpoApi; + private final ArmRpoService armRpoService; + private final ArmApiService armApiService; + private final UserIdentity userIdentity; + + /** + * This method integrates various ARM RPO API calls to ultimately trigger a search. The results of that search are then processed by another automated + * task. + *

+ * If any of the underlying ArmRpoApi methods fail, ArmRpoApi will explicitly set the arm_rpo_execution_detail status to FAILED for that + * particular stage. So if you're thinking about adding any transactionality at the level of TriggerArmRpoSearchServiceImpl please be careful to avoid + * unwanted arm_rpo_execution_detail rollbacks. + */ + @Override + public void triggerArmRpoSearch() { + log.debug("Triggering ARM RPO search flow..."); + + var userAccountEntity = userIdentity.getUserAccount(); + + final Integer executionId = armRpoService.createArmRpoExecutionDetailEntity(userAccountEntity) + .getId(); + + // armBearerToken may be null, but we'll let the lower level service methods deal with that by handling the resultant HTTP exception + final String armBearerToken = armApiService.getArmBearerToken(); + + armRpoApi.getRecordManagementMatter(armBearerToken, + executionId, + userAccountEntity); + + // We expect getRecordManagementMatter() to populate the matter id as a side effect, so refresh the entity to get the updated value + final String matterId = armRpoService.getArmRpoExecutionDetailEntity(executionId) + .getMatterId(); + armRpoApi.getIndexesByMatterId(armBearerToken, + executionId, + matterId, + userAccountEntity); + + armRpoApi.getStorageAccounts(armBearerToken, + executionId, + userAccountEntity); + + armRpoApi.getProfileEntitlements(armBearerToken, + executionId, + userAccountEntity); + + armRpoApi.getMasterIndexFieldByRecordClassSchema(armBearerToken, + executionId, + ArmRpoHelper.getMasterIndexFieldByRecordClassSchemaPrimaryRpoState(), + userAccountEntity); + + String searchName = armRpoApi.addAsyncSearch(armBearerToken, + executionId, + userAccountEntity); + + armRpoApi.saveBackgroundSearch(armBearerToken, + executionId, + searchName, + userAccountEntity); + log.debug("ARM RPO search flow completed successfully"); + } + +} diff --git a/src/main/java/uk/gov/hmcts/darts/common/datamanagement/api/DataManagementFacadeImpl.java b/src/main/java/uk/gov/hmcts/darts/common/datamanagement/api/DataManagementFacadeImpl.java index 6f836afbf4..1f671c6a3a 100644 --- a/src/main/java/uk/gov/hmcts/darts/common/datamanagement/api/DataManagementFacadeImpl.java +++ b/src/main/java/uk/gov/hmcts/darts/common/datamanagement/api/DataManagementFacadeImpl.java @@ -6,7 +6,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.springframework.stereotype.Service; -import uk.gov.hmcts.darts.arm.service.impl.ArmApiServiceImpl; +import uk.gov.hmcts.darts.arm.service.ArmApiService; import uk.gov.hmcts.darts.audio.helper.UnstructuredDataHelper; import uk.gov.hmcts.darts.common.datamanagement.component.impl.DownloadResponseMetaData; import uk.gov.hmcts.darts.common.datamanagement.component.impl.FileBasedDownloadResponseMetaData; @@ -51,7 +51,7 @@ public class DataManagementFacadeImpl implements DataManagementFacade { private final StorageOrderHelper storageOrderHelper; private final UnstructuredDataHelper unstructuredDataHelper; private final DataManagementConfiguration dataManagementConfiguration; - private final ArmApiServiceImpl armApiService; + private final ArmApiService armApiService; private final ObjectRetrievalQueueRepository objectRetrievalQueueRepository; @Override diff --git a/src/main/java/uk/gov/hmcts/darts/task/runner/impl/ProcessE2EArmRpoPendingAutomatedTask.java b/src/main/java/uk/gov/hmcts/darts/task/runner/impl/ProcessE2EArmRpoPendingAutomatedTask.java new file mode 100644 index 0000000000..e41fc63878 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/darts/task/runner/impl/ProcessE2EArmRpoPendingAutomatedTask.java @@ -0,0 +1,38 @@ +package uk.gov.hmcts.darts.task.runner.impl; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.darts.arm.service.TriggerArmRpoSearchService; +import uk.gov.hmcts.darts.common.repository.AutomatedTaskRepository; +import uk.gov.hmcts.darts.log.api.LogApi; +import uk.gov.hmcts.darts.task.api.AutomatedTaskName; +import uk.gov.hmcts.darts.task.config.AutomatedTaskConfigurationProperties; +import uk.gov.hmcts.darts.task.runner.AutoloadingManualTask; +import uk.gov.hmcts.darts.task.service.LockService; + +@Slf4j +@Component +public class ProcessE2EArmRpoPendingAutomatedTask extends AbstractLockableAutomatedTask implements AutoloadingManualTask { + + private final TriggerArmRpoSearchService triggerArmRpoSearchService; + + protected ProcessE2EArmRpoPendingAutomatedTask(AutomatedTaskRepository automatedTaskRepository, + AutomatedTaskConfigurationProperties automatedTaskConfigurationProperties, + LogApi logApi, + LockService lockService, + TriggerArmRpoSearchService triggerArmRpoSearchService) { + super(automatedTaskRepository, automatedTaskConfigurationProperties, logApi, lockService); + this.triggerArmRpoSearchService = triggerArmRpoSearchService; + } + + @Override + protected void runTask() { + triggerArmRpoSearchService.triggerArmRpoSearch(); + } + + @Override + public AutomatedTaskName getAutomatedTaskName() { + return AutomatedTaskName.PROCESS_E2E_ARM_PENDING_TASK_NAME; + } + +} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index df84785964..651aac941e 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -286,7 +286,7 @@ darts: download-data-path: /api/v1/downloadBlob/{cabinet_id}/{record_id}/{file_id} rpo-url: get-record-management-matter-path: /api/v1/getRecordManagementMatter - get-storage-accounts: /api/v1/getStorageAccounts + get-storage-accounts-path: /api/v1/getStorageAccounts get-indexes-by-matter-id-path: /api/v1/getIndexesByMatterId get-master-index-field-by-record-class-schema-path: /api/v1/getMasterIndexFieldByRecordClassSchema get-profile-entitlements-path: /api/v1/getProfileEntitlements