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

DTSPB-4373 Send Sealed and Certified Email #2926

Merged
merged 10 commits into from
Dec 19, 2024
1 change: 1 addition & 0 deletions Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def secrets = [
secret('excelaEmail', 'EXCELA_EMAIL'),
secret('smeeAndFordEmail', 'SMEE_AND_FORD_EMAIL'),
secret('hmrcEmail', 'HMRC_EMAIL'),
secret('sealedAndCertifiedEmail', 'SEALED_AND_CERTIFIED_EMAIL'),
secret('ftpSignature', 'FTP_SIGNATURE'),
secret('ftpEnv', 'FTP_ENV'),
secret('probate-bo-grantSignatureKey', 'PDF_SERVICE_GRANTSIGNATURESECRETKEY'),
Expand Down
2 changes: 1 addition & 1 deletion charts/probate-back-office/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
description: A Helm chart for the HMCTS probate back office service
name: probate-back-office
home: https://github.com/hmcts/probate-back-office
version: 1.0.47
version: 1.0.48
maintainers:
- name: HMCTS Probate Team
email: [email protected]
Expand Down
2 changes: 2 additions & 0 deletions charts/probate-back-office/values.preview.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ java:
alias: smeeAndFordEmail
- name: hmrcEmail
alias: hmrcEmail
- name: sealedAndCertifiedEmail
alias: sealedAndCertifiedEmail
- name: ftpSignature
alias: ftp.client.signature
- name: ftpEnv
Expand Down
2 changes: 2 additions & 0 deletions charts/probate-back-office/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ java:
alias: smeeAndFordEmail
- name: hmrcEmail
alias: hmrcEmail
- name: sealedAndCertifiedEmail
alias: sealedAndCertifiedEmail
- name: ftpSignature
alias: ftp.client.signature
- name: ftpEnv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public void setUp() throws NotificationClientException {

when(notificationService.sendEmail(any(State.class), any(CaseDetails.class))).thenReturn(document);

when(notificationService.sendSealedAndCertifiedEmail(any(CaseDetails.class))).thenReturn(document);

when(documentGeneratorService.generateGrantReissue(any(), any(), any())).thenReturn(document);
when(documentGeneratorService.generateCoversheet(any(CallbackRequest.class)))
.thenReturn(Document.builder().documentType(DocumentType.GRANT_COVERSHEET).build());
Expand Down Expand Up @@ -293,6 +295,7 @@ void generateDigitalGrantReissueWithBulkPrint() throws Exception {
is(DIGITAL_GRANT_REISSUE.getTemplateName())))
.andReturn();

verify(notificationService).sendSealedAndCertifiedEmail(any(CaseDetails.class));
verify(bulkPrintService)
.optionallySendToBulkPrint(any(CallbackRequest.class), any(Document.class), any(Document.class), eq(true));
}
Expand Down Expand Up @@ -334,6 +337,7 @@ void generateDigitalGrantIfLocalPrint() throws Exception {
jsonPath("$.data.probateDocumentsGenerated[1].value.DocumentType", is(DIGITAL_GRANT.getTemplateName())))
.andReturn();
verify(notificationService).sendEmail(eq(State.GRANT_ISSUED), any(CaseDetails.class));
verify(notificationService).sendSealedAndCertifiedEmail(any(CaseDetails.class));
verify(documentGeneratorService)
.getDocument(any(CallbackRequest.class), eq(DocumentStatus.FINAL), eq(DocumentIssueType.GRANT));
}
Expand All @@ -352,6 +356,7 @@ void generateDigitalGrantIntestacy() throws Exception {
.andExpect(status().isOk())
.andReturn();
verify(notificationService).sendEmail(eq(State.GRANT_ISSUED_INTESTACY), any(CaseDetails.class));
verify(notificationService).sendSealedAndCertifiedEmail(any(CaseDetails.class));
verify(documentGeneratorService)
.getDocument(any(CallbackRequest.class), eq(DocumentStatus.FINAL), eq(DocumentIssueType.GRANT));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2028,6 +2028,31 @@ void sendApplicationReceivedEmailCreatedByCaseWorkerPPIsExecToSolicitor()
verify(pdfManagementService).generateAndUpload(any(SentEmail.class), eq(SENT_EMAIL));
}

