Skip to content

Commit

Permalink
Added restting the view documents task when case stay is lifted
Browse files Browse the repository at this point in the history
  • Loading branch information
Gareth40342 committed Nov 14, 2024
1 parent 685d170 commit 502964a
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder;
import uk.gov.hmcts.reform.dashboard.data.TaskStatus;

import java.time.LocalDateTime;

import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
Expand All @@ -30,6 +32,7 @@ void should_create_stay_lifted_claimant_scenario() throws Exception {
.ccdCaseReference(Long.valueOf(caseId))
.ccdState(CaseState.CASE_PROGRESSION)
.preStayState(CaseState.HEARING_READINESS.toString())
.caseDocumentUploadDate(LocalDateTime.now())
.applicant1Represented(YesOrNo.NO)
.build();

Expand Down Expand Up @@ -64,15 +67,20 @@ void should_create_stay_lifted_claimant_scenario() throws Exception {
jsonPath("$[1].currentStatusEn").value(TaskStatus.NOT_AVAILABLE_YET.getName()),
jsonPath("$[1].currentStatusCy").value(TaskStatus.NOT_AVAILABLE_YET.getWelshName()),
jsonPath("$[2].reference").value(caseId),
jsonPath("$[2].taskNameEn").value("<a>Add the trial arrangements</a>"),
jsonPath("$[2].taskNameCy").value("<a>Ychwanegu trefniadau'r treial</a>"),
jsonPath("$[2].currentStatusEn").value(TaskStatus.NOT_AVAILABLE_YET.getName()),
jsonPath("$[2].currentStatusCy").value(TaskStatus.NOT_AVAILABLE_YET.getWelshName()),
jsonPath("$[2].taskNameEn").value("<a href=\"{VIEW_EVIDENCE_UPLOAD_DOCUMENTS}\" class=\"govuk-link\">View documents</a>"),
jsonPath("$[2].taskNameCy").value("<a href=\"{VIEW_EVIDENCE_UPLOAD_DOCUMENTS}\" class=\"govuk-link\">Gweld y dogfennau</a>"),
jsonPath("$[2].currentStatusEn").value(TaskStatus.AVAILABLE.getName()),
jsonPath("$[2].currentStatusCy").value(TaskStatus.AVAILABLE.getWelshName()),
jsonPath("$[3].reference").value(caseId),
jsonPath("$[3].taskNameEn").value("<a>View the bundle</a>"),
jsonPath("$[3].taskNameCy").value("<a>Gweld y bwndel</a>"),
jsonPath("$[3].taskNameEn").value("<a>Add the trial arrangements</a>"),
jsonPath("$[3].taskNameCy").value("<a>Ychwanegu trefniadau'r treial</a>"),
jsonPath("$[3].currentStatusEn").value(TaskStatus.NOT_AVAILABLE_YET.getName()),
jsonPath("$[3].currentStatusCy").value(TaskStatus.NOT_AVAILABLE_YET.getWelshName())
jsonPath("$[3].currentStatusCy").value(TaskStatus.NOT_AVAILABLE_YET.getWelshName()),
jsonPath("$[4].reference").value(caseId),
jsonPath("$[4].taskNameEn").value("<a>View the bundle</a>"),
jsonPath("$[4].taskNameCy").value("<a>Gweld y bwndel</a>"),
jsonPath("$[4].currentStatusEn").value(TaskStatus.NOT_AVAILABLE_YET.getName()),
jsonPath("$[4].currentStatusCy").value(TaskStatus.NOT_AVAILABLE_YET.getWelshName())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder;
import uk.gov.hmcts.reform.dashboard.data.TaskStatus;

import java.time.LocalDateTime;

import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
Expand All @@ -21,7 +23,7 @@ public class StayLiftedDefendantScenarioTest extends DashboardBaseIntegrationTes
private StayLiftedDefendantNotificationHandler handler;

@Test
void should_create_stay_lifted_claimant_scenario() throws Exception {
void should_create_stay_lifted_defendant_scenario() throws Exception {

String caseId = "7123454456455465";

Expand All @@ -31,6 +33,7 @@ void should_create_stay_lifted_claimant_scenario() throws Exception {
.ccdState(CaseState.CASE_PROGRESSION)
.preStayState(CaseState.HEARING_READINESS.toString())
.respondent1Represented(YesOrNo.NO)
.caseDocumentUploadDateRes(LocalDateTime.now())
.build();

when(featureToggleService.isLipVLipEnabled()).thenReturn(true);
Expand Down Expand Up @@ -59,15 +62,20 @@ void should_create_stay_lifted_claimant_scenario() throws Exception {
jsonPath("$[0].currentStatusEn").value(TaskStatus.NOT_AVAILABLE_YET.getName()),
jsonPath("$[0].currentStatusCy").value(TaskStatus.NOT_AVAILABLE_YET.getWelshName()),
jsonPath("$[1].reference").value(caseId),
jsonPath("$[1].taskNameEn").value("<a>Add the trial arrangements</a>"),
jsonPath("$[1].taskNameCy").value("<a>Ychwanegu trefniadau'r treial</a>"),
jsonPath("$[1].currentStatusEn").value(TaskStatus.NOT_AVAILABLE_YET.getName()),
jsonPath("$[1].currentStatusCy").value(TaskStatus.NOT_AVAILABLE_YET.getWelshName()),
jsonPath("$[2].reference").value(caseId),
jsonPath("$[2].taskNameEn").value("<a>View the bundle</a>"),
jsonPath("$[2].taskNameCy").value("<a>Gweld y bwndel</a>"),
jsonPath("$[1].reference").value(caseId),
jsonPath("$[1].taskNameEn").value("<a href=\"{VIEW_EVIDENCE_UPLOAD_DOCUMENTS}\" class=\"govuk-link\">View documents</a>"),
jsonPath("$[1].taskNameCy").value("<a href=\"{VIEW_EVIDENCE_UPLOAD_DOCUMENTS}\" class=\"govuk-link\">Gweld y dogfennau</a>"),
jsonPath("$[1].currentStatusEn").value(TaskStatus.AVAILABLE.getName()),
jsonPath("$[1].currentStatusCy").value(TaskStatus.AVAILABLE.getWelshName()),
jsonPath("$[2].taskNameEn").value("<a>Add the trial arrangements</a>"),
jsonPath("$[2].taskNameCy").value("<a>Ychwanegu trefniadau'r treial</a>"),
jsonPath("$[2].currentStatusEn").value(TaskStatus.NOT_AVAILABLE_YET.getName()),
jsonPath("$[2].currentStatusCy").value(TaskStatus.NOT_AVAILABLE_YET.getWelshName())
jsonPath("$[2].currentStatusCy").value(TaskStatus.NOT_AVAILABLE_YET.getWelshName()),
jsonPath("$[3].reference").value(caseId),
jsonPath("$[3].taskNameEn").value("<a>View the bundle</a>"),
jsonPath("$[3].taskNameCy").value("<a>Gweld y bwndel</a>"),
jsonPath("$[3].currentStatusEn").value(TaskStatus.NOT_AVAILABLE_YET.getName()),
jsonPath("$[3].currentStatusCy").value(TaskStatus.NOT_AVAILABLE_YET.getWelshName())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ public enum DashboardScenarios {
SCENARIO_AAA6_CP_STAY_LIFTED_RESET_HEARING_FEE_PAID_TASK("Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Fee.Paid.Task"),
SCENARIO_AAA6_CP_STAY_LIFTED_RESET_HEARING_TASKS_CLAIMANT("Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Tasks.Claimant"),
SCENARIO_AAA6_CP_STAY_LIFTED_RESET_HEARING_TASKS_DEFENDANT("Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Tasks.Defendant"),
SCENARIO_AAA6_CP_STAY_LIFTED_VIEW_DOCUMENTS_TASK_AVAILABLE_CLAIMANT("Scenario.AAA6.CP.Stay.Lifted.View.Documents.Task.Available.Claimant"),
SCENARIO_AAA6_CP_STAY_LIFTED_VIEW_DOCUMENTS_TASK_NOT_AVAILABLE_CLAIMANT("Scenario.AAA6.CP.Stay.Lifted.View.Documents.Task.Not.Available.Claimant"),
SCENARIO_AAA6_CP_STAY_LIFTED_VIEW_DOCUMENTS_TASK_AVAILABLE_DEFENDANT("Scenario.AAA6.CP.Stay.Lifted.View.Documents.Task.Available.Defendant"),
SCENARIO_AAA6_CP_STAY_LIFTED_VIEW_DOCUMENTS_TASK_NOT_AVAILABLE_DEFENDANT("Scenario.AAA6.CP.Stay.Lifted.View.Documents.Task.Not.Available.Defendant"),
SCENARIO_AAA6_UPDATE_CASE_PROCEED_IN_CASE_MAN_DEFENDANT("Scenario.AAA6.Update.CaseProceedsInCaseman.Defendant"),
SCENARIO_AAA6_UPDATE_CASE_PROCEED_IN_CASE_MAN_DEFENDANT_FAST_TRACK("Scenario.AAA6.Update.CaseProceedsInCaseman.Defendant.FastTrack");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import uk.gov.hmcts.reform.civil.callback.CaseEventsDashboardCallbackHandler;
import uk.gov.hmcts.reform.civil.client.DashboardApiClient;
import uk.gov.hmcts.reform.civil.enums.CaseState;
import uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
Expand All @@ -14,12 +15,15 @@
import java.util.List;
import java.util.Map;

import static java.util.Objects.nonNull;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_DASHBOARD_NOTIFICATION_STAY_LIFTED_CLAIMANT;
import static uk.gov.hmcts.reform.civil.enums.CaseState.HEARING_READINESS;
import static uk.gov.hmcts.reform.civil.enums.CaseState.PREPARE_FOR_HEARING_CONDUCT_HEARING;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_STAY_LIFTED_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_STAY_LIFTED_RESET_HEARING_FEE_PAID_TASK;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_STAY_LIFTED_RESET_HEARING_TASKS_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_STAY_LIFTED_VIEW_DOCUMENTS_TASK_NOT_AVAILABLE_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_STAY_LIFTED_VIEW_DOCUMENTS_TASK_AVAILABLE_CLAIMANT;

@Service
public class StayLiftedClaimantNotificationHandler extends CaseEventsDashboardCallbackHandler {
Expand Down Expand Up @@ -55,7 +59,8 @@ public Map<String, Boolean> getScenarios(CaseData caseData) {
return Map.of(
SCENARIO_AAA6_CP_STAY_LIFTED_CLAIMANT.getScenario(), true,
SCENARIO_AAA6_CP_STAY_LIFTED_RESET_HEARING_TASKS_CLAIMANT.getScenario(), hadHearingScheduled(caseData),
SCENARIO_AAA6_CP_STAY_LIFTED_RESET_HEARING_FEE_PAID_TASK.getScenario(), hadHearingScheduled(caseData) && !caseData.isHearingFeePaid()
SCENARIO_AAA6_CP_STAY_LIFTED_RESET_HEARING_FEE_PAID_TASK.getScenario(), hadHearingScheduled(caseData) && !caseData.isHearingFeePaid(),
getViewDocumentsScenario(caseData).getScenario(), true
);
}

Expand All @@ -69,4 +74,10 @@ private boolean hadHearingScheduled(CaseData caseData) {
).contains(CaseState.valueOf(caseData.getPreStayState()));
}

private DashboardScenarios getViewDocumentsScenario(CaseData caseData) {
return nonNull(caseData.getCaseDocumentUploadDate())
? SCENARIO_AAA6_CP_STAY_LIFTED_VIEW_DOCUMENTS_TASK_AVAILABLE_CLAIMANT
: SCENARIO_AAA6_CP_STAY_LIFTED_VIEW_DOCUMENTS_TASK_NOT_AVAILABLE_CLAIMANT;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import uk.gov.hmcts.reform.civil.callback.CaseEventsDashboardCallbackHandler;
import uk.gov.hmcts.reform.civil.client.DashboardApiClient;
import uk.gov.hmcts.reform.civil.enums.CaseState;
import uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
Expand All @@ -14,11 +15,14 @@
import java.util.List;
import java.util.Map;

import static java.util.Objects.nonNull;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_DASHBOARD_NOTIFICATION_STAY_LIFTED_DEFENDANT;
import static uk.gov.hmcts.reform.civil.enums.CaseState.HEARING_READINESS;
import static uk.gov.hmcts.reform.civil.enums.CaseState.PREPARE_FOR_HEARING_CONDUCT_HEARING;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_STAY_LIFTED_DEFENDANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_STAY_LIFTED_RESET_HEARING_TASKS_DEFENDANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_STAY_LIFTED_VIEW_DOCUMENTS_TASK_NOT_AVAILABLE_DEFENDANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_STAY_LIFTED_VIEW_DOCUMENTS_TASK_AVAILABLE_DEFENDANT;

@Service
public class StayLiftedDefendantNotificationHandler extends CaseEventsDashboardCallbackHandler {
Expand Down Expand Up @@ -53,7 +57,9 @@ public Map<String, Boolean> getScenarios(CaseData caseData) {
if (caseData.isRespondent1NotRepresented()) {
return Map.of(
SCENARIO_AAA6_CP_STAY_LIFTED_DEFENDANT.getScenario(), true,
SCENARIO_AAA6_CP_STAY_LIFTED_RESET_HEARING_TASKS_DEFENDANT.getScenario(), hadHearingScheduled(caseData));
SCENARIO_AAA6_CP_STAY_LIFTED_RESET_HEARING_TASKS_DEFENDANT.getScenario(), hadHearingScheduled(caseData),
getViewDocumentsScenario(caseData).getScenario(), true
);
}

return new HashMap<>();
Expand All @@ -65,4 +71,11 @@ private boolean hadHearingScheduled(CaseData caseData) {
PREPARE_FOR_HEARING_CONDUCT_HEARING
).contains(CaseState.valueOf(caseData.getPreStayState()));
}

private DashboardScenarios getViewDocumentsScenario(CaseData caseData) {
return nonNull(caseData.getCaseDocumentUploadDateRes())
? SCENARIO_AAA6_CP_STAY_LIFTED_VIEW_DOCUMENTS_TASK_AVAILABLE_DEFENDANT
: SCENARIO_AAA6_CP_STAY_LIFTED_VIEW_DOCUMENTS_TASK_NOT_AVAILABLE_DEFENDANT;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,32 @@
INSERT INTO dbs.scenario (name, notifications_to_delete, notifications_to_create)
VALUES ('Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Fee.Paid.Task', '{}', '{}'),
('Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Tasks.Claimant', '{}', '{}'),
('Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Tasks.Defendant', '{}', '{}');
('Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Tasks.Defendant', '{}', '{}'),
('Scenario.AAA6.CP.Stay.Lifted.View.Documents.Task.Available.Claimant', '{}', '{}'),
('Scenario.AAA6.CP.Stay.Lifted.View.Documents.Task.Not.Available.Claimant', '{}', '{}'),
('Scenario.AAA6.CP.Stay.Lifted.View.Documents.Task.Available.Defendant', '{}', '{}'),
('Scenario.AAA6.CP.Stay.Lifted.View.Documents.Task.Not.Available.Defendant', '{}', '{}');

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 ('<a>View the hearing</a>', 'Hearing', '<a>Gweld y gwrandawiad</a>',
'Gwrandawiad', 'Hearing.View', 'Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Tasks.Claimant', '{1, 1}', 'CLAIMANT', 8),
('<a>Pay the hearing fee</a>', 'Hearing', '<a>Talu ffi''r gwrandawiad</a>',
'Gwrandawiad', 'Hearing.Fee.Pay', 'Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Fee.Paid.Task', '{1, 1}', 'CLAIMANT', 9),
('<a href="{VIEW_EVIDENCE_UPLOAD_DOCUMENTS}" class="govuk-link">View documents</a>', 'Hearing' ,'<a href="{VIEW_EVIDENCE_UPLOAD_DOCUMENTS}" class="govuk-link">Gweld y dogfennau</a>',
'Gwrandawiad', 'Hearing.Document.View', 'Scenario.AAA6.CP.Stay.Lifted.View.Documents.Task.Available.Claimant','{3, 3}', 'CLAIMANT', 11),
('<a>View documents</a>', 'Hearing' ,'<a>Gweld y dogfennau</a>', 'Gwrandawiad',
'Hearing.Document.View', 'Scenario.AAA6.CP.Stay.Lifted.View.Documents.Task.Not.Available.Claimant','{1, 1}', 'CLAIMANT', 11),
('<a>Add the trial arrangements</a>', 'Hearing', '<a>Ychwanegu trefniadau''r treial</a>',
'Gwrandawiad', 'Hearing.Arrangements.Add', 'Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Tasks.Claimant', '{1, 1}', 'CLAIMANT', 12),
('<a>View the bundle</a>', 'Hearing', '<a>Gweld y bwndel</a>',
'Gwrandawiad', 'Hearing.Bundle.View', 'Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Tasks.Claimant', '{1, 1}', 'CLAIMANT', 13),
('<a>View the hearing</a>', 'Hearing', '<a>Gweld y gwrandawiad</a>',
'Gwrandawiad', 'Hearing.View', 'Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Tasks.Defendant', '{1, 1}', 'DEFENDANT', 8),
('<a href="{VIEW_EVIDENCE_UPLOAD_DOCUMENTS}" class="govuk-link">View documents</a>', 'Hearing' ,'<a href="{VIEW_EVIDENCE_UPLOAD_DOCUMENTS}" class="govuk-link">Gweld y dogfennau</a>',
'Gwrandawiad', 'Hearing.Document.View', 'Scenario.AAA6.CP.Stay.Lifted.View.Documents.Task.Available.Defendant','{3, 3}', 'DEFENDANT', 11),
('<a>View documents</a>', 'Hearing' ,'<a>Gweld y dogfennau</a>', 'Gwrandawiad',
'Hearing.Document.View', 'Scenario.AAA6.CP.Stay.Lifted.View.Documents.Task.Not.Available.Defendant','{1, 1}', 'DEFENDANT', 11),
('<a>Add the trial arrangements</a>', 'Hearing', '<a>Ychwanegu trefniadau''r treial</a>',
'Gwrandawiad', 'Hearing.Arrangements.Add', 'Scenario.AAA6.CP.Stay.Lifted.Reset.Hearing.Tasks.Defendant', '{1, 1}', 'DEFENDANT', 12),
('<a>View the bundle</a>', 'Hearing', '<a>Gweld y bwndel</a>',
Expand Down
Loading

0 comments on commit 502964a

Please sign in to comment.