diff --git a/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java b/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java index a54355cea51..85bf880ebe6 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java @@ -94,6 +94,7 @@ public enum CaseEvent { GENERATE_TRIAL_READY_DOCUMENT_RESPONDENT1(USER), GENERATE_TRIAL_READY_DOCUMENT_RESPONDENT2(USER), LIP_CLAIM_SETTLED(USER), + TRIGGER_TASK_RECONFIG(USER), NOTIFY_FORMER_SOLICITOR(CAMUNDA), NOTIFY_OTHER_SOLICITOR_1(CAMUNDA), NOTIFY_OTHER_SOLICITOR_2(CAMUNDA), @@ -300,7 +301,8 @@ public enum CaseEvent { NOTIFY_LIP_RESPONDENT_CLAIMANT_CONFIRM_TO_PROCEED(CAMUNDA), NOTIFY_LIP_APPLICANT_CLAIMANT_CONFIRM_TO_PROCEED(CAMUNDA), NOTIFY_APPLICANT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT(CAMUNDA), - NOTIFY_RESPONDENT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT(CAMUNDA); + NOTIFY_RESPONDENT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT(CAMUNDA), + TRIGGER_TASK_RECONFIG_GA(CAMUNDA); private final UserType userType; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandler.java index 6a7c730596d..4664afc38b7 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandler.java @@ -20,13 +20,16 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_LOCATION_UPDATE; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_UPDATE_GA_LOCATION; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_TASK_RECONFIG; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_TASK_RECONFIG_GA; @Slf4j @Service @RequiredArgsConstructor public class TriggerGenAppLocationUpdateCallbackHandler extends CallbackHandler { - private static final List EVENTS = List.of(TRIGGER_UPDATE_GA_LOCATION); + private static final List EVENTS = List.of(TRIGGER_UPDATE_GA_LOCATION, + TRIGGER_TASK_RECONFIG_GA); private final GenAppStateHelperService helperService; private final ObjectMapper objectMapper; @@ -49,7 +52,11 @@ private CallbackResponse triggerGaEvent(CallbackParams callbackParams) { try { if (caseData.getGeneralApplications() != null && !caseData.getGeneralApplications().isEmpty()) { caseData = helperService.updateApplicationLocationDetailsInClaim(caseData, authToken); - helperService.triggerEvent(caseData, TRIGGER_LOCATION_UPDATE); + if (callbackParams.getRequest().getEventId().equals(TRIGGER_UPDATE_GA_LOCATION.name())) { + helperService.triggerEvent(caseData, TRIGGER_LOCATION_UPDATE); + } else if (callbackParams.getRequest().getEventId().equals(TRIGGER_TASK_RECONFIG_GA.name())) { + helperService.triggerEvent(caseData, TRIGGER_TASK_RECONFIG); + } } } catch (Exception e) { String errorMessage = "Could not trigger event to update location on application under case: " diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandler.java index 85837b957ac..9aa24b4646f 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandler.java @@ -12,6 +12,7 @@ import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.callback.CaseEvent; import uk.gov.hmcts.reform.civil.helpers.LocationHelper; +import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.common.DynamicList; import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; @@ -22,7 +23,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; - import static java.util.Objects.nonNull; import static uk.gov.hmcts.reform.civil.callback.CallbackParams.Params.BEARER_TOKEN; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; @@ -30,6 +30,7 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.MID; import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRANSFER_ONLINE_CASE; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_TASK_RECONFIG_GA; import static uk.gov.hmcts.reform.civil.model.common.DynamicList.fromList; @Service @@ -110,10 +111,12 @@ private CallbackResponse saveTransferOnlineCase(CallbackParams callbackParams) { callbackParams.getCaseData().getTransferCourtLocationList()); if (nonNull(newCourtLocation)) { caseDataBuilder.caseManagementLocation(LocationHelper.buildCaseLocation(newCourtLocation)); + caseDataBuilder.locationName(newCourtLocation.getSiteName()); } DynamicList tempLocationList = caseData.getTransferCourtLocationList(); tempLocationList.setListItems(null); caseDataBuilder.transferCourtLocationList(tempLocationList); + caseDataBuilder.businessProcess(BusinessProcess.ready(TRIGGER_TASK_RECONFIG_GA)); return AboutToStartOrSubmitCallbackResponse.builder() .data(caseDataBuilder.build().toMap(objectMapper)) .build(); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandlerTest.java index 53cd99df257..b2a913e47bc 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandlerTest.java @@ -8,9 +8,11 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; +import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.sampledata.CallbackParamsBuilder; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.sampledata.GeneralApplicationDetailsBuilder; import uk.gov.hmcts.reform.civil.service.GenAppStateHelperService; @@ -28,8 +30,10 @@ import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_LOCATION_UPDATE; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_UPDATE_GA_LOCATION; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_TASK_RECONFIG_GA; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_LOCATION_UPDATE; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_TASK_RECONFIG; @ExtendWith(SpringExtension.class) @SpringBootTest(classes = { @@ -51,6 +55,7 @@ class TriggerGenAppLocationUpdateCallbackHandlerTest extends BaseCallbackHandler @Test void handleEventsReturnsTheExpectedCallbackEvent() { assertThat(handler.handledEvents()).contains(TRIGGER_UPDATE_GA_LOCATION); + assertThat(handler.handledEvents()).contains(TRIGGER_TASK_RECONFIG_GA); } @Test @@ -63,7 +68,12 @@ void shouldTriggerGeneralApplicationEvent_whenCaseHasGeneralApplication() { getOriginalStatusOfGeneralApplication() ); when(helperService.updateApplicationLocationDetailsInClaim(any(), any())).thenReturn(caseData); - CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + CallbackParams params = CallbackParamsBuilder.builder() + .of(ABOUT_TO_SUBMIT, caseData) + .request(CallbackRequest.builder() + .eventId(TRIGGER_UPDATE_GA_LOCATION.name()) + .build()) + .build(); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); assertThat(response.getErrors()).isNull(); @@ -106,6 +116,27 @@ void triggerGeneralApplicationEventThrowsException_HandleFailure() { assertThat(response.getErrors()).contains(expectedErrorMessage); } + @Test + void shouldTriggerReconfigureWhenCallbackEventIsReconfigGA() { + CaseData caseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDetails(CaseData.builder().build(), + true, + true, + true, true, + getOriginalStatusOfGeneralApplication() + ); + when(helperService.updateApplicationLocationDetailsInClaim(any(), any())).thenReturn(caseData); + CallbackParams callbackParams = CallbackParamsBuilder.builder() + .of(ABOUT_TO_SUBMIT, caseData) + .request(CallbackRequest.builder() + .eventId(TRIGGER_TASK_RECONFIG_GA.name()) + .build()) + .build(); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(callbackParams); + assertThat(response.getErrors()).isNull(); + verify(helperService, times(1)).triggerEvent(caseData, TRIGGER_TASK_RECONFIG); + } + private Map getOriginalStatusOfGeneralApplication() { Map latestStatus = new HashMap<>(); latestStatus.put("1234", "Application Submitted - Awaiting Judicial Decision"); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandlerTest.java index b68d54ff9e8..19f87d67765 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandlerTest.java @@ -228,4 +228,4 @@ void shouldReturnExpectedSubmittedCallbackResponse() { void handleEventsReturnsTheExpectedCallbackEvent() { assertThat(handler.handledEvents()).contains(CaseEvent.TRANSFER_ONLINE_CASE); } -} +} \ No newline at end of file