@Test
void verifysendsendSealedAndCertifiedEmail()
throws NotificationClientException, BadRequestException {

CaseDetails caseDetails = new CaseDetails(CaseData.builder()
.applicationType(SOLICITOR)
.deceasedForenames("Deceased")
.deceasedSurname("DeceasedL")
.build(), LAST_MODIFIED, ID);
notificationService.sendSealedAndCertifiedEmail(caseDetails);

HashMap<String, String> personalisation = new HashMap<>();

personalisation.put(PERSONALISATION_CCD_REFERENCE, caseDetails.getId().toString());
personalisation.put(PERSONALISATION_DECEASED_NAME, caseDetails.getData().getDeceasedFullName());

verify(notificationClient).sendEmail(
eq("sealed-and-certified"),
eq("[email protected]"),
eq(personalisation),
eq("1"));

verify(pdfManagementService).generateAndUpload(any(SentEmail.class), eq(SENT_EMAIL));
}

@Test
void verifySendNocEmail()
throws NotificationClientException, BadRequestException {
Expand Down
5 changes: 5 additions & 0 deletions src/integrationTest/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ notifications:
redeclarationSot: "pa-redeclaration-sot"
grantDelayed: "pa-grantDelayed"
grantAwaitingDocumentation: "pa-grantAwaitingDoc"
sealedAndCertified: "sealed-and-certified"
solicitor:
applicationReceived: "sol-application-received"
applicationReceivedNoDocs: "sol-application-received-no-docs"
Expand All @@ -184,6 +185,7 @@ notifications:
grantDelayed: "sols-grantDelayed"
grantAwaitingDocumentation: "sols-grantAwaitingDoc"
noticeOfChangeReceived: "sols-noc"
sealedAndCertified: "sealed-and-certified"
welsh:
personal:
applicationReceived: "pa-application-received-welsh"
Expand All @@ -206,6 +208,7 @@ notifications:
redeclarationSot: "pa-redeclaration-sot-welsh"
grantDelayed: "pa-grantDelayed-welsh"
grantAwaitingDocumentation: "pa-grantAwaitingDoc-welsh"
sealedAndCertified: "sealed-and-certified"
solicitor:
applicationReceived: "sol-application-received-welsh"
applicationReceivedNoDocs: "sol-application-received-no-docs-welsh"
Expand All @@ -226,6 +229,7 @@ notifications:
grantDelayed: "sols-grantDelayed-welsh"
grantAwaitingDocumentation: "sols-grantAwaitingDoc-welsh"
noticeOfChangeReceived: "sols-noc"
sealedAndCertified: "sealed-and-certified"

documents:
templates:
Expand Down Expand Up @@ -408,6 +412,7 @@ idam-s2s-auth:
excelaEmail: [email protected]
smeeAndFordEmail: [email protected]
hmrcEmail: ${HMRC_EMAIL:[email protected]}
sealedAndCertifiedEmail: [email protected]

data-extract:
pagination:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public class EmailAddresses {
private String smeeAndFordEmail;

private String hmrcEmail;

private String sealedAndCertifiedEmail;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ public class EmailTemplates {
private String grantAwaitingDocumentation;
private String hmrcExtract;
private String noticeOfChangeReceived;
private String sealedAndCertified;
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ public ResponseEntity<CallbackResponse> generateGrant(
documents.add(digitalGrantDocument);
documents.add(coverSheet);
Optional<UserInfo> caseworkerInfo = userInfoService.getCaseworkerInfo();
if (caseData.getOutsideUKGrantCopies() != null && caseData.getOutsideUKGrantCopies() > 0) {
documents.add(notificationService.sendSealedAndCertifiedEmail(caseDetails));
}
MarcusHMCTS marked this conversation as resolved.
Show resolved Hide resolved
if (caseData.isGrantIssuedEmailNotificationRequested()) {
callbackResponse =
eventValidationService.validateEmailRequest(callbackRequest, emailAddressNotifyValidationRules);
Expand All @@ -213,7 +216,6 @@ public ResponseEntity<CallbackResponse> generateGrant(
callbackResponse = callbackResponseTransformer.addDocuments(callbackRequest, documents, letterId, pdfSize,
caseworkerInfo);
}

return ResponseEntity.ok(callbackResponse);
}

Expand Down Expand Up @@ -307,11 +309,13 @@ public ResponseEntity<CallbackResponse> generateGrantReissue(
grantDocument, true);
}

String pdfSize = getPdfSize(caseData);

if (caseData.getOutsideUKGrantCopies() != null && caseData.getOutsideUKGrantCopies() > 0) {
documents.add(notificationService.sendSealedAndCertifiedEmail(caseDetails));
}
if (caseData.isGrantReissuedEmailNotificationRequested()) {
documents.add(notificationService.generateGrantReissue(callbackRequest));
}
String pdfSize = getPdfSize(caseData);
log.info("{} documents generated: {}", documents.size(), documents);
Optional<UserInfo> caseworkerInfo = userInfoService.getCaseworkerInfo();
return ResponseEntity.ok(callbackResponseTransformer.addDocuments(callbackRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,27 @@ public Document emailPreview(CaseDetails caseDetails) throws NotificationClientE
return getGeneratedDocument(previewResponse, getEmail(caseData), SENT_EMAIL);
}

public Document sendSealedAndCertifiedEmail(CaseDetails caseDetails) throws NotificationClientException {
CaseData caseData = caseDetails.getData();
String reference = caseDetails.getId().toString();
String deceasedName = caseData.getDeceasedFullName();

String templateId = notificationTemplates.getEmail().get(LanguagePreference.ENGLISH)
.get(caseData.getApplicationType()).getSealedAndCertified();
Map<String, Object> personalisation =
grantOfRepresentationPersonalisationService.getSealedAndCertifiedPersonalisation(caseDetails.getId(),
deceasedName);
doCommonNotificationServiceHandling(personalisation, caseDetails.getId());

log.info("Sealed And Certified Personlisation complete now get the email response");
MarcusHMCTS marked this conversation as resolved.
Show resolved Hide resolved

SendEmailResponse response = notificationClientService.sendEmail(templateId,
emailAddresses.getSealedAndCertifiedEmail(), personalisation, reference);

log.info("Send Sealed And Certified completed.");
return getGeneratedSentEmailDocument(response, emailAddresses.getSealedAndCertifiedEmail(), SENT_EMAIL);
}

public Document sendNocEmail(State state, CaseDetails caseDetails) throws NotificationClientException {
CaseData caseData = caseDetails.getData();
Registry registry = registriesProperties.getRegistries().get(caseData.getRegistryLocation().toLowerCase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ public Map<String, String> getExelaPersonalisation(List<ReturnedCaseDetails> cas
return personalisation;
}

public Map<String, Object> getSealedAndCertifiedPersonalisation(Long caseId, String deceasedName) {
HashMap<String, Object> personalisation = new HashMap<>();
personalisation.put(PERSONALISATION_CCD_REFERENCE, caseId.toString());
personalisation.put(PERSONALISATION_DECEASED_NAME, deceasedName);

return personalisation;
}

public Map<String, Object> getNocPersonalisation(Long caseId, String solicitorName, String deceasedName) {
HashMap<String, Object> personalisation = new HashMap<>();

Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ notifications:
caveatWithdrawn: "99b9ba1a-a2a1-4b85-ae83-e1652e9d342b"
grantDelayed: "7045b381-a087-44fe-8bb5-e5a591cb8473"
grantAwaitingDocumentation: "cc4aa69b-10fb-4a9c-9e0e-1851dfaa69e9"
sealedAndCertified: "16c9a4ce-162f-4ed1-8d70-be79616685ac"
solicitor:
applicationReceived: "27939b7f-3028-4c90-87bb-694adb0b6a51"
applicationReceivedNoDocs: "b374863f-3f65-4aed-a5ab-fb2648222f75"
Expand All @@ -288,6 +289,7 @@ notifications:
grantDelayed: "7045b381-a087-44fe-8bb5-e5a591cb8473"
grantAwaitingDocumentation: "638395bf-805f-48a7-97b1-d26ea9e9334e"
noticeOfChangeReceived: "6af59aa3-b379-406f-9be4-331b8411c6d9"
sealedAndCertified: "16c9a4ce-162f-4ed1-8d70-be79616685ac"
welsh:
personal:
applicationReceived: "7f39b671-86ce-49cb-b6b1-2019101aa8b1"
Expand All @@ -312,6 +314,7 @@ notifications:
caveatWithdrawn: "c63bc430-9868-4f10-924b-408c7ac3cbd8"
grantDelayed: "7045b381-a087-44fe-8bb5-e5a591cb8473"
grantAwaitingDocumentation: "cc4aa69b-10fb-4a9c-9e0e-1851dfaa69e9"
sealedAndCertified: "16c9a4ce-162f-4ed1-8d70-be79616685ac"
MarcusHMCTS marked this conversation as resolved.
Show resolved Hide resolved
solicitor:
applicationReceived: "2f282002-6799-47d0-92dd-726960b91c98"
applicationReceivedNoDocs: "60eab724-adec-4d5d-a0a1-aef73ed7da4d"
Expand All @@ -336,6 +339,7 @@ notifications:
grantDelayed: "7045b381-a087-44fe-8bb5-e5a591cb8473"
grantAwaitingDocumentation: "638395bf-805f-48a7-97b1-d26ea9e9334e"
noticeOfChangeReceived: "6af59aa3-b379-406f-9be4-331b8411c6d9"
sealedAndCertified: "16c9a4ce-162f-4ed1-8d70-be79616685ac"

documents:
templates:
Expand Down Expand Up @@ -513,6 +517,8 @@ smeeAndFordEmail: ${SMEE_AND_FORD_EMAIL:[email protected]}

hmrcEmail: ${HMRC_EMAIL:[email protected]}

sealedAndCertifiedEmail: ${SEALED_AND_CERTIFIED_EMAIL:[email protected]}

welsh:
months:
1: "Ionawr"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,31 @@ void shouldNotStartAwaitingDocumentationNotificationPeriodNullEvidenceHandled()
assertThat(stringResponseEntity.getStatusCode(), is(HttpStatus.OK));
}

@Test
void shouldSealedAndCertifiedEmail() throws NotificationClientException {
CaseDetails caseDetails = new CaseDetails(CaseData.builder()
.applicationType(SOLICITOR)
.deceasedForenames("Deceased")
.deceasedSurname("DeceasedL")
.build(), LAST_MODIFIED, ID);
callbackRequest = new CallbackRequest(caseDetails);
document = Document.builder()
.documentDateAdded(LocalDate.now())
.documentFileName("fileName")
.documentGeneratedBy("generatedBy")
.documentLink(
DocumentLink.builder().documentUrl("url").documentFilename("file")
.documentBinaryUrl("binary").build())
.documentType(DocumentType.SENT_EMAIL)
.build();
callbackResponse = CallbackResponse.builder().errors(Collections.EMPTY_LIST).build();
when(eventValidationService.validateNocEmail(any(), any())).thenReturn(callbackResponse);
when(notificationService.sendSealedAndCertifiedEmail(any())).thenReturn(document);
ResponseEntity<CallbackResponse> stringResponseEntity =
notificationController.sendNOCEmailNotification(callbackRequest);
assertThat(stringResponseEntity.getStatusCode(), is(HttpStatus.OK));
}

@Test
void shouldSendNocEmail() throws NotificationClientException {
setUpMocks(NOC);
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/payloadWithBulkPrint.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"document_binary_url": "http://localhost:8080/documents/e1f4f972-1514-4247-bdb1-964998ef3710/binary"
},
"extraCopiesOfGrant": null,
"outsideUKGrantCopies": 1,
"solsPaymentMethods": "fee account",
"solsSolicitorFirmPostcode": "KT10 0LA",
"deceasedForenames": "Deceased First Name",
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/payloadWithLocalPrint.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"document_binary_url": "http://localhost:8080/documents/e1f4f972-1514-4247-bdb1-964998ef3710/binary"
},
"extraCopiesOfGrant": null,
"outsideUKGrantCopies": 1,
"solsPaymentMethods": "fee account",
"solsSolicitorFirmPostcode": "KT10 0LA",
"deceasedForenames": "Deceased First Name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"document_binary_url": "http://localhost:8080/documents/e1f4f972-1514-4247-bdb1-964998ef3710/binary"
},
"extraCopiesOfGrant": null,
"outsideUKGrantCopies": 1,
"solsPaymentMethods": "fee account",
"deceasedForenames": "Deceased First Name",
"primaryApplicantIsApplying": "Yes",
Expand Down
Loading