Skip to content

Commit

Permalink
CIV-13484 - Dashboard notification - SDO drawn (claimant + defendant) (
Browse files Browse the repository at this point in the history
…#4719)

* draft changes.

* fixed integration test.

* fixed checkstyle and unit tests.

* fixed functional tests.

* Update DashboardScenarios.java

---------

Co-authored-by: Raja Mani <[email protected]>
Co-authored-by: jarekPierchala <[email protected]>
  • Loading branch information
3 people authored May 29, 2024
1 parent f237674 commit 51b7793
Show file tree
Hide file tree
Showing 15 changed files with 221 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void should_create_order_made_claimant_scenario() throws Exception {
CaseDocument.builder().documentLink(Document.builder().documentBinaryUrl("url").build()).build())))
.build();

when(featureToggleService.isCaseProgressionEnabled()).thenReturn(true);
handler.handle(callbackParamsTest(caseData));

//Verify Notification is created
Expand Down Expand Up @@ -107,6 +108,41 @@ void should_create_order_made_claimant_scenario_mediation_unsuccessful_sdo_carm(
"Ni fydd unrhyw gosbau yn cael eu gosod am eich diffyg presenoldeb.</p>"));
}

@Test
void should_create_order_made_claimant_scenario_pre_cp_release() throws Exception {

String caseId = "72014545415";

CaseData caseData = CaseDataBuilder.builder().atStateRespondentPartAdmissionSpec().build()
.toBuilder()
.legacyCaseReference("reference")
.ccdCaseReference(Long.valueOf(caseId))
.applicant1Represented(YesOrNo.NO)
.finalOrderDocumentCollection(List.of(ElementUtils.element(
CaseDocument.builder().documentLink(Document.builder().documentBinaryUrl("url").build()).build())))
.build();

when(featureToggleService.isCaseProgressionEnabled()).thenReturn(false);
handler.handle(callbackParamsTest(caseData));

//Verify Notification is created
doGet(BEARER_TOKEN, GET_NOTIFICATIONS_URL, caseId, "CLAIMANT")
.andExpect(status().isOk())
.andExpectAll(
status().is(HttpStatus.OK.value()),
jsonPath("$[0].titleEn").value("An order has been issued by the court."),
jsonPath("$[0].descriptionEn").value(
"<p class=\"govuk-body\">Please follow instructions in the order and comply with the deadlines. " +
"Please send any documents to the court named in the order if required. " +
"The claim will now proceed offline, you will receive further updates by post.</p>"),
jsonPath("$[0].titleCy").value("Mae gorchymyn wedi’i gyhoeddi gan y llys."),
jsonPath("$[0].descriptionCy").value(
"<p class=\"govuk-body\">Dilynwch y cyfarwyddiadau sydd yn y gorchymyn a chydymffurfiwch " +
"â’r dyddiadau terfyn. Anfonwch unrhyw ddogfennau i’r llys a enwir yn y gorchymyn os oes angen. " +
"Bydd yr hawliad nawr yn parhau all-lein a byddwch yn cael unrhyw ddiweddariadau pellach drwy’r post.</p>")
);
}

private static CallbackParams callbackParamsTest(CaseData caseData) {
return CallbackParamsBuilder.builder()
.of(ABOUT_TO_SUBMIT, caseData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.math.BigDecimal;

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 @@ -24,6 +25,7 @@ public class UploadHearingDocumentsClaimantScenarioTest extends DashboardBaseInt
void shouldCreateUploadDocumentCaseProgresionScenario() throws Exception {

String caseId = "12345188432991";
when(featureToggleService.isCaseProgressionEnabled()).thenReturn(true);

CaseData caseData = CaseDataBuilder.builder().atStateRespondentFullAdmissionSpec().build()
.toBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void should_create_order_made_defendant_scenario() throws Exception {
CaseDocument.builder().documentLink(Document.builder().documentBinaryUrl("url").build()).build())))
.build();

when(featureToggleService.isCaseProgressionEnabled()).thenReturn(true);
handler.handle(callbackParamsTest(caseData));

//Verify Notification is created
Expand Down Expand Up @@ -107,6 +108,41 @@ void should_create_order_made_defendant_scenario_mediation_unsuccessful_sdo_carm
"ymwneud â pheidio â mynychu apwyntiad cyfryngu. Ni fydd unrhyw gosbau yn cael eu gosod am eich diffyg presenoldeb.</p>"));
}

