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-16292 Defendant Lip Dashboard Notification-discontinued #5925

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ sonarqube {
property "sonar.coverage.exclusions", "**/model/**, **/config/**/*Configuration.java, **/request/servlet/** , **/controllers/**, **/testingsupport/**, **/*ExternalTaskListener.java, **/*BaseExternalTaskHandler.java, **/stereotypes/**, **/*Exception.java, **/EventHistoryMapper*.java, **/model/hearingvalues/**, **/enums/hearing/**, **/fees/client/**, **/enums/sdo/**, **/service/PaymentsService.java, **/DashboardWithParamsCallbackHandler.java, **/PaymentRequestUpdateCallbackService.java, **/advice/**"
property "sonar.cpd.exclusions", "**/*DocumentManagementService.java, **/*Spec*.java, **/*CcdDashboardClaimantClaimMatcher.java, **/*CcdDashboardDefendantClaimMatcher.java"
property "sonar.exclusions", "**/hmc/model/**, **/model/hearingvalues/**, **/handler/callback/camunda/dashboardnotifications/claimant/CCJRequestedDashboardNotificationHandler.java, **/handler/callback/camunda/dashboardnotifications/claimant/ClaimantCCJResponseNotificationHandler.java" +
", **/handler/callback/camunda/dashboardnotifications/claimant/ClaimantResponseNotificationHandler.java, **/utils/HmcDataUtils.java, **/handler/callback/camunda/dashboardnotifications/defendant/MoreTimeRequestedDashboardNotificationDefendantHandler.java, **/handler/callback/camunda/dashboardnotifications/claimant/ClaimantMediationSuccessfulDashboardNotificationHandler.java, **/handler/callback/camunda/dashboardnotifications/claimant/ClaimSettledDashboardNotificationHandler.java, **/handler/callback/camunda/dashboardnotifications/claimant/HearingScheduledClaimantNotificationHandler.java"
", **/handler/callback/camunda/dashboardnotifications/claimant/ClaimantResponseNotificationHandler.java, **/utils/HmcDataUtils.java, **/handler/callback/camunda/dashboardnotifications/defendant/MoreTimeRequestedDashboardNotificationDefendantHandler.java, **/handler/callback/camunda/dashboardnotifications/claimant/ClaimantMediationSuccessfulDashboardNotificationHandler.java, **/handler/callback/camunda/dashboardnotifications/claimant/ClaimSettledDashboardNotificationHandler.java, **/handler/callback/camunda/dashboardnotifications/claimant/HearingScheduledClaimantNotificationHandler.java" +
", **/handler/callback/camunda/dashboardnotifications/defendant/DefendantNotifyDiscontinuanceDashboardNotificationHandler.java"
property "sonar.host.url", "https://sonar.reform.hmcts.net/"
property "sonar.web.javaOpts", "-Xmx2G"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package uk.gov.hmcts.reform.civil.controllers.dashboard.scenarios.defendant;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import uk.gov.hmcts.reform.civil.controllers.DashboardBaseIntegrationTest;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.defendant.DefendantNotifyDiscontinuanceDashboardNotificationHandler;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder;

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;

public class DefendantNoticeOfDiscontinuanceScenarioTest extends DashboardBaseIntegrationTest {

public static final String DEFENDANT = "DEFENDANT";

@Autowired
private DefendantNotifyDiscontinuanceDashboardNotificationHandler handler;

@Test
void should_create_scenario_for_discontinuance_claim() throws Exception {

String caseId = "4321456";
CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build()
.toBuilder()
.legacyCaseReference("reference")
.ccdCaseReference(Long.valueOf(caseId))
.respondent1Represented(YesOrNo.NO)
.build();

when(featureToggleService.isLipVLipEnabled()).thenReturn(true);

handler.handle(callbackParams(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("A notice of discontinuance has been created and sent to all parties"),
jsonPath("$[0].descriptionEn")
.value(
"<p class=\"govuk-body\">This means that all or part of this claim has been discontinued.<br>Please review the "
+ "<a href=\"{NOTICE_OF_DISCONTINUANCE}\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"govuk-link\">"
+ "notice of discontinuance</a> carefully.</p>"),
jsonPath("$[0].titleCy").value("MMae hysbysiad o ddirwyn i ben wedi’i greu a’i anfon at yr holl bartïon"),
jsonPath("$[0].descriptionCy")
.value(
"<p class=\"govuk-body\">Mae hyn yn golygu bod rhan, neu'r cyfan, o'r hawliad hwn wedi dod i ben.<br>Adolygwch yr "
+ "<a href=\"{NOTICE_OF_DISCONTINUANCE}\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"govuk-link\">"
+ "hysbysiad o ddirwyn i ben</a> yn ofalus.</p>")
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ 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_DEFENDANT_DASHBOARD_NOTIFICATION_FOR_DISCONTINUANCE(CAMUNDA);

private final UserType userType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ 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_DISCONTINUE_NOTICE_OF_DISCONTINUE_ISSUED_DEFENDANT("Scenario.AAA6.Discontinue.NoticeOfDiscontinuanceIssued.Defendant");

private final String scenario;

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

import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
import uk.gov.hmcts.reform.civil.callback.DashboardCallbackHandler;
import uk.gov.hmcts.reform.civil.client.DashboardApiClient;
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 uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_DEFENDANT_DASHBOARD_NOTIFICATION_FOR_DISCONTINUANCE;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_DISCONTINUE_NOTICE_OF_DISCONTINUE_ISSUED_DEFENDANT;

@Service
public class DefendantNotifyDiscontinuanceDashboardNotificationHandler extends DashboardCallbackHandler {

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

public DefendantNotifyDiscontinuanceDashboardNotificationHandler(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) {
if (caseData.isRespondent1LiP()) {
return SCENARIO_AAA6_DISCONTINUE_NOTICE_OF_DISCONTINUE_ISSUED_DEFENDANT.getScenario();
}
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Add scenario
*/
INSERT INTO dbs.scenario (name, notifications_to_delete, notifications_to_create)
VALUES ('Scenario.AAA6.Discontinue.NoticeOfDiscontinuanceIssued.Defendant',
'{}',
'{"Notice.AAA6.Discontinue.NoticeOfDiscontinuanceIssued.Defendant": []}');

/**
* Add notification template
*/
INSERT INTO dbs.dashboard_notifications_templates ( template_name, title_En, title_Cy, description_En, description_Cy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove space before template_name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a script alignment

, notification_role)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

being a bit nitpicky but could we have this comma on the previous line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a script alignment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can the comma not be put up on the previous line without error?
or description_Cy be brought down to line 13?

VALUES ('Notice.AAA6.Discontinue.NoticeOfDiscontinuanceIssued.Defendant',
'A notice of discontinuance has been created and sent to all parties',
'MMae hysbysiad o ddirwyn i ben wedi’i greu a’i anfon at yr holl bartïon',
'<p class="govuk-body">This means that all or part of this claim has been discontinued.<br>Please review the <a href="{NOTICE_OF_DISCONTINUANCE}" target="_blank" rel="noopener noreferrer" class="govuk-link">notice of discontinuance</a> carefully.</p>',
'<p class="govuk-body">Mae hyn yn golygu bod rhan, neu''r cyfan, o''r hawliad hwn wedi dod i ben.<br>Adolygwch yr <a href="{NOTICE_OF_DISCONTINUANCE}" target="_blank" rel="noopener noreferrer" class="govuk-link">hysbysiad o ddirwyn i ben</a> yn ofalus.</p>',
'DEFENDANT');
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.defendant;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.client.DashboardApiClient;
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.sampledata.CallbackParamsBuilder;
import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.dashboard.data.ScenarioRequestParams;

import java.util.HashMap;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_DEFENDANT_DASHBOARD_NOTIFICATION_FOR_DISCONTINUANCE;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_DISCONTINUE_NOTICE_OF_DISCONTINUE_ISSUED_DEFENDANT;

@ExtendWith(MockitoExtension.class)
public class DefendantNotifyDiscontinuanceDashboardNotificationHandlerTest extends BaseCallbackHandlerTest {

@InjectMocks
private DefendantNotifyDiscontinuanceDashboardNotificationHandler handler;

@Mock
private DashboardApiClient dashboardApiClient;

@Mock
private DashboardNotificationsParamsMapper dashboardNotificationsParamsMapper;

@Mock
private FeatureToggleService featureToggleService;

public static final String TASK_ID = "CreateDefendantDashboardNotificationsForDiscontinuance";

HashMap<String, Object> params = new HashMap<>();

@Test
void handleEventsReturnsTheExpectedCallbackEvent() {
assertThat(handler.handledEvents()).contains(
CREATE_DEFENDANT_DASHBOARD_NOTIFICATION_FOR_DISCONTINUANCE);
}

@Test
void shouldReturnCorrectCamundaActivityId_whenInvoked() {
assertThat(handler.camundaActivityId(
CallbackParamsBuilder.builder()
.request(CallbackRequest.builder()
.eventId(CREATE_DEFENDANT_DASHBOARD_NOTIFICATION_FOR_DISCONTINUANCE.name())
.build())
.build()))
.isEqualTo(TASK_ID);
}

@Test
void shouldCreateDashboardNotifications_whenDefendantIsLiPAndDiscontinuedClaim() {
params.put("ccdCaseReference", "123");

when(featureToggleService.isLipVLipEnabled()).thenReturn(true);
when(dashboardNotificationsParamsMapper.mapCaseDataToParams(any())).thenReturn(params);

CaseData caseData = CaseData.builder()
.legacyCaseReference("reference")
.ccdCaseReference(1234L)
.respondent1Represented(YesOrNo.NO)
.build();

CallbackParams callbackParams = CallbackParamsBuilder.builder()
.of(ABOUT_TO_SUBMIT, caseData)
.build();

handler.handle(callbackParams);
verify(dashboardApiClient).recordScenario(
caseData.getCcdCaseReference().toString(),
SCENARIO_AAA6_DISCONTINUE_NOTICE_OF_DISCONTINUE_ISSUED_DEFENDANT.getScenario(),
"BEARER_TOKEN",
ScenarioRequestParams.builder().params(params).build()
);
}

@Test
void shouldNotCreateDashboardNotifications_whenDefendantIsLiPAndDiscontinuedClaim() {
params.put("ccdCaseReference", "123");

when(featureToggleService.isLipVLipEnabled()).thenReturn(true);
when(dashboardNotificationsParamsMapper.mapCaseDataToParams(any())).thenReturn(params);

CaseData caseData = CaseData.builder()
.legacyCaseReference("reference")
.ccdCaseReference(1234L)
.respondent1Represented(YesOrNo.YES)
.build();

CallbackParams callbackParams = CallbackParamsBuilder.builder()
.of(ABOUT_TO_SUBMIT, caseData)
.build();

handler.handle(callbackParams);
verifyNoInteractions(dashboardApiClient);
}
}
Loading