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-10907 - Claimant LiP notification at Hearing Scheduled #3371

Merged
merged 19 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
cc666d3
CIV-10907 - Claimant LiP notification at Hearing Scheduled
m-meulendijks-v1 Oct 9, 2023
0ee4f6f
Merge branch 'master' into feat/CIV-10907
m-meulendijks-v1 Oct 9, 2023
1719f23
Merge branch 'master' into feat/CIV-10907
m-meulendijks-v1 Oct 10, 2023
0002a22
Merge branch 'master' into feat/CIV-10907
m-meulendijks-v1 Oct 31, 2023
36305ea
Merge branch 'master' into feat/CIV-10907
m-meulendijks-v1 Nov 3, 2023
a5b3924
Merge branch 'master' into feat/CIV-10907
m-meulendijks-v1 Nov 14, 2023
7127a16
Merge branch 'master' into feat/CIV-10907
m-meulendijks-v1 Nov 17, 2023
41afd07
CIV-10370 Add SDO claimant lip Notification
miguelMolina3691 Oct 6, 2023
7528ee0
CIV-10370 update test
miguelMolina3691 Oct 10, 2023
a0397ac
Merge branch 'master' into feat/CIV-10907
m-meulendijks-v1 Nov 20, 2023
524cfaa
CIV-10907 - worked around feature toggle for early adopters
m-meulendijks-v1 Nov 20, 2023
8af5a7e
Merge branch 'master' into feat/CIV-10907
marianadpereira Nov 20, 2023
bbacb15
Merge branch 'master' into feat/CIV-10907
m-meulendijks-v1 Nov 21, 2023
7c08ec6
Merge branch 'master' into feat/CIV-10907
dharmendrak Nov 21, 2023
cfe996c
Merge branch 'master' into feat/CIV-10907
marianadpereira Nov 22, 2023
9c99cad
Merge branch 'master' into feat/CIV-10907
laarmada Nov 30, 2023
40909ff
Merge branch 'master' into feat/CIV-10907
marianadpereira Dec 1, 2023
5c62fed
Merge branch 'master' into feat/CIV-10907
marianadpereira Dec 1, 2023
3b3231e
Merge branch 'master' into feat/CIV-10907
marianadpereira Dec 1, 2023
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 @@ -57,18 +57,10 @@ public List<CaseEvent> handledEvents() {
private CallbackResponse notifyApplicantsSolicitorSDOTriggered(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();

String unspecTemplate = featureToggleService.isEarlyAdoptersEnabled()
? notificationsProperties.getSdoOrderedEA() : notificationsProperties.getSdoOrdered();

String specTemplate = featureToggleService.isEarlyAdoptersEnabled()
? notificationsProperties.getSdoOrderedSpecEA() : notificationsProperties.getSdoOrderedSpec();

notificationService.sendMail(
caseData.getApplicantSolicitor1UserDetails().getEmail(),
caseData.getCaseAccessCategory() == CaseCategory.SPEC_CLAIM
? specTemplate
: unspecTemplate,
addProperties(caseData),
getRecipientEmail(caseData),
getNotificationTemplate(caseData),
getEmailProperties(caseData),
String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference())
);

Expand All @@ -84,9 +76,45 @@ CLAIM_LEGAL_ORG_NAME_SPEC, getApplicantsLegalOrganizationName(caseData.getApplic
);
}

public Map<String, String> addPropertiesLip(CaseData caseData) {
return Map.of(
CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(),
CLAIMANT_NAME, caseData.getApplicant1().getPartyName()
);
}

public String getApplicantsLegalOrganizationName(String id, CaseData caseData) {
Optional<Organisation> organisation = organisationService.findOrganisationById(id);
return organisation.isPresent() ? organisation.get().getName() :
caseData.getApplicantSolicitor1ClaimStatementOfTruth().getName();
}

private String getNotificationTemplate(CaseData caseData) {

String unspecTemplate = featureToggleService.isEarlyAdoptersEnabled()
? notificationsProperties.getSdoOrderedEA() : notificationsProperties.getSdoOrdered();

String specTemplate = featureToggleService.isEarlyAdoptersEnabled()
? notificationsProperties.getSdoOrderedSpecEA() : notificationsProperties.getSdoOrderedSpec();

if (caseData.isApplicantLiP()) {
return notificationsProperties.getClaimantLipClaimUpdatedTemplate();
} else {
if (caseData.getCaseAccessCategory() == CaseCategory.SPEC_CLAIM) {
return specTemplate;
} else {
return unspecTemplate;
}
}
}

private String getRecipientEmail(CaseData caseData) {
return caseData.isApplicantLiP() ? caseData.getClaimantUserDetails().getEmail()
: caseData.getApplicantSolicitor1UserDetails().getEmail();
}