@Test
void should_create_order_made_claimant_scenario_pre_cp_release() throws Exception {

String caseId = "72014545416";

CaseData caseData = CaseDataBuilder.builder().atStateRespondentPartAdmissionSpec().build()
.toBuilder()
.legacyCaseReference("reference")
.ccdCaseReference(Long.valueOf(caseId))
.respondent1Represented(YesOrNo.NO)
.finalOrderDocumentCollection(List.of(ElementUtils.element(
CaseDocument.builder().documentLink(Document.builder().documentBinaryUrl("url").build()).build())))
.build();

when(featureToggleService.isCaseProgressionEnabled()).thenReturn(false);
handler.handle(callbackParamsTest(caseData));

//Verify Notification is created
doGet(BEARER_TOKEN, GET_NOTIFICATIONS_URL, caseId, "DEFENDANT")
.andExpect(status().isOk())
.andExpectAll(
status().is(HttpStatus.OK.value()),
jsonPath("$[0].titleEn").value("An order has been issued by the court."),
jsonPath("$[0].descriptionEn").value(
"<p class=\"govuk-body\">Please follow instructions in the order and comply with the deadlines. " +
"Please send any documents to the court named in the order if required. " +
"The claim will now proceed offline, you will receive further updates by post.</p>"),
jsonPath("$[0].titleCy").value("Mae gorchymyn wedi’i gyhoeddi gan y llys."),
jsonPath("$[0].descriptionCy").value(
"<p class=\"govuk-body\">Dilynwch y cyfarwyddiadau sydd yn y gorchymyn a chydymffurfiwch " +
"â’r dyddiadau terfyn. Anfonwch unrhyw ddogfennau i’r llys a enwir yn y gorchymyn os oes angen. " +
"Bydd yr hawliad nawr yn parhau all-lein a byddwch yn cael unrhyw ddiweddariadau pellach drwy’r post.</p>")
);
}

