Skip to content

Commit 4f00ec5

Browse files
committed
SSCS-10722 Pass case ID to migration steps.
1 parent f4405f9 commit 4f00ec5

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

modules/processor/src/main/java/uk/gov/hmcts/reform/migration/CaseMigrationProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private void updateCase(String authorisation, Long id, Map<String, Object> data,
164164
totalCases++;
165165

166166
try {
167-
var migratedData = dataMigrationService.migrate(data);
167+
var migratedData = dataMigrationService.migrate(data, id);
168168
if (!dryRun) {
169169
coreCaseDataService.update(
170170
authorisation,

modules/processor/src/main/java/uk/gov/hmcts/reform/migration/service/DataMigrationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
public interface DataMigrationService<T> {
99
Predicate<CaseDetails> accepts();
1010

11-
T migrate(Map<String, Object> data);
11+
T migrate(Map<String, Object> data, Long id);
1212
}

modules/processor/src/test/java/uk/gov/hmcts/reform/migration/CaseMigrationProcessorTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void shouldProcessASingleCaseAndMigrationIsSuccessful() {
7474
public void shouldProcessASingleCaseAndMigrationIsFailed() {
7575
when(coreCaseDataService.fetchOne(USER_TOKEN, CASE_ID)).thenReturn(caseDetails1);
7676
when(dataMigrationService.accepts()).thenReturn(candidate -> true);
77-
when(dataMigrationService.migrate(caseDetails1.getData())).thenReturn(caseDetails1.getData());
77+
when(dataMigrationService.migrate(caseDetails1.getData(), caseDetails1.getId())).thenReturn(caseDetails1.getData());
7878
when(coreCaseDataService.update(USER_TOKEN, caseDetails1.getId().toString(), EVENT_ID, EVENT_SUMMARY, EVENT_DESCRIPTION, caseDetails1.getData())).thenThrow(new RuntimeException("Internal server error"));
7979
caseMigrationProcessor.processSingleCase(USER_TOKEN, CASE_ID, false);
8080
verify(coreCaseDataService, times(1)).fetchOne(USER_TOKEN, CASE_ID);
@@ -89,9 +89,9 @@ public void shouldProcessAllTheCandidateCases_whenOneCaseFailed() {
8989
mockDataUpdate(caseDetails1);
9090
mockDataUpdate(caseDetails2);
9191
when(dataMigrationService.accepts()).thenReturn(candidate -> true);
92-
when(dataMigrationService.migrate(caseDetails1.getData())).thenReturn(caseDetails1.getData());
93-
when(dataMigrationService.migrate(caseDetails2.getData())).thenReturn(caseDetails2.getData());
94-
when(dataMigrationService.migrate(caseDetails3.getData())).thenReturn(caseDetails3.getData());
92+
when(dataMigrationService.migrate(caseDetails1.getData(), caseDetails1.getId())).thenReturn(caseDetails1.getData());
93+
when(dataMigrationService.migrate(caseDetails2.getData(), caseDetails2.getId())).thenReturn(caseDetails2.getData());
94+
when(dataMigrationService.migrate(caseDetails3.getData(), caseDetails3.getId())).thenReturn(caseDetails3.getData());
9595
when(coreCaseDataService.update(USER_TOKEN, caseDetails3.getId().toString(), EVENT_ID, EVENT_SUMMARY, EVENT_DESCRIPTION, caseDetails3.getData())).thenThrow(new RuntimeException("Internal server error"));
9696
caseMigrationProcessor.processAllCases(USER_TOKEN, USER_ID, false);
9797
assertThat(caseMigrationProcessor.getFailedCases(), contains(1113L));
@@ -103,9 +103,9 @@ public void shouldProcessAllTheCandidateCases_whenTwoCasesFailed() {
103103
mockDataFetch(caseDetails1, caseDetails2, caseDetails3);
104104
mockDataUpdate(caseDetails1);
105105
when(dataMigrationService.accepts()).thenReturn(candidate -> true);
106-
when(dataMigrationService.migrate(caseDetails1.getData())).thenReturn(caseDetails1.getData());
107-
when(dataMigrationService.migrate(caseDetails2.getData())).thenReturn(caseDetails2.getData());
108-
when(dataMigrationService.migrate(caseDetails3.getData())).thenReturn(caseDetails3.getData());
106+
when(dataMigrationService.migrate(caseDetails1.getData(), caseDetails1.getId())).thenReturn(caseDetails1.getData());
107+
when(dataMigrationService.migrate(caseDetails2.getData(), caseDetails2.getId())).thenReturn(caseDetails2.getData());
108+
when(dataMigrationService.migrate(caseDetails3.getData(), caseDetails3.getId())).thenReturn(caseDetails3.getData());
109109
when(coreCaseDataService.update(USER_TOKEN, caseDetails2.getId().toString(), EVENT_ID, EVENT_SUMMARY, EVENT_DESCRIPTION, caseDetails2.getData())).thenThrow(new RuntimeException("Internal server error"));
110110
when(coreCaseDataService.update(USER_TOKEN, caseDetails3.getId().toString(), EVENT_ID, EVENT_SUMMARY, EVENT_DESCRIPTION, caseDetails3.getData())).thenThrow(new RuntimeException("Internal server error"));
111111
caseMigrationProcessor.processAllCases(USER_TOKEN, USER_ID, false);

0 commit comments

Comments
 (0)