Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIV-15723 - Move trial ready bits from bundle script to trial ready check #5935

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,9 @@ public enum CaseEvent {
CREATE_DASHBOARD_NOTIFICATION_COSC_NOT_PAID_FULL_DEFENDANT(CAMUNDA),
CREATE_DASHBOARD_NOTIFICATION_STAY_LIFTED_CLAIMANT(CAMUNDA),
CREATE_DASHBOARD_NOTIFICATION_STAY_LIFTED_DEFENDANT(CAMUNDA),
NOTIFY_APPLICANT_SOLICITOR1_FOR_PAID_IN_FULL_COSC(CAMUNDA);
NOTIFY_APPLICANT_SOLICITOR1_FOR_PAID_IN_FULL_COSC(CAMUNDA),
CREATE_DASHBOARD_NOTIFICATION_TRIAL_READY_CHECK_CLAIMANT1(CAMUNDA),
CREATE_DASHBOARD_NOTIFICATION_TRIAL_READY_CHECK_DEFENDANT1(CAMUNDA);

private final UserType userType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ public enum DashboardScenarios {
SCENARIO_AAA6_HEARING_FEE_HWF_PART_REMISSION("Scenario.AAA6.CP.HearingFee.HWF.PartRemission"),
SCENARIO_AAA6_HEARING_FEE_HWF_NO_REMISSION("Scenario.AAA6.CP.HearingFee.HWF.Rejected"),
SCENARIO_AAA6_HEARING_FEE_HWF_FULL_REMISSION("Scenario.AAA6.CP.HearingFee.HWF.FullRemission"),
SCENARIO_AAA6_BUNDLE_CREATED_TRIAL_READY_CLAIMANT("Scenario.AAA6.CP.Bundle.Ready.TrialReady.Claimant"),
SCENARIO_AAA6_BUNDLE_CREATED_TRIAL_READY_DEFENDANT("Scenario.AAA6.CP.Bundle.Ready.TrialReady.Defendant"),
SCENARIO_AAA6_CP_HEARING_FEE_HELP_WITH_FEE_APPLIED_CLAIMANT("Scenario.AAA6.CP.HearingFee.HWF.AppliedFor.Claimant"),
SCENARIO_AAA6_CP_CLAIM_ISSUE_FAST_TRACK_CLAIMANT("Scenario.AAA6.ClaimIssue.Claimant.FastTrack"),
SCENARIO_AAA6_CP_CLAIM_ISSUE_FAST_TRACK_DEFENDANT("Scenario.AAA6.ClaimIssue.Defendant.FastTrack"),
Expand Down Expand Up @@ -217,7 +215,9 @@ public enum DashboardScenarios {
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"),
SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_RELIST_HEARING_CLAIMANT("Scenario.AAA6.CP.Trial.Arrangements.Relist.Hearing.Claimant"),
SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_RELIST_HEARING_DEFENDANT("Scenario.AAA6.CP.Trial.Arrangements.Relist.Hearing.Defendant");
SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_RELIST_HEARING_DEFENDANT("Scenario.AAA6.CP.Trial.Arrangements.Relist.Hearing.Defendant"),
SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_CHECK_CLAIMANT("Scenario.AAA6.CP.TrialReady.Check.Claimant"),
SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_CHECK_DEFENDANT("Scenario.AAA6.CP.TrialReady.Check.Defendant");

private final String scenario;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import static java.util.Objects.isNull;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_DASHBOARD_NOTIFICATION_FOR_BUNDLE_CREATED_FOR_CLAIMANT1;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_BUNDLE_CREATED_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_BUNDLE_CREATED_TRIAL_READY_CLAIMANT;

@Service
public class BundleCreationClaimantNotificationHandler extends CaseProgressionDashboardCallbackHandler {
Expand All @@ -42,9 +41,7 @@ public List<CaseEvent> handledEvents() {

@Override
public String getScenario(CaseData caseData) {
return isNull(caseData.getTrialReadyApplicant()) && SdoHelper.isFastTrack(caseData)
? SCENARIO_AAA6_BUNDLE_CREATED_CLAIMANT.getScenario()
: SCENARIO_AAA6_BUNDLE_CREATED_TRIAL_READY_CLAIMANT.getScenario();
return SCENARIO_AAA6_BUNDLE_CREATED_CLAIMANT.getScenario();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.claimant;

import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
import uk.gov.hmcts.reform.civil.callback.CaseProgressionDashboardCallbackHandler;
import uk.gov.hmcts.reform.civil.client.DashboardApiClient;
import uk.gov.hmcts.reform.civil.enums.AllocatedTrack;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.helpers.sdo.SdoHelper;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;

import java.util.List;

import static java.util.Objects.isNull;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_DASHBOARD_NOTIFICATION_TRIAL_READY_CHECK_CLAIMANT1;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_CHECK_CLAIMANT;

public class TrialReadyCheckClaimantNotificationHandler extends CaseProgressionDashboardCallbackHandler {

private static final List<CaseEvent> EVENTS = List.of(CREATE_DASHBOARD_NOTIFICATION_TRIAL_READY_CHECK_CLAIMANT1);
public static final String TASK_ID = "TrialReadyCheckDashboardNotificationsForClaimant1";

public TrialReadyCheckClaimantNotificationHandler(DashboardApiClient dashboardApiClient,
DashboardNotificationsParamsMapper mapper,
FeatureToggleService featureToggleService) {
super(dashboardApiClient, mapper, featureToggleService);
}

@Override
public String camundaActivityId(CallbackParams callbackParams) {
return TASK_ID;
}

@Override
public List<CaseEvent> handledEvents() {
return EVENTS;
}

@Override
public String getScenario(CaseData caseData) {
return SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_CHECK_CLAIMANT.getScenario();
}

@Override
public boolean shouldRecordScenario(CaseData caseData) {
return YesOrNo.NO.equals(caseData.getApplicant1Represented())
&& isNull(caseData.getTrialReadyApplicant())
&& AllocatedTrack.FAST_CLAIM.name().equals(caseData.getAssignedTrack());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@
import uk.gov.hmcts.reform.civil.callback.CaseProgressionDashboardCallbackHandler;
import uk.gov.hmcts.reform.civil.client.DashboardApiClient;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.helpers.sdo.SdoHelper;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;

import java.util.List;

import static java.util.Objects.isNull;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_DASHBOARD_NOTIFICATION_FOR_BUNDLE_CREATED_FOR_DEFENDANT1;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_BUNDLE_CREATED_DEFENDANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_BUNDLE_CREATED_TRIAL_READY_DEFENDANT;

@Service
public class BundleCreationDefendantNotificationHandler extends CaseProgressionDashboardCallbackHandler {
Expand All @@ -42,9 +39,7 @@ public List<CaseEvent> handledEvents() {

@Override
public String getScenario(CaseData caseData) {
return isNull(caseData.getTrialReadyRespondent1()) && SdoHelper.isFastTrack(caseData)
? SCENARIO_AAA6_BUNDLE_CREATED_DEFENDANT.getScenario()
: SCENARIO_AAA6_BUNDLE_CREATED_TRIAL_READY_DEFENDANT.getScenario();
return SCENARIO_AAA6_BUNDLE_CREATED_DEFENDANT.getScenario();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.defendant;

import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
import uk.gov.hmcts.reform.civil.callback.CaseProgressionDashboardCallbackHandler;
import uk.gov.hmcts.reform.civil.client.DashboardApiClient;
import uk.gov.hmcts.reform.civil.enums.AllocatedTrack;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.helpers.sdo.SdoHelper;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;

import java.util.List;

import static java.util.Objects.isNull;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_DASHBOARD_NOTIFICATION_TRIAL_READY_CHECK_DEFENDANT1;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_CHECK_DEFENDANT;

public class TrialReadyCheckDefendantNotificationHandler extends CaseProgressionDashboardCallbackHandler {

private static final List<CaseEvent> EVENTS = List.of(CREATE_DASHBOARD_NOTIFICATION_TRIAL_READY_CHECK_DEFENDANT1);
public static final String TASK_ID = "TrialReadyCheckDashboardNotificationsForDefendant1";

public TrialReadyCheckDefendantNotificationHandler(DashboardApiClient dashboardApiClient,
DashboardNotificationsParamsMapper mapper,
FeatureToggleService featureToggleService) {
super(dashboardApiClient, mapper, featureToggleService);
}

@Override
public String camundaActivityId(CallbackParams callbackParams) {
return TASK_ID;
}

@Override
public List<CaseEvent> handledEvents() {
return EVENTS;
}

@Override
public String getScenario(CaseData caseData) {
return SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_CHECK_DEFENDANT.getScenario();
}

@Override
public boolean shouldRecordScenario(CaseData caseData) {
return YesOrNo.NO.equals(caseData.getRespondent1Represented())
&& isNull(caseData.getTrialReadyRespondent1())
&& AllocatedTrack.FAST_CLAIM.name().equals(caseData.getAssignedTrack());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import uk.gov.hmcts.reform.civil.callback.CallbackHandler;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
import uk.gov.hmcts.reform.civil.model.BusinessProcess;
import uk.gov.hmcts.reform.civil.model.CaseData;

import java.util.List;
Expand All @@ -35,6 +36,7 @@ protected Map<String, Callback> callbacks() {
private CallbackResponse setTrialReadyChecked(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData().toBuilder()
.trialReadyChecked(YES)
.businessProcess(BusinessProcess.ready(TRIAL_READY_CHECK))
.build();

return AboutToStartOrSubmitCallbackResponse.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Delete scenarios
*/
DELETE FROM dbs.scenario WHERE(name = 'Scenario.AAA6.CP.Bundle.Ready.TrialReady.Claimant')
OR(name = 'Scenario.AAA6.CP.Bundle.Ready.TrialReady.Defendant');

/**
* Add scenarios
*/
INSERT INTO dbs.scenario (name, notifications_to_delete, notifications_to_create)
VALUES ('Scenario.AAA6.CP.TrialReady.Check.Claimant', '{"Notice.AAA6.CP.Trial.Arrangements.Finalised.NotifyOtherParty.Claimant", "Notice.AAA6.CP.Trial.Arrangements.Required.Claimant"}', '{}'),
('Scenario.AAA6.CP.TrialReady.Check.Defendant', '{"Notice.AAA6.CP.Trial.Arrangements.Finalised.NotifyOtherParty.Defendant", "Notice.AAA6.CP.Trial.Arrangements.Required.Defendant"}', '{}');

/**
* Delete task items
*/
DELETE FROM dbs.task_item_template
WHERE (template_name = 'Hearing.Arrangements.Add' AND scenario_name = 'Scenario.AAA6.CP.Bundle.Ready.Claimant' AND task_order = 13)
OR (template_name = 'Hearing.Arrangements.Add' AND scenario_name = 'Scenario.AAA6.CP.Bundle.Ready.Defendant' AND task_order = 12)
OR (template_name = 'Hearing.Bundle.View' AND scenario_name = 'Scenario.AAA6.CP.Bundle.Ready.TrialReady.Claimant' AND task_order = 12)
OR (template_name = 'Hearing.Bundle.View' AND scenario_name = 'Scenario.AAA6.CP.Bundle.Ready.TrialReady.Defendant' AND task_order = 11);

/**
* Add task item template
*/

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, hint_text_en, hint_text_cy)
values ('<a>Add the trial arrangements</a>', 'Hearing' ,'<a>Ychwanegu trefniadau''r treial</a>',
'Gwrandawiad', 'Hearing.Arrangements.Add', 'Scenario.AAA6.CP.TrialReady.Check.Claimant', '{2, 2}', 'CLAIMANT', 12),
('<a>Add the trial arrangements</a>', 'Hearing' ,'<a>Ychwanegu trefniadau''r treial</a>',
'Gwrandawiad', 'Hearing.Arrangements.Add', 'Scenario.AAA6.CP.TrialReady.Check.Defendant', '{2, 2}', 'DEFENDANT', 11);
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_DASHBOARD_NOTIFICATION_FOR_BUNDLE_CREATED_FOR_CLAIMANT1;
import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_BUNDLE_CREATED_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_BUNDLE_CREATED_TRIAL_READY_CLAIMANT;

@ExtendWith(MockitoExtension.class)
public class BundleCreationClaimantNotificationHandlerTest extends BaseCallbackHandlerTest {
Expand All @@ -52,13 +51,14 @@ class AboutToSubmitCallback {

@BeforeEach
void setup() {
when(dashboardApiClient.recordScenario(any(), any(), anyString(), any())).thenReturn(ResponseEntity.of(
Optional.empty()));
when(toggleService.isCaseProgressionEnabled()).thenReturn(true);
}

@Test
void shouldRecordScenario_whenInvokedWhenNotTrialReady() {
when(dashboardApiClient.recordScenario(any(), any(), anyString(), any())).thenReturn(ResponseEntity.of(
Optional.empty()));

CaseData caseData = CaseDataBuilder.builder().atStateTrialReadyCheck().build().toBuilder()
.applicant1Represented(YesOrNo.NO)
.drawDirectionsOrderRequired(YesOrNo.YES)
Expand Down Expand Up @@ -86,6 +86,7 @@ void shouldRecordScenario_whenInvokedWhenNotTrialReady() {

@Test
void shouldRecordScenarioTrialReady_whenInvokedWhenSmallClaimsCase() {

CaseData caseData = CaseDataBuilder.builder().atStateTrialReadyCheck().applicant1Represented(YesOrNo.NO).build();
CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request(
CallbackRequest.builder().eventId(CREATE_DASHBOARD_NOTIFICATION_FOR_BUNDLE_CREATED_FOR_CLAIMANT1.name()).build()
Expand All @@ -99,7 +100,7 @@ void shouldRecordScenarioTrialReady_whenInvokedWhenSmallClaimsCase() {

verify(dashboardApiClient).recordScenario(
caseData.getCcdCaseReference().toString(),
SCENARIO_AAA6_BUNDLE_CREATED_TRIAL_READY_CLAIMANT.getScenario(),
SCENARIO_AAA6_BUNDLE_CREATED_CLAIMANT.getScenario(),
"BEARER_TOKEN",
ScenarioRequestParams.builder().params(scenarioParams).build()
);
Expand All @@ -126,7 +127,7 @@ void shouldRecordScenario_whenInvokedWhenTrialReady() {

verify(dashboardApiClient).recordScenario(
caseData.getCcdCaseReference().toString(),
SCENARIO_AAA6_BUNDLE_CREATED_TRIAL_READY_CLAIMANT.getScenario(),
SCENARIO_AAA6_BUNDLE_CREATED_CLAIMANT.getScenario(),
"BEARER_TOKEN",
ScenarioRequestParams.builder().params(scenarioParams).build()
);
Expand Down
Loading
Loading