Skip to content

Commit

Permalink
CIV-16594 take case offline view applications avilable (#6162)
Browse files Browse the repository at this point in the history
* CIV-16568 added changes for sot

* CIV-16594 added changes for sot

* CIV-16594 updated tests

* CIV-16594 updated tests

* CIV-16594 updated tests

* CIV-16594 updated tests

* CIV-16594 removed the logic to show dashboard notifications for applicant

---------

Co-authored-by: Raja Mani <rajakm@gmail.com>
Co-authored-by: sankhajuria <sankhajuria@gmail.com>
  • Loading branch information
3 people authored Feb 21, 2025
1 parent 336a810 commit 46b18c2
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;

Expand All @@ -58,6 +62,16 @@ public String getScenario(CaseData caseData) {
return SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_CLAIMANT.getScenario();
}

@Override
public Map<String, Boolean> 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;
Expand Down Expand Up @@ -87,7 +101,7 @@ protected void beforeRecordScenario(CaseData caseData, String authToken) {
taskListService.makeProgressAbleTasksInactiveForCaseIdentifierAndRole(
caseId,
"CLAIMANT",
null
GA
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -66,6 +70,17 @@ public String getScenario(CaseData caseData) {
return SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_DEFENDANT.getScenario();
}

@Override
public Map<String, Boolean> 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<CaseEvent> handledEvents() {
return EVENTS;
Expand Down Expand Up @@ -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"
));
}
}
}
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand All @@ -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() {
Expand All @@ -76,15 +82,17 @@ void shouldRecordScenario_whenInvokedWithoutCPEnabled() {
.respondent1Represented(YesOrNo.NO)
.applicant1Represented(YesOrNo.NO)
.ccdCaseReference(1234L)
.generalApplications(List.of(Element.<GeneralApplication>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<String, Object> 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);

Expand All @@ -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
Expand Down Expand Up @@ -186,7 +206,7 @@ private void verifyDeleteNotificationsAndTaskListUpdates(CaseData caseData) {
verify(taskListService).makeProgressAbleTasksInactiveForCaseIdentifierAndRole(
caseData.getCcdCaseReference().toString(),
"CLAIMANT",
null
GA
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand All @@ -83,18 +86,24 @@ class AboutToSubmitCallback {
@Test
void shouldRecordScenario_whenInvokedWithoutCPToggle() {
// Given
List<Element<GeneralApplication>> 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<String, Object> 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);

Expand All @@ -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
Expand Down Expand Up @@ -231,7 +253,7 @@ private void verifyDeleteNotificationsAndTaskListUpdates(CaseData caseData) {
verify(taskListService).makeProgressAbleTasksInactiveForCaseIdentifierAndRole(
caseData.getCcdCaseReference().toString(),
"DEFENDANT",
null
GA
);
}

Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 46b18c2

Please sign in to comment.