diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/DashboardScenarios.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/DashboardScenarios.java index 99cc8565988..7b911dda3b9 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/DashboardScenarios.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/DashboardScenarios.java @@ -145,6 +145,14 @@ public enum DashboardScenarios { SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_CLAIMANT("Scenario.AAA6.CaseProceedsInCaseman.Claimant"), SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_DEFENDANT("Scenario.AAA6.CaseProceedsInCaseman.Defendant"), SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_CLAIMANT_WITHOUT_TASK_CHANGES("Scenario.AAA6.CaseProceedsInCaseman.Claimant.FastTrack"), + SCENARIO_AAA6_GENERAL_APPLICATION_INITIATE_APPLICATION_INACTIVE_CLAIMANT( + "Scenario.AAA6.GeneralApplication.InitiateApplication.Inactive.Claimant"), + SCENARIO_AAA6_GENERAL_APPLICATION_INITIATE_APPLICATION_INACTIVE_DEFENDANT( + "Scenario.AAA6.GeneralApplication.InitiateApplication.Inactive.Defendant"), + SCENARIO_AAA6_GENERAL_APPLICATION_AVAILABLE_DEFENDANT( + "Scenario.AAA6.GeneralApplication.ViewApplicationAvailable.Defendant"), + SCENARIO_AAA6_GENERAL_APPLICATION_AVAILABLE_CLAIMANT( + "Scenario.AAA6.GeneralApplication.ViewApplicationAvailable.Claimant"), SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_DEFENDANT_WITHOUT_TASK_CHANGES("Scenario.AAA6.CaseProceedsInCaseman.Defendant.FastTrack"), SCENARIO_AAA6_CP_HEARING_DOCUMENTS_UPLOADED_CLAIMANT("Scenario.AAA6.CP.HearingDocuments.Uploaded.Claimant"), SCENARIO_AAA6_CP_HEARING_DOCUMENTS_NOT_UPLOADED_CLAIMANT("Scenario.AAA6.CP.HearingDocuments.NotUploaded.Claimant"), diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/claimant/CaseProceedOfflineClaimantNotificationHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/claimant/CaseProceedOfflineClaimantNotificationHandler.java index 7d9a76eccbc..f12b8324541 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/claimant/CaseProceedOfflineClaimantNotificationHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/claimant/CaseProceedOfflineClaimantNotificationHandler.java @@ -13,10 +13,13 @@ import uk.gov.hmcts.reform.dashboard.services.TaskListService; import java.util.List; +import java.util.Map; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_CLAIMANT_DASHBOARD_NOTIFICATION_FOR_CASE_PROCEED_OFFLINE; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_CLAIMANT; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_CLAIMANT_WITHOUT_TASK_CHANGES; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_AVAILABLE_CLAIMANT; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_INITIATE_APPLICATION_INACTIVE_CLAIMANT; @Service public class CaseProceedOfflineClaimantNotificationHandler extends DashboardCallbackHandler { @@ -32,6 +35,7 @@ public class CaseProceedOfflineClaimantNotificationHandler extends DashboardCall CaseState.DECISION_OUTCOME, CaseState.All_FINAL_ORDERS_ISSUED); public static final String TASK_ID = "GenerateClaimantDashboardNotificationCaseProceedOffline"; + public static final String GA = "Applications"; private final DashboardNotificationService dashboardNotificationService; private final TaskListService taskListService; @@ -58,6 +62,16 @@ public String getScenario(CaseData caseData) { return SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_CLAIMANT.getScenario(); } + @Override + public Map getScenarios(CaseData caseData) { + return Map.of( + SCENARIO_AAA6_GENERAL_APPLICATION_INITIATE_APPLICATION_INACTIVE_CLAIMANT.getScenario(), + featureToggleService.isGaForLipsEnabled(), + SCENARIO_AAA6_GENERAL_APPLICATION_AVAILABLE_CLAIMANT.getScenario(), + featureToggleService.isGaForLipsEnabled() && caseData.getGeneralApplications().size() > 0 + ); + } + @Override public String camundaActivityId(CallbackParams callbackParams) { return TASK_ID; @@ -87,7 +101,7 @@ protected void beforeRecordScenario(CaseData caseData, String authToken) { taskListService.makeProgressAbleTasksInactiveForCaseIdentifierAndRole( caseId, "CLAIMANT", - null + GA ); } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/defendant/CaseProceedOfflineDefendantNotificationHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/defendant/CaseProceedOfflineDefendantNotificationHandler.java index 736fe60e3a0..564189835e1 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/defendant/CaseProceedOfflineDefendantNotificationHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/defendant/CaseProceedOfflineDefendantNotificationHandler.java @@ -13,8 +13,11 @@ import uk.gov.hmcts.reform.dashboard.services.TaskListService; import java.util.List; +import java.util.Map; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_DEFENDANT_DASHBOARD_NOTIFICATION_FOR_CASE_PROCEED_OFFLINE; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_AVAILABLE_DEFENDANT; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_INITIATE_APPLICATION_INACTIVE_DEFENDANT; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_DEFENDANT; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_DEFENDANT_WITHOUT_TASK_CHANGES; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_UPDATE_CASE_PROCEED_IN_CASE_MAN_DEFENDANT; @@ -34,6 +37,7 @@ public class CaseProceedOfflineDefendantNotificationHandler extends DashboardCal CaseState.DECISION_OUTCOME, CaseState.All_FINAL_ORDERS_ISSUED); public static final String TASK_ID = "GenerateDefendantDashboardNotificationCaseProceedOffline"; + public static final String GA = "Applications"; private final DashboardNotificationService dashboardNotificationService; private final TaskListService taskListService; @@ -66,6 +70,17 @@ public String getScenario(CaseData caseData) { return SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_DEFENDANT.getScenario(); } + @Override + public Map getScenarios(CaseData caseData) { + + return Map.of( + SCENARIO_AAA6_GENERAL_APPLICATION_INITIATE_APPLICATION_INACTIVE_DEFENDANT.getScenario(), + featureToggleService.isGaForLipsEnabled(), + SCENARIO_AAA6_GENERAL_APPLICATION_AVAILABLE_DEFENDANT.getScenario(), + featureToggleService.isGaForLipsEnabled() && caseData.getGeneralApplications().size() > 0 + ); + } + @Override public List handledEvents() { return EVENTS; @@ -95,16 +110,7 @@ protected void beforeRecordScenario(CaseData caseData, String authToken) { taskListService.makeProgressAbleTasksInactiveForCaseIdentifierAndRole( caseId, "DEFENDANT", - null + GA ); - - if (caseData.getGeneralApplications() != null && !caseData.getGeneralApplications().isEmpty()) { - caseData.getGeneralApplications() - .forEach(application -> - dashboardNotificationService.deleteByReferenceAndCitizenRole( - application.getValue().getCaseLink().getCaseReference(), - "APPLICANT" - )); - } } } diff --git a/src/main/resources/db/migration/V2025_02_13_1701__CIV-16594-general-initiate-application-inactive.sql b/src/main/resources/db/migration/V2025_02_13_1701__CIV-16594-general-initiate-application-inactive.sql new file mode 100644 index 00000000000..28b2645cdfb --- /dev/null +++ b/src/main/resources/db/migration/V2025_02_13_1701__CIV-16594-general-initiate-application-inactive.sql @@ -0,0 +1,20 @@ +/** + * Add scenario + */ +INSERT INTO dbs.scenario (name, notifications_to_delete, notifications_to_create) +VALUES ('Scenario.AAA6.GeneralApplication.InitiateApplication.Inactive.Claimant', '{}', '{}'), + ('Scenario.AAA6.GeneralApplication.InitiateApplication.Inactive.Defendant', '{}', '{}'); + +/** + * Add task list items + */ +INSERT INTO dbs.task_item_template (task_name_en, category_en, task_name_cy, category_cy, template_name, + scenario_name, task_status_sequence, role, task_order) +values ('Contact the court to request a change to my case', + 'Applications', 'Cysylltu â’r llys i wneud cais am newid i fy achos', + 'Ceisiadau', 'Application.Create', 'Scenario.AAA6.GeneralApplication.InitiateApplication.Inactive.Claimant', + '{2, 2}', 'CLAIMANT', 16), + ('Contact the court to request a change to my case', + 'Applications', 'Cysylltu â’r llys i wneud cais am newid i fy achos', + 'Ceisiadau', 'Application.Create', 'Scenario.AAA6.GeneralApplication.InitiateApplication.Inactive.Defendant', + '{2, 2}', 'DEFENDANT', 16); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/claimant/CaseProceedOfflineClaimantNotificationHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/claimant/CaseProceedOfflineClaimantNotificationHandlerTest.java index 1d641203994..4fd94bd47fa 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/claimant/CaseProceedOfflineClaimantNotificationHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/claimant/CaseProceedOfflineClaimantNotificationHandlerTest.java @@ -11,6 +11,8 @@ import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.model.common.Element; +import uk.gov.hmcts.reform.civil.model.genapplication.GeneralApplication; import uk.gov.hmcts.reform.civil.sampledata.CallbackParamsBuilder; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper; @@ -21,6 +23,7 @@ import uk.gov.hmcts.reform.dashboard.services.TaskListService; import java.util.HashMap; +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -33,6 +36,8 @@ import static uk.gov.hmcts.reform.civil.enums.CaseState.All_FINAL_ORDERS_ISSUED; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_CLAIMANT; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_CLAIMANT_WITHOUT_TASK_CHANGES; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_AVAILABLE_CLAIMANT; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_INITIATE_APPLICATION_INACTIVE_CLAIMANT; @ExtendWith(MockitoExtension.class) class CaseProceedOfflineClaimantNotificationHandlerTest extends BaseCallbackHandlerTest { @@ -50,6 +55,7 @@ class CaseProceedOfflineClaimantNotificationHandlerTest extends BaseCallbackHand @Mock private FeatureToggleService toggleService; public static final String TASK_ID = "GenerateClaimantDashboardNotificationCaseProceedOffline"; + public static final String GA = "Applications"; @Test void handleEventsReturnsTheExpectedCallbackEvent() { @@ -76,15 +82,17 @@ void shouldRecordScenario_whenInvokedWithoutCPEnabled() { .respondent1Represented(YesOrNo.NO) .applicant1Represented(YesOrNo.NO) .ccdCaseReference(1234L) + .generalApplications(List.of(Element.builder().build())) .previousCCDState(AWAITING_APPLICANT_INTENTION).build(); - CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( - CallbackRequest.builder().eventId(CREATE_CLAIMANT_DASHBOARD_NOTIFICATION_FOR_CASE_PROCEED_OFFLINE.name()).build() - ).build(); when(toggleService.isLipVLipEnabled()).thenReturn(true); + when(toggleService.isGaForLipsEnabled()).thenReturn(true); HashMap scenarioParams = new HashMap<>(); when(mapper.mapCaseDataToParams(any())).thenReturn(scenarioParams); - + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( + CallbackRequest.builder() + .eventId(CREATE_CLAIMANT_DASHBOARD_NOTIFICATION_FOR_CASE_PROCEED_OFFLINE.name()).build() + ).build(); // When handler.handle(params); @@ -97,6 +105,18 @@ void shouldRecordScenario_whenInvokedWithoutCPEnabled() { caseData.getCcdCaseReference().toString(), ScenarioRequestParams.builder().params(scenarioParams).build() ); + verify(dashboardScenariosService).recordScenarios( + "BEARER_TOKEN", + SCENARIO_AAA6_GENERAL_APPLICATION_INITIATE_APPLICATION_INACTIVE_CLAIMANT.getScenario(), + caseData.getCcdCaseReference().toString(), + ScenarioRequestParams.builder().params(scenarioParams).build() + ); + verify(dashboardScenariosService).recordScenarios( + "BEARER_TOKEN", + SCENARIO_AAA6_GENERAL_APPLICATION_AVAILABLE_CLAIMANT.getScenario(), + caseData.getCcdCaseReference().toString(), + ScenarioRequestParams.builder().params(scenarioParams).build() + ); } @Test @@ -186,7 +206,7 @@ private void verifyDeleteNotificationsAndTaskListUpdates(CaseData caseData) { verify(taskListService).makeProgressAbleTasksInactiveForCaseIdentifierAndRole( caseData.getCcdCaseReference().toString(), "CLAIMANT", - null + GA ); } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/defendant/CaseProceedOfflineDefendantNotificationHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/defendant/CaseProceedOfflineDefendantNotificationHandlerTest.java index 443afed02d9..23e29119cfe 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/defendant/CaseProceedOfflineDefendantNotificationHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/defendant/CaseProceedOfflineDefendantNotificationHandlerTest.java @@ -39,6 +39,8 @@ import static uk.gov.hmcts.reform.civil.enums.CaseState.AWAITING_APPLICANT_INTENTION; import static uk.gov.hmcts.reform.civil.enums.CaseState.CASE_PROGRESSION; import static uk.gov.hmcts.reform.civil.enums.CaseState.PENDING_CASE_ISSUED; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_AVAILABLE_DEFENDANT; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_INITIATE_APPLICATION_INACTIVE_DEFENDANT; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_DEFENDANT; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_DEFENDANT_WITHOUT_TASK_CHANGES; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_UPDATE_CASE_PROCEED_IN_CASE_MAN_DEFENDANT; @@ -61,6 +63,7 @@ class CaseProceedOfflineDefendantNotificationHandlerTest extends BaseCallbackHan @Mock private FeatureToggleService toggleService; public static final String TASK_ID = "GenerateDefendantDashboardNotificationCaseProceedOffline"; + public static final String GA = "Applications"; @Test void handleEventsReturnsTheExpectedCallbackEvent() { @@ -83,18 +86,24 @@ class AboutToSubmitCallback { @Test void shouldRecordScenario_whenInvokedWithoutCPToggle() { // Given + List> gaApplications = wrapElements( + GeneralApplication.builder() + .caseLink(CaseLink.builder().caseReference("54326781").build()) + .build()); CaseData caseData = CaseDataBuilder.builder().atStateRespondentFullAdmissionSpec().build().toBuilder() .respondent1Represented(YesOrNo.NO) .ccdCaseReference(12890L) + .generalApplications(gaApplications) .previousCCDState(AWAITING_APPLICANT_INTENTION).build(); - CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( - CallbackRequest.builder().eventId(CREATE_DEFENDANT_DASHBOARD_NOTIFICATION_FOR_CASE_PROCEED_OFFLINE.name()).build() - ).build(); when(toggleService.isLipVLipEnabled()).thenReturn(true); + when(toggleService.isGaForLipsEnabled()).thenReturn(true); HashMap scenarioParams = new HashMap<>(); when(mapper.mapCaseDataToParams(any())).thenReturn(scenarioParams); - + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( + CallbackRequest.builder() + .eventId(CREATE_DEFENDANT_DASHBOARD_NOTIFICATION_FOR_CASE_PROCEED_OFFLINE.name()).build() + ).build(); // When handler.handle(params); @@ -106,6 +115,19 @@ void shouldRecordScenario_whenInvokedWithoutCPToggle() { caseData.getCcdCaseReference().toString(), ScenarioRequestParams.builder().params(scenarioParams).build() ); + verify(dashboardScenariosService).recordScenarios( + "BEARER_TOKEN", + SCENARIO_AAA6_GENERAL_APPLICATION_INITIATE_APPLICATION_INACTIVE_DEFENDANT.getScenario(), + caseData.getCcdCaseReference().toString(), + ScenarioRequestParams.builder().params(scenarioParams).build() + ); + verify(dashboardScenariosService).recordScenarios( + "BEARER_TOKEN", + SCENARIO_AAA6_GENERAL_APPLICATION_AVAILABLE_DEFENDANT.getScenario(), + caseData.getCcdCaseReference().toString(), + ScenarioRequestParams.builder().params(scenarioParams).build() + ); + } @Test @@ -231,7 +253,7 @@ private void verifyDeleteNotificationsAndTaskListUpdates(CaseData caseData) { verify(taskListService).makeProgressAbleTasksInactiveForCaseIdentifierAndRole( caseData.getCcdCaseReference().toString(), "DEFENDANT", - null + GA ); } @@ -263,13 +285,6 @@ void shouldRecordScenario_whenCoScFlagEnabledAndActiveJudgmentExists() { // When handler.handle(params); - // Then - verifyDeleteNotificationsAndTaskListUpdates(caseData); - verify(dashboardNotificationService).deleteByReferenceAndCitizenRole( - "54326781", - "APPLICANT" - ); - verify(dashboardScenariosService).recordScenarios( "BEARER_TOKEN", SCENARIO_AAA6_UPDATE_CASE_PROCEED_IN_CASE_MAN_DEFENDANT.getScenario(),