private Map<String, String> getEmailProperties(CaseData caseData) {
return caseData.isApplicantLiP() ? addPropertiesLip(caseData)
: addProperties(caseData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public String camundaActivityId(CallbackParams callbackParams) {
private CallbackResponse notifyClaimantHearing(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
boolean isApplicantLip = isApplicantLip(caseData);
String recipient = caseData.getApplicantSolicitor1UserDetails().getEmail();

if (isEvent(callbackParams, NOTIFY_CLAIMANT_HEARING_HMC)) {
String recipient = caseData.getApplicantSolicitor1UserDetails().getEmail();
sendEmailHMC(caseData, recipient);
} else if (isEvent(callbackParams, NOTIFY_CLAIMANT_HEARING)) {
sendEmail(caseData, getRecipient(caseData, isApplicantLip), getReferenceTemplate(caseData, isApplicantLip), isApplicantLip);
Expand Down Expand Up @@ -142,7 +142,7 @@ private boolean isApplicantLip(CaseData caseData) {
}

private String getRecipient(CaseData caseData, boolean isApplicantLip) {
return isApplicantLip ? caseData.getApplicant1().getPartyEmail()
return isApplicantLip ? caseData.getClaimantUserDetails().getEmail()
: caseData.getApplicantSolicitor1UserDetails().getEmail();
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,11 @@ public boolean isRespondent1LiP() {
return YesOrNo.NO == getRespondent1Represented();
}

@JsonIgnore
public boolean isApplicantLiP() {
return YesOrNo.NO == getApplicant1Represented();
}

public YesOrNo getRespondent2Represented() {
return Stream.of(
respondent2Represented,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest;
import uk.gov.hmcts.reform.ccd.model.OrganisationPolicy;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.enums.CaseCategory;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.model.IdamUserDetails;
import uk.gov.hmcts.reform.civil.model.StatementOfTruth;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest;
import uk.gov.hmcts.reform.civil.model.CaseData;
Expand All @@ -29,6 +34,7 @@
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.handler.callback.camunda.notification.CreateSDOApplicantsNotificationHandler.TASK_ID;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIMANT_NAME;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIM_LEGAL_ORG_NAME_SPEC;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIM_REFERENCE_NUMBER;
import static uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder.LEGACY_CASE_REFERENCE;
Expand Down Expand Up @@ -57,32 +63,97 @@ class AboutToSubmitCallback {
@BeforeEach
void setup() {
when(notificationsProperties.getSdoOrdered()).thenReturn("template-id");
when(notificationsProperties.getSdoOrderedSpec()).thenReturn("template-id-spec");
when(notificationsProperties.getSdoOrderedEA()).thenReturn("template-id-EA");
when(notificationsProperties.getSdoOrderedSpecEA()).thenReturn("template-id-spec-EA");
when(notificationsProperties.getClaimantLipClaimUpdatedTemplate()).thenReturn("template-id-lip");
when(organisationService.findOrganisationById(anyString()))
.thenReturn(Optional.of(Organisation.builder().name("Signer Name").build()));
when(featureToggleService.isEarlyAdoptersEnabled()).thenReturn(false);
}

@Test
void shouldNotifyApplicantSolicitor_whenInvoked() {
// Given
CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build();
CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build();
// When
handler.handle(params);
// Then
verify(notificationService).sendMail(
"[email protected]",
"template-id",
getNotificationDataMap(),
"create-sdo-applicants-notification-000DC001"
);
}

@Test
void shouldNotifyApplicantLip_whenInvoked() {
// Given
CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build()
.toBuilder().claimantUserDetails(IdamUserDetails.builder().email("[email protected]").build())
.applicant1Represented(YesOrNo.NO)
.build();
CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build();
// When
handler.handle(params);
// Then
verify(notificationService).sendMail(
"[email protected]",
"template-id-lip",
getNotificationDataMapLip(),
"create-sdo-applicants-notification-000DC001"
);
}

@Test
void shouldNotifyApplicantSolicitorStatement_whenInvoked() {
// Given
CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build()
.toBuilder()
.applicant1Represented(YesOrNo.YES)
.applicant1OrganisationPolicy(OrganisationPolicy.builder().organisation(
uk.gov.hmcts.reform.ccd.model.Organisation.builder().organisationID("abc1").build()).build())
.caseAccessCategory(CaseCategory.SPEC_CLAIM)
.applicantSolicitor1ClaimStatementOfTruth(StatementOfTruth.builder().name("test name").build())
.build();
CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build();
// When
when(organisationService.findOrganisationById(anyString())).thenReturn(Optional.empty());
handler.handle(params);
// Then
verify(notificationService).sendMail(
"[email protected]",
"template-id",
getNotificationDataMap(caseData),
"template-id-spec",
getNotificationDataMapStatement(),
"create-sdo-applicants-notification-000DC001"
);
}

@NotNull
private Map<String, String> getNotificationDataMap(CaseData caseData) {
private Map<String, String> getNotificationDataMap() {
return Map.of(
CLAIM_REFERENCE_NUMBER, LEGACY_CASE_REFERENCE,
CLAIM_LEGAL_ORG_NAME_SPEC, "Signer Name"
);
}

@NotNull
private Map<String, String> getNotificationDataMapLip() {
return Map.of(
CLAIM_REFERENCE_NUMBER, LEGACY_CASE_REFERENCE,
CLAIMANT_NAME, "Mr. John Rambo"
);
}

@NotNull
private Map<String, String> getNotificationDataMapStatement() {
return Map.of(
CLAIM_REFERENCE_NUMBER, LEGACY_CASE_REFERENCE,
CLAIM_LEGAL_ORG_NAME_SPEC, "test name"
);
}
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,13 @@ void shouldNotifyApplicantSolicitor_whenInvokedNoFeeAnd2v1() {
}

@Test
void shouldNotifyApplicantSolicitorLip_whenInvokedAnd1v1() {
void shouldNotifyApplicantLip_whenInvokedAnd1v1() {
// Given
CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build().toBuilder()
.hearingDate(LocalDate.of(2023, 05, 17))
.hearingTimeHourMinute("1030")
.applicant1Represented(YesOrNo.NO)
.applicant1(Party.builder().partyName("John").partyEmail("[email protected]").type(Party.Type.INDIVIDUAL).build())
.claimantUserDetails(IdamUserDetails.builder().email("[email protected]").build())
.hearingReferenceNumber("000HN001")
.addApplicant2(YesOrNo.NO)
.addRespondent2(YesOrNo.NO)
Expand Down
Loading