private static CallbackParams callbackParamsTest(CaseData caseData) {
return CallbackParamsBuilder.builder()
.of(ABOUT_TO_SUBMIT, caseData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.math.BigDecimal;

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 @@ -25,6 +26,7 @@ void shouldCreateUploadDocumentCaseProgresionScenario() throws Exception {

String caseId = "1234518843299";

when(featureToggleService.isCaseProgressionEnabled()).thenReturn(true);
CaseData caseData = CaseDataBuilder.builder().atStateRespondentFullAdmissionSpec().build()
.toBuilder()
.legacyCaseReference("reference")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ public enum DashboardScenarios {
SCENARIO_AAA6_CP_CLAIM_ISSUE_FAST_TRACK_DEFENDANT("Scenario.AAA6.ClaimIssue.Defendant.FastTrack"),
SCENARIO_AAA6_CLAIMANT_MEDIATION_WHEN_DEFENDANT_NOT_CONTACTABLE("Scenario.AAA6.MediationUnsuccessful.WhenDefendantNotContactable.CARM.Claimant"),
SCENARIO_AAA6_DEFENDANT_MEDIATION_WHEN_CLAIMANT_NOT_CONTACTABLE("Scenario.AAA6.MediationUnsuccessful.WhenClaimantNotContactable.CARM.Defendant"),
SCENARIO_AAA6_CLAIMANT_SDO_DRAWN_PRE_CASE_PROGRESSION("Scenario.AAA6.ClaimantIntent.SDODrawn.PreCaseProgression.Claimant"),
SCENARIO_AAA6_DEFENDANT_SDO_DRAWN_PRE_CASE_PROGRESSION("Scenario.AAA6.ClaimantIntent.SDODrawn.PreCaseProgression.Defendant"),
SCENARIO_AAA6_DEFENDANT_RESPONSE_BILINGUAL_CLAIMANT("Scenario.AAA6.DefResponse.BilingualFlagSet.Claimant"),
SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_CLAIMANT("Scenario.AAA6.CaseProceedsInCaseman.Claimant"),
SCENARIO_AAA6_CASE_PROCEED_IN_CASE_MAN_DEFENDANT("Scenario.AAA6.CaseProceedsInCaseman.Defendant"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_DASHBOARD_NOTIFICATION_SDO_CLAIMANT;
import static uk.gov.hmcts.reform.civil.enums.AllocatedTrack.SMALL_CLAIM;
import static uk.gov.hmcts.reform.civil.enums.mediation.MediationUnsuccessfulReason.NOT_CONTACTABLE_CLAIMANT_ONE;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CLAIMANT_SDO_DRAWN_PRE_CASE_PROGRESSION;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_ORDER_MADE_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_MEDIATION_UNSUCCESSFUL_TRACK_CHANGE_CLAIMANT_CARM;
import static uk.gov.hmcts.reform.civil.utils.MediationUtils.findMediationUnsuccessfulReason;
Expand Down Expand Up @@ -53,6 +54,9 @@ && isSDOEvent(callbackParams)
&& hasTrackChanged(caseData)) {
return SCENARIO_AAA6_MEDIATION_UNSUCCESSFUL_TRACK_CHANGE_CLAIMANT_CARM.getScenario();
}
if (isSDODrawnPreCPRelease()) {
return SCENARIO_AAA6_CLAIMANT_SDO_DRAWN_PRE_CASE_PROGRESSION.getScenario();
}
return SCENARIO_AAA6_CP_ORDER_MADE_CLAIMANT.getScenario();
}

Expand All @@ -66,6 +70,10 @@ private boolean isCarmApplicableCase(CaseData caseData) {
&& SMALL_CLAIM.equals(getPreviousAllocatedTrack(caseData));
}

private boolean isSDODrawnPreCPRelease() {
return !getFeatureToggleService().isCaseProgressionEnabled();
}

private boolean isMediationUnsuccessfulReasonEqualToNotContactableClaimantOne(CaseData caseData) {
return findMediationUnsuccessfulReason(caseData, List.of(NOT_CONTACTABLE_CLAIMANT_ONE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ protected String getScenario(CaseData caseData) {
@Override
public boolean shouldRecordScenario(CaseData caseData) {
// TODO check for Small Claims is because Small Claims does not use a known date
return caseData.isApplicantNotRepresented() && !SdoHelper.isSmallClaimsTrack(caseData);
return caseData.isApplicantNotRepresented()
&& !SdoHelper.isSmallClaimsTrack(caseData)
&& featureToggleService.isCaseProgressionEnabled();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static uk.gov.hmcts.reform.civil.enums.AllocatedTrack.SMALL_CLAIM;
import static uk.gov.hmcts.reform.civil.enums.mediation.MediationUnsuccessfulReason.NOT_CONTACTABLE_DEFENDANT_ONE;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_ORDER_MADE_DEFENDANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_DEFENDANT_SDO_DRAWN_PRE_CASE_PROGRESSION;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_MEDIATION_UNSUCCESSFUL_TRACK_CHANGE_DEFENDANT_CARM;
import static uk.gov.hmcts.reform.civil.utils.MediationUtils.findMediationUnsuccessfulReason;

Expand Down Expand Up @@ -53,6 +54,9 @@ && isSDOEvent(callbackParams)
&& hasTrackChanged(caseData)) {
return SCENARIO_AAA6_MEDIATION_UNSUCCESSFUL_TRACK_CHANGE_DEFENDANT_CARM.getScenario();
}
if (isSDODrawnPreCPRelease()) {
return SCENARIO_AAA6_DEFENDANT_SDO_DRAWN_PRE_CASE_PROGRESSION.getScenario();
}
return SCENARIO_AAA6_CP_ORDER_MADE_DEFENDANT.getScenario();
}

Expand All @@ -75,6 +79,10 @@ private boolean isSDOEvent(CallbackParams callbackParams) {
.equals(CaseEvent.valueOf(callbackParams.getRequest().getEventId()));
}

private boolean isSDODrawnPreCPRelease() {
return !getFeatureToggleService().isCaseProgressionEnabled();
}

private boolean hasTrackChanged(CaseData caseData) {
return SMALL_CLAIM.equals(getPreviousAllocatedTrack(caseData))
&& !caseData.isSmallClaim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ protected String getScenario(CaseData caseData) {
@Override
public boolean shouldRecordScenario(CaseData caseData) {
// TODO check for Small Claims is because Small Claims does not use a known date
return caseData.isRespondent1NotRepresented() && !SdoHelper.isSmallClaimsTrack(caseData);
return caseData.isRespondent1NotRepresented()
&& !SdoHelper.isSmallClaimsTrack(caseData)
&& featureToggleService.isCaseProgressionEnabled();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Add scenario
*/
INSERT INTO dbs.scenario (name, notifications_to_delete, notifications_to_create)
VALUES ('Scenario.AAA6.ClaimantIntent.SDODrawn.PreCaseProgression.Claimant',
'{ "Notice.AAA6.ClaimantIntent.GoToHearing.Claimant",
"Notice.AAA6.ClaimantIntent.MediationUnsuccessful.Claimant"}', '{"Notice.AAA6.ClaimantIntent.SDODrawn.PreCaseProgression.Claimant" : []}');

/**
* Add notification template
*/
INSERT INTO dbs.dashboard_notifications_templates (template_name, title_En, title_Cy, description_En, description_Cy
,notification_role)
VALUES ('Notice.AAA6.ClaimantIntent.SDODrawn.PreCaseProgression.Claimant', 'An order has been issued by the court.', 'Mae gorchymyn wedi’i gyhoeddi gan y llys.',
'<p class="govuk-body">Please follow instructions in the order and comply with the deadlines. Please send any documents to the court named in the order if required. The claim will now proceed offline, you will receive further updates by post.</p>',
'<p class="govuk-body">Dilynwch y cyfarwyddiadau sydd yn y gorchymyn a chydymffurfiwch â’r dyddiadau terfyn. Anfonwch unrhyw ddogfennau i’r llys a enwir yn y gorchymyn os oes angen. Bydd yr hawliad nawr yn parhau all-lein a byddwch yn cael unrhyw ddiweddariadau pellach drwy’r post.</p>',
'CLAIMANT');
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Add scenario
*/
INSERT INTO dbs.scenario (name, notifications_to_delete, notifications_to_create)
VALUES ('Scenario.AAA6.ClaimantIntent.SDODrawn.PreCaseProgression.Defendant',
'{"Notice.AAA6.ClaimantIntent.GoToHearing.DefPartAdmit.Defendant",
"Notice.AAA6.ClaimantIntent.GoToHearing.DefPartAdmit.FullDefence.StatesPaid.ClaimantConfirms.Defendant",
"Notice.AAA6.ClaimantIntent.GoToHearing.DefPartAdmit.FullDefence.StatesPaid.PartOrFull.ClaimantDisputes.Defendant",
"Notice.AAA6.ClaimantIntent.GoToHearing.DefFullDefence.ClaimantDisputes.Defendant",
"Notice.AAA6.ClaimantIntent.GoToHearing.DefFullDefence.ClaimantDisputes.NoMediation.Defendant",
"Notice.AAA6.ClaimantIntent.MediationUnsuccessful.Defendant"}', '{"Notice.AAA6.ClaimantIntent.SDODrawn.PreCaseProgression.Defendant" : []}');

/**
* Add notification template
*/
INSERT INTO dbs.dashboard_notifications_templates (template_name, title_En, title_Cy, description_En, description_Cy
,notification_role)
VALUES ('Notice.AAA6.ClaimantIntent.SDODrawn.PreCaseProgression.Defendant', 'An order has been issued by the court.', 'Mae gorchymyn wedi’i gyhoeddi gan y llys.',
'<p class="govuk-body">Please follow instructions in the order and comply with the deadlines. Please send any documents to the court named in the order if required. The claim will now proceed offline, you will receive further updates by post.</p>',
'<p class="govuk-body">Dilynwch y cyfarwyddiadau sydd yn y gorchymyn a chydymffurfiwch â’r dyddiadau terfyn. Anfonwch unrhyw ddogfennau i’r llys a enwir yn y gorchymyn os oes angen. Bydd yr hawliad nawr yn parhau all-lein a byddwch yn cael unrhyw ddiweddariadau pellach drwy’r post.</p>',
'DEFENDANT');
Loading

0 comments on commit 51b7793

Please sign in to comment.