-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CIV-15228 Stay Lifted LIP Email Notification (#5627)
* CIV-15230 Notify LR stay update requested * CIV-15230 add template * CIV-15230 add abstract classes * CIV-15230 lint * CIV-15230 lint * CIV-15228 Stay Lift Lip Email Notification * CIV-15228 sonar issues * CIV-15228 sonar issues * CIV-15228 checkstyle error --------- Co-authored-by: miguelMolina3691 <[email protected]> Co-authored-by: Miguel Molina <[email protected]> Co-authored-by: mounikahmcts <[email protected]> Co-authored-by: ss-evoco <[email protected]>
- Loading branch information
1 parent
7d8dec8
commit a5e152f
Showing
9 changed files
with
196 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,25 +3,36 @@ | |
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
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.ccd.client.model.CallbackResponse; | ||
import uk.gov.hmcts.reform.civil.callback.CallbackParams; | ||
import uk.gov.hmcts.reform.civil.callback.CaseEvent; | ||
import uk.gov.hmcts.reform.civil.enums.YesOrNo; | ||
import uk.gov.hmcts.reform.civil.enums.dq.Language; | ||
import uk.gov.hmcts.reform.civil.model.CaseData; | ||
import uk.gov.hmcts.reform.civil.model.IdamUserDetails; | ||
import uk.gov.hmcts.reform.civil.model.Party; | ||
import uk.gov.hmcts.reform.civil.model.citizenui.CaseDataLiP; | ||
import uk.gov.hmcts.reform.civil.model.citizenui.RespondentLiPResponse; | ||
import uk.gov.hmcts.reform.civil.notify.NotificationService; | ||
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; | ||
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.mockito.Mockito.verify; | ||
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.NOTIFY_CLAIMANT_STAY_LIFTED; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
|
@@ -38,6 +49,38 @@ class NotifyClaimantStayLiftedHandlerTest { | |
|
||
private CaseData caseData; | ||
|
||
private CaseDataBuilder commonCaseData() { | ||
return CaseDataBuilder.builder().atStateClaimDetailsNotified() | ||
.claimantUserDetails(IdamUserDetails.builder().email("[email protected]").build()) | ||
.applicant1(Party.builder().individualFirstName("John").individualLastName("Doe") | ||
.type(Party.Type.INDIVIDUAL).build()) | ||
.respondent1(Party.builder().individualFirstName("Jack").individualLastName("Jackson") | ||
.type(Party.Type.INDIVIDUAL).build()) | ||
.applicantSolicitor1UserDetails(IdamUserDetails.builder().email("[email protected]").build()); | ||
} | ||
|
||
private CaseData getCaseData(boolean isClaimantLiP, boolean isClaimantBilingual) { | ||
String claimantBilingualLanguagePreference = isClaimantBilingual ? Language.BOTH.toString() | ||
: Language.ENGLISH.toString(); | ||
RespondentLiPResponse respondentLip = RespondentLiPResponse.builder() | ||
.respondent1ResponseLanguage(claimantBilingualLanguagePreference).build(); | ||
return commonCaseData() | ||
.applicant1Represented(isClaimantLiP ? YesOrNo.NO : YesOrNo.YES) | ||
.applicantSolicitor1UserDetails(IdamUserDetails.builder().email("[email protected]").build()) | ||
.claimantBilingualLanguagePreference(claimantBilingualLanguagePreference) | ||
.build().toBuilder() | ||
.caseDataLiP(CaseDataLiP.builder() | ||
.respondent1LiPResponse(respondentLip).build()) | ||
.build(); | ||
} | ||
|
||
static Stream<Arguments> provideCaseDataLip() { | ||
return Stream.of( | ||
Arguments.of(true, true, "bilingual-template"), | ||
Arguments.of(true, false, "default-template") | ||
); | ||
} | ||
|
||
@BeforeEach | ||
void setUp() { | ||
caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified() | ||
|
@@ -77,7 +120,46 @@ void sendNotificationShouldSendEmail() { | |
"solicitor-template", | ||
Map.of( | ||
"claimReferenceNumber", "1594901956117591", | ||
"name", "John Doe" | ||
"name", "John Doe", | ||
"claimantvdefendant", "John Doe V Jack Jackson" | ||
), | ||
"stay-lifted-claimant-notification-1594901956117591" | ||
); | ||
assertNotNull(response); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("provideCaseDataLip") | ||
void sendNotificationShouldSendEmail(boolean isRespondentLiP, boolean isRespondentBilingual, String template) { | ||
CaseData caseData = getCaseData(isRespondentLiP, isRespondentBilingual); | ||
|
||
CallbackRequest callbackRequest = CallbackRequest | ||
.builder() | ||
.eventId(CaseEvent.NOTIFY_CLAIMANT_DISMISS_CASE.name()) | ||
.build(); | ||
CallbackParams params = CallbackParams.builder() | ||
.request(callbackRequest) | ||
.caseData(caseData) | ||
.type(ABOUT_TO_SUBMIT) | ||
.build(); | ||
|
||
if (isRespondentLiP && isRespondentBilingual) { | ||
when(notificationsProperties.getNotifyLipUpdateTemplateBilingual()).thenReturn("bilingual-template"); | ||
} else if (isRespondentLiP) { | ||
when(notificationsProperties.getNotifyLipUpdateTemplate()).thenReturn("default-template"); | ||
} else { | ||
when(notificationsProperties.getNotifyLRStayLifted()).thenReturn("solicitor-template"); | ||
} | ||
|
||
CallbackResponse response = handler.sendNotification(params); | ||
|
||
verify(notificationService).sendMail( | ||
isRespondentLiP ? "[email protected]" : "[email protected]", | ||
template, | ||
Map.of( | ||
"claimReferenceNumber", "1594901956117591", | ||
"name", "John Doe", | ||
"claimantvdefendant", "John Doe V Jack Jackson" | ||
), | ||
"stay-lifted-claimant-notification-1594901956117591" | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,12 @@ | |
import uk.gov.hmcts.reform.civil.callback.CallbackParams; | ||
import uk.gov.hmcts.reform.civil.callback.CaseEvent; | ||
import uk.gov.hmcts.reform.civil.enums.YesOrNo; | ||
import uk.gov.hmcts.reform.civil.enums.dq.Language; | ||
import uk.gov.hmcts.reform.civil.model.CaseData; | ||
import uk.gov.hmcts.reform.civil.model.IdamUserDetails; | ||
import uk.gov.hmcts.reform.civil.model.Party; | ||
import uk.gov.hmcts.reform.civil.model.citizenui.CaseDataLiP; | ||
import uk.gov.hmcts.reform.civil.model.citizenui.RespondentLiPResponse; | ||
import uk.gov.hmcts.reform.civil.notify.NotificationService; | ||
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; | ||
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; | ||
|
@@ -29,6 +32,7 @@ | |
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.mockito.Mockito.verify; | ||
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.NOTIFY_DEFENDANT2_STAY_LIFTED; | ||
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_DEFENDANT_STAY_LIFTED; | ||
|
||
|
@@ -112,7 +116,8 @@ void sendNotificationShouldSendEmail(boolean isDefendant2, CaseEvent caseEvent) | |
"solicitor-template", | ||
Map.of( | ||
"claimReferenceNumber", "1594901956117591", | ||
"name", "Jim Jameson" | ||
"name", "Jim Jameson", | ||
"claimantvdefendant", "Mr. John Rambo V Jack Jackson" | ||
), | ||
"stay-lifted-defendant-notification-1594901956117591" | ||
); | ||
|
@@ -122,12 +127,82 @@ void sendNotificationShouldSendEmail(boolean isDefendant2, CaseEvent caseEvent) | |
"solicitor-template", | ||
Map.of( | ||
"claimReferenceNumber", "1594901956117591", | ||
"name", "Jack Jackson" | ||
"name", "Jack Jackson", | ||
"claimantvdefendant", "Mr. John Rambo V Jack Jackson" | ||
), | ||
"stay-lifted-defendant-notification-1594901956117591" | ||
); | ||
} | ||
assertNotNull(response); | ||
} | ||
|
||
private CaseDataBuilder commonCaseData() { | ||
return CaseDataBuilder.builder().atStateClaimDetailsNotified() | ||
.claimantUserDetails(IdamUserDetails.builder().email("[email protected]").build()) | ||
.applicant1(Party.builder().individualFirstName("John").individualLastName("Doe") | ||
.type(Party.Type.INDIVIDUAL).build()) | ||
.respondent1(Party.builder().individualFirstName("Jack").individualLastName("Jackson") | ||
.partyEmail("[email protected]") | ||
.type(Party.Type.INDIVIDUAL).build()) | ||
.respondentSolicitor1EmailAddress("[email protected]"); | ||
} | ||
|
||
private CaseData getCaseData(boolean isRespondentLiP, boolean isRespondentBilingual) { | ||
RespondentLiPResponse respondentLip = RespondentLiPResponse.builder() | ||
.respondent1ResponseLanguage(isRespondentBilingual ? Language.BOTH.toString() | ||
: Language.ENGLISH.toString()).build(); | ||
return commonCaseData() | ||
.respondent1Represented(isRespondentLiP ? YesOrNo.NO : YesOrNo.YES) | ||
|
||
.build().toBuilder() | ||
.caseDataLiP(CaseDataLiP.builder() | ||
.respondent1LiPResponse(respondentLip).build()) | ||
.build(); | ||
} | ||
|
||
static Stream<Arguments> provideLipCaseData() { | ||
return Stream.of( | ||
Arguments.of(true, true, "bilingual-template"), | ||
Arguments.of(true, false, "default-template") | ||
); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("provideLipCaseData") | ||
void sendNotificationShouldSendLipEmail(boolean isRespondentLiP, boolean isRespondentBilingual, String template) { | ||
CaseData caseData = getCaseData(isRespondentLiP, isRespondentBilingual); | ||
|
||
CallbackRequest callbackRequest = CallbackRequest | ||
.builder() | ||
.eventId(CaseEvent.NOTIFY_DEFENDANT_DISMISS_CASE.name()) | ||
.build(); | ||
CallbackParams params = CallbackParams.builder() | ||
.request(callbackRequest) | ||
.caseData(caseData) | ||
.type(ABOUT_TO_SUBMIT) | ||
.build(); | ||
|
||
if (isRespondentLiP && isRespondentBilingual) { | ||
when(notificationsProperties.getNotifyLipUpdateTemplateBilingual()).thenReturn("bilingual-template"); | ||
} else if (isRespondentLiP) { | ||
when(notificationsProperties.getNotifyLipUpdateTemplate()).thenReturn("default-template"); | ||
} else { | ||
when(notificationsProperties.getNotifyLRStayLifted()).thenReturn("solicitor-template"); | ||
} | ||
|
||
CallbackResponse response = handler.sendNotification(params); | ||
|
||
verify(notificationService).sendMail( | ||
isRespondentLiP ? "[email protected]" : "[email protected]", | ||
template, | ||
Map.of( | ||
"claimReferenceNumber", "1594901956117591", | ||
"name", "Jack Jackson", | ||
"claimantvdefendant", "John Doe V Jack Jackson" | ||
), | ||
"stay-lifted-defendant-notification-1594901956117591" | ||
); | ||
assertNotNull(response); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters