Search in sources :

Example 1 with SendLetterResponse

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"));
}
Also used : UUID(java.util.UUID) SendLetterResponse(uk.gov.hmcts.reform.sendletter.api.SendLetterResponse) Test(org.junit.Test)

Example 2 with SendLetterResponse

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);
}
Also used : LetterWithPdfsRequest(uk.gov.hmcts.reform.sendletter.api.LetterWithPdfsRequest) UUID(java.util.UUID) SendLetterResponse(uk.gov.hmcts.reform.sendletter.api.SendLetterResponse) Test(org.junit.Test)

Example 3 with SendLetterResponse

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);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) LetterStatus(uk.gov.hmcts.reform.sendletter.api.LetterStatus) SendLetterResponse(uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)

Example 4 with SendLetterResponse

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);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) LetterStatus(uk.gov.hmcts.reform.sendletter.api.LetterStatus) SendLetterResponse(uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)

Example 5 with SendLetterResponse

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);
}
Also used : CaseData(uk.gov.hmcts.probate.model.ccd.raw.request.CaseData) CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) ArrayList(java.util.ArrayList) ProbateDocument(uk.gov.hmcts.reform.probate.model.ProbateDocument) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) Map(java.util.Map) SendLetterResponse(uk.gov.hmcts.reform.sendletter.api.SendLetterResponse) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

SendLetterResponse (uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)61 Document (uk.gov.hmcts.probate.model.ccd.raw.Document)30 Test (org.junit.Test)25 LetterV3 (uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3)21 UUID (java.util.UUID)18 CaveatCallbackRequest (uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatCallbackRequest)18 CallbackRequest (uk.gov.hmcts.probate.model.ccd.raw.request.CallbackRequest)18 DocumentLink (uk.gov.hmcts.probate.model.ccd.raw.DocumentLink)14 CaseDetails (uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails)14 ArrayList (java.util.ArrayList)13 CaseData (uk.gov.hmcts.probate.model.ccd.raw.request.CaseData)13 LetterWithPdfsRequest (uk.gov.hmcts.reform.sendletter.api.LetterWithPdfsRequest)12 SolsAddress (uk.gov.hmcts.probate.model.ccd.raw.SolsAddress)11 ResponseCaseData (uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData)11 Test (org.junit.jupiter.api.Test)8 CaveatDetails (uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatDetails)8 ZonedDateTime (java.time.ZonedDateTime)7 CallbackResponse (uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse)7 LetterStatus (uk.gov.hmcts.reform.sendletter.api.LetterStatus)7 ScannedDocument (uk.gov.hmcts.probate.model.ccd.raw.ScannedDocument)6