use of uk.gov.hmcts.reform.sendletter.api.SendLetterResponse in project sscs-evidence-share by hmcts.
the class BulkPrintServiceTest method willSendToBulkPrint.
@Test
public void willSendToBulkPrint() {
when(sendLetterApi.sendLetter(eq(AUTH_TOKEN), captor.capture())).thenReturn(new SendLetterResponse(LETTER_ID));
Optional<UUID> letterIdOptional = bulkPrintService.sendToBulkPrint(PDF_LIST, SSCS_CASE_DATA);
assertEquals("letterIds must be equal", Optional.of(LETTER_ID), letterIdOptional);
assertEquals("sscs-data-pack", captor.getValue().getAdditionalData().get("letterType"));
assertEquals("Appellant LastName", captor.getValue().getAdditionalData().get("appellantName"));
assertEquals("234", captor.getValue().getAdditionalData().get("caseIdentifier"));
}
use of uk.gov.hmcts.reform.sendletter.api.SendLetterResponse in project sscs-evidence-share by hmcts.
the class BulkPrintServiceTest method willSendToBulkPrintWithAdditionalData.
@Test
public void willSendToBulkPrintWithAdditionalData() {
when(sendLetterApi.sendLetter(eq(AUTH_TOKEN), any(LetterWithPdfsRequest.class))).thenReturn(new SendLetterResponse(LETTER_ID));
Optional<UUID> letterIdOptional = bulkPrintService.sendToBulkPrint(PDF_LIST, SSCS_CASE_DATA);
assertEquals("letterIds must be equal", Optional.of(LETTER_ID), letterIdOptional);
}
use of uk.gov.hmcts.reform.sendletter.api.SendLetterResponse in project nfdiv-case-api by hmcts.
the class CaseworkerReIssueApplicationIT method stubAosPackSendLetter.
private void stubAosPackSendLetter() throws IOException {
final var documentListValue1 = documentWithType(APPLICATION, MINI_APPLICATION_ID);
final var documentListValue2 = documentWithType(RESPONDENT_INVITATION, AOS_COVER_LETTER_ID);
final var documentListValue3 = documentWithType(NOTICE_OF_PROCEEDINGS, NOTICE_OF_PROCEEDING_ID);
final List<String> documentIds = asList(FilenameUtils.getName(documentListValue1.getValue().getDocumentLink().getUrl()), FilenameUtils.getName(documentListValue2.getValue().getDocumentLink().getUrl()), FilenameUtils.getName(documentListValue3.getValue().getDocumentLink().getUrl()));
final byte[] pdfAsBytes = loadPdfAsBytes();
for (String documentId : documentIds) {
stubDownloadBinaryFromDocumentManagement(documentId, pdfAsBytes);
}
final SendLetterResponse sendLetterResponse = new SendLetterResponse(UUID.randomUUID());
final ZonedDateTime now = ZonedDateTime.now();
final LetterStatus letterStatus = new LetterStatus(sendLetterResponse.letterId, "OK", "", now, now, now, null, 1);
stubSendLetters(objectMapper.writeValueAsString(sendLetterResponse));
stubStatusOfSendLetter(sendLetterResponse.letterId, objectMapper.writeValueAsString(letterStatus));
when(serviceTokenGenerator.generate()).thenReturn(TEST_SERVICE_AUTH_TOKEN);
}
use of uk.gov.hmcts.reform.sendletter.api.SendLetterResponse in project nfdiv-case-api by hmcts.
the class CaseworkerIssueApplicationIT method stubAosPackSendLetter.
private void stubAosPackSendLetter() throws IOException {
final var documentListValue1 = documentWithType(APPLICATION, DIVORCE_APPLICATION_ID);
final var documentListValue2 = documentWithType(RESPONDENT_INVITATION, AOS_COVER_LETTER_ID);
final var documentListValue3 = documentWithType(NOTICE_OF_PROCEEDINGS, NOTICE_OF_PROCEEDING_ID);
final List<String> documentIds = asList(FilenameUtils.getName(documentListValue1.getValue().getDocumentLink().getUrl()), FilenameUtils.getName(documentListValue2.getValue().getDocumentLink().getUrl()), FilenameUtils.getName(documentListValue3.getValue().getDocumentLink().getUrl()));
final byte[] pdfAsBytes = loadPdfAsBytes();
for (String documentId : documentIds) {
stubDownloadBinaryFromDocumentManagement(documentId, pdfAsBytes);
}
final SendLetterResponse sendLetterResponse = new SendLetterResponse(UUID.randomUUID());
final ZonedDateTime now = ZonedDateTime.now();
final LetterStatus letterStatus = new LetterStatus(sendLetterResponse.letterId, "OK", "", now, now, now, null, 1);
stubSendLetters(objectMapper.writeValueAsString(sendLetterResponse));
stubStatusOfSendLetter(sendLetterResponse.letterId, objectMapper.writeValueAsString(letterStatus));
when(serviceTokenGenerator.generate()).thenReturn(TEST_SERVICE_AUTH_TOKEN);
}
use of uk.gov.hmcts.reform.sendletter.api.SendLetterResponse in project probate-back-office by hmcts.
the class NotificationController method sendCaseStoppedNotification.
@PostMapping(path = "/case-stopped")
public ResponseEntity<CallbackResponse> sendCaseStoppedNotification(@Validated({ EmailAddressNotifyValidationRule.class }) @RequestBody CallbackRequest callbackRequest) throws NotificationClientException {
CaseDetails caseDetails = callbackRequest.getCaseDetails();
CaseData caseData = caseDetails.getData();
CallbackResponse response = CallbackResponse.builder().errors(new ArrayList<>()).build();
Document document;
List<Document> documents = new ArrayList<>();
String letterId = null;
if (caseData.isCaveatStopNotificationRequested() && caseData.isCaveatStopEmailNotificationRequested()) {
response = eventValidationService.validateEmailRequest(callbackRequest, emailAddressNotifyValidationRules);
if (response.getErrors().isEmpty()) {
log.info("Initiate call to send caveat email for case id {} ", callbackRequest.getCaseDetails().getId());
document = notificationService.sendEmail(CASE_STOPPED_CAVEAT, caseDetails);
documents.add(document);
log.info("Successful response for caveat email for case id {} ", callbackRequest.getCaseDetails().getId());
}
} else if (caseData.isCaveatStopNotificationRequested() && !caseData.isCaveatStopEmailNotificationRequested()) {
Document coversheet = documentGeneratorService.generateCoversheet(callbackRequest);
documents.add(coversheet);
log.info("Initiate call to generate Caveat stopped document for case id {} ", callbackRequest.getCaseDetails().getId());
Map<String, Object> placeholders = gorDocmosisService.caseDataForStoppedMatchedCaveat(callbackRequest.getCaseDetails());
Document caveatRaisedDoc = pdfManagementService.generateDocmosisDocumentAndUpload(placeholders, DocumentType.CAVEAT_STOPPED);
documents.add(caveatRaisedDoc);
log.info("Successful response for caveat stopped document for case id {} ", callbackRequest.getCaseDetails().getId());
if (caseData.isCaveatStopSendToBulkPrintRequested()) {
log.info("Initiate call to bulk print for Caveat stopped document and coversheet for case id {} ", callbackRequest.getCaseDetails().getId());
SendLetterResponse sendLetterResponse = bulkPrintService.sendToBulkPrintForGrant(callbackRequest, caveatRaisedDoc, coversheet);
letterId = sendLetterResponse != null ? sendLetterResponse.letterId.toString() : null;
response = eventValidationService.validateBulkPrintResponse(letterId, bulkPrintValidationRules);
}
} else {
response = eventValidationService.validateEmailRequest(callbackRequest, emailAddressNotifyValidationRules);
if (response.getErrors().isEmpty()) {
log.info("Initiate call to notify applicant for case id {} ", callbackRequest.getCaseDetails().getId());
document = notificationService.sendEmail(CASE_STOPPED, caseDetails);
documents.add(document);
log.info("Successful response from notify for case id {} ", callbackRequest.getCaseDetails().getId());
}
}
if (response.getErrors().isEmpty()) {
response = callbackResponseTransformer.caseStopped(callbackRequest, documents, letterId);
}
return ResponseEntity.ok(response);
}
Aggregations