Skip to content

Commit

Permalink
DMP-4221: (Dev Only)Remove ARM's single mode logic (#2250)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Edwards-cgi authored Nov 15, 2024
1 parent af6caae commit 6206a83
Show file tree
Hide file tree
Showing 32 changed files with 14 additions and 5,500 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
import org.springframework.scheduling.config.TriggerTask;
import org.springframework.scheduling.support.CronExpression;
import uk.gov.hmcts.darts.arm.service.ArmRetentionEventDateProcessor;
import uk.gov.hmcts.darts.arm.service.CleanupArmResponseFilesService;
import uk.gov.hmcts.darts.arm.service.impl.ArmBatchProcessResponseFilesImpl;
import uk.gov.hmcts.darts.arm.service.impl.ArmResponseFilesProcessorImpl;
import uk.gov.hmcts.darts.arm.service.impl.UnstructuredToArmBatchProcessorImpl;
import uk.gov.hmcts.darts.arm.service.impl.UnstructuredToArmProcessorImpl;
import uk.gov.hmcts.darts.audio.deleter.impl.inbound.ExternalInboundDataStoreDeleter;
import uk.gov.hmcts.darts.audio.deleter.impl.outbound.ExternalOutboundDataStoreDeleter;
import uk.gov.hmcts.darts.audio.deleter.impl.unstructured.ExternalUnstructuredDataStoreDeleter;
Expand All @@ -47,7 +44,6 @@
import uk.gov.hmcts.darts.task.api.AutomatedTaskName;
import uk.gov.hmcts.darts.task.config.ApplyRetentionCaseAssociatedObjectsAutomatedTaskConfig;
import uk.gov.hmcts.darts.task.config.ArmRetentionEventDateCalculatorAutomatedTaskConfig;
import uk.gov.hmcts.darts.task.config.CleanupArmResponseFilesAutomatedTaskConfig;
import uk.gov.hmcts.darts.task.config.CloseOldCasesAutomatedTaskConfig;
import uk.gov.hmcts.darts.task.config.CloseUnfinishedTranscriptionsAutomatedTaskConfig;
import uk.gov.hmcts.darts.task.config.DailyListAutomatedTaskConfig;
Expand All @@ -67,7 +63,6 @@
import uk.gov.hmcts.darts.task.runner.impl.AbstractLockableAutomatedTask;
import uk.gov.hmcts.darts.task.runner.impl.ApplyRetentionCaseAssociatedObjectsAutomatedTask;
import uk.gov.hmcts.darts.task.runner.impl.ArmRetentionEventDateCalculatorAutomatedTask;
import uk.gov.hmcts.darts.task.runner.impl.CleanupArmResponseFilesAutomatedTask;
import uk.gov.hmcts.darts.task.runner.impl.CloseOldCasesAutomatedTask;
import uk.gov.hmcts.darts.task.runner.impl.CloseUnfinishedTranscriptionsAutomatedTask;
import uk.gov.hmcts.darts.task.runner.impl.DailyListAutomatedTask;
Expand Down Expand Up @@ -131,8 +126,6 @@ class AutomatedTaskServiceTest extends IntegrationBase {
@Autowired
private UnstructuredAudioDeleterProcessor unstructuredAudioDeleterProcessor;
@Autowired
private CleanupArmResponseFilesService cleanupArmResponseFilesService;
@Autowired
private CloseOldCasesProcessor closeOldCasesProcessor;
@Autowired
private DailyListService dailyListService;
Expand All @@ -151,15 +144,12 @@ class AutomatedTaskServiceTest extends IntegrationBase {
@Autowired
private ArmBatchProcessResponseFilesImpl armBatchProcessResponseFiles;
@Autowired
private ArmResponseFilesProcessorImpl armResponseFilesProcessor;
@Autowired
private GenerateCaseDocumentForRetentionDateProcessor generateCaseDocumentForRetentionDateProcessor;
@Autowired
private LogApi logApi;
@Autowired
private LockService lockService;
@Autowired
UnstructuredToArmProcessorImpl unstructuredToArmProcessor;

@Autowired
UnstructuredToArmBatchProcessorImpl unstructuredToArmBatchProcessor;
@MockBean
Expand Down Expand Up @@ -649,7 +639,6 @@ void givenConfiguredTasksUpdateCronAndResetCronForUnstructuredToArmAutomatedTask
automatedTaskRepository,
mock(UnstructuredToArmAutomatedTaskConfig.class),
unstructuredToArmBatchProcessor,
unstructuredToArmProcessor,
logApi,
lockService
);
Expand Down Expand Up @@ -684,7 +673,6 @@ void givenConfiguredTaskCancelUnstructuredToArmAutomatedTask() {
automatedTaskRepository,
mock(UnstructuredToArmAutomatedTaskConfig.class),
unstructuredToArmBatchProcessor,
unstructuredToArmProcessor,
logApi,
lockService
);
Expand Down Expand Up @@ -713,8 +701,7 @@ void givenConfiguredTasksUpdateCronAndResetCronForProcessArmResponseFilesAutomat
mock(ProcessArmResponseFilesAutomatedTaskConfig.class),
logApi,
lockService,
armBatchProcessResponseFiles,
armResponseFilesProcessor
armBatchProcessResponseFiles
);

