-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
d3bfff0
1bc0671
d3d5b79
7f3cc0f
c80cb48
7283e80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
@@ -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 | ||
, notification_role) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a script alignment There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
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); | ||
} | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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