Optional<AutomatedTaskEntity> originalAutomatedTaskEntity =
Expand Down Expand Up @@ -746,8 +733,7 @@ void givenConfiguredTaskCancelProcessArmResponseFilesAutomatedTask() {
mock(ProcessArmResponseFilesAutomatedTaskConfig.class),
logApi,
lockService,
armBatchProcessResponseFiles,
armResponseFilesProcessor
armBatchProcessResponseFiles
);

Set<ScheduledTask> scheduledTasks = scheduledTaskHolder.getScheduledTasks();
Expand All @@ -765,65 +751,6 @@ void givenConfiguredTaskCancelProcessArmResponseFilesAutomatedTask() {

}

@Test
void givenConfiguredTasksUpdateCronAndResetCronForCleanupArmResponseFilesAutomatedTask() {
AutomatedTask automatedTask =
new CleanupArmResponseFilesAutomatedTask(
automatedTaskRepository,
mock(CleanupArmResponseFilesAutomatedTaskConfig.class),
cleanupArmResponseFilesService,
logApi,
lockService
);

Optional<AutomatedTaskEntity> originalAutomatedTaskEntity =
automatedTaskService.getAutomatedTaskEntityByTaskName(automatedTask.getTaskName());
log.info("TEST - Original task {} cron expression {}", automatedTask.getTaskName(),
originalAutomatedTaskEntity.get().getCronExpression()
);

automatedTaskService.updateAutomatedTaskCronExpression(automatedTask.getTaskName(), "*/9 * * * * *");

Set<ScheduledTask> scheduledTasks = scheduledTaskHolder.getScheduledTasks();
displayTasks(scheduledTasks);

Optional<AutomatedTaskEntity> updatedAutomatedTaskEntity =
automatedTaskService.getAutomatedTaskEntityByTaskName(automatedTask.getTaskName());
log.info("TEST - Updated task {} cron expression {}", automatedTask.getTaskName(),
updatedAutomatedTaskEntity.get().getCronExpression()
);
assertEquals(originalAutomatedTaskEntity.get().getTaskName(), updatedAutomatedTaskEntity.get().getTaskName());
assertNotEquals(originalAutomatedTaskEntity.get().getCronExpression(), updatedAutomatedTaskEntity.get().getCronExpression());

automatedTaskService.updateAutomatedTaskCronExpression(
automatedTask.getTaskName(), originalAutomatedTaskEntity.get().getCronExpression());
}

@Test
void givenConfiguredTaskCancelCleanupArmResponseFilesAutomatedTask() {
AutomatedTask automatedTask =
new CleanupArmResponseFilesAutomatedTask(
automatedTaskRepository,
mock(CleanupArmResponseFilesAutomatedTaskConfig.class),
cleanupArmResponseFilesService,
logApi,
lockService
);

Set<ScheduledTask> scheduledTasks = scheduledTaskHolder.getScheduledTasks();
displayTasks(scheduledTasks);

boolean mayInterruptIfRunning = false;
boolean taskCancelled = automatedTaskService.cancelAutomatedTask(
automatedTask.getTaskName(),
mayInterruptIfRunning
);
assertTrue(taskCancelled);

log.info("About to reload task {}", automatedTask.getTaskName());
automatedTaskService.reloadTaskByName(automatedTask.getTaskName());
}

@Test
void givenConfiguredTaskCloseOldCasesAutomatedTask() {
AutomatedTask automatedTask =
Expand Down
Loading

0 comments on commit 6206a83

Please sign in to comment.