Search in sources :

Example 1 with BulkPrintException

use of uk.gov.hmcts.probate.exception.BulkPrintException in project probate-back-office by hmcts.

the class BulkPrintService method sendDocumentsForReprint.

public SendLetterResponse sendDocumentsForReprint(CallbackRequest callbackRequest, Document selectedDocument, Document coverSheet) {
    SendLetterResponse sendLetterResponse = sendToBulkPrint(callbackRequest, selectedDocument, coverSheet, true);
    String letterId = sendLetterResponse != null ? sendLetterResponse.letterId.toString() : null;
    CallbackResponse response = eventValidationService.validateBulkPrintResponse(letterId, bulkPrintValidationRules);
    if (!response.getErrors().isEmpty()) {
        throw new BulkPrintException(businessValidationMessageService.generateError(BUSINESS_ERROR, "bulkPrintResponseNull").getMessage(), "Bulk print send letter for reprint response is null for: " + callbackRequest.getCaseDetails().getId());
    }
    return sendLetterResponse;
}
Also used : BulkPrintException(uk.gov.hmcts.probate.exception.BulkPrintException) CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) SendLetterResponse(uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)

Example 2 with BulkPrintException

use of uk.gov.hmcts.probate.exception.BulkPrintException in project probate-back-office by hmcts.

the class BulkPrintService method optionallySendToBulkPrint.

public String optionallySendToBulkPrint(CallbackRequest callbackRequest, Document coversheet, Document document, boolean sendToBulkPrint) {
    CallbackResponse response;
    SendLetterResponse sendLetterResponse;
    String letterId = null;
    if (sendToBulkPrint) {
        log.info("Initiate call to bulk print for document with case id {} and coversheet", callbackRequest.getCaseDetails().getId());
        sendLetterResponse = sendToBulkPrintForGrant(callbackRequest, document, coversheet);
        letterId = sendLetterResponse != null ? sendLetterResponse.letterId.toString() : null;
        response = eventValidationService.validateBulkPrintResponse(letterId, bulkPrintValidationRules);
        if (!response.getErrors().isEmpty()) {
            throw new BulkPrintException(businessValidationMessageService.generateError(BUSINESS_ERROR, "bulkPrintResponseNull").getMessage(), "Bulk print send letter response is null for: " + callbackRequest.getCaseDetails().getId());
        }
    }
    return letterId;
}
Also used : BulkPrintException(uk.gov.hmcts.probate.exception.BulkPrintException) CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) SendLetterResponse(uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)

Example 3 with BulkPrintException

use of uk.gov.hmcts.probate.exception.BulkPrintException in project probate-back-office by hmcts.

the class BulkPrintServiceTest method testUnSuccessfulValidateEmailThrowsError.

@Test
public void testUnSuccessfulValidateEmailThrowsError() throws BulkPrintException {
    SolsAddress address = SolsAddress.builder().addressLine1("Address 1").addressLine2("Address 2").postCode("EC2").country("UK").build();
    CaseData caseData = CaseData.builder().primaryApplicantEmailAddress("primary@probate-test.com").primaryApplicantForenames("firstname").primaryApplicantSurname("surname").primaryApplicantAddress(address).build();
    final CallbackRequest callbackRequest = new CallbackRequest(new CaseDetails(caseData, null, 0L));
    DocumentLink documentLink = DocumentLink.builder().documentUrl("http://localhost").build();
    final Document document = Document.builder().documentFileName("test.pdf").documentGeneratedBy("test").documentDateAdded(LocalDate.now()).documentLink(documentLink).build();
    final Document coverSheet = Document.builder().documentFileName("test.pdf").documentGeneratedBy("test").documentDateAdded(LocalDate.now()).documentLink(documentLink).build();
    List<String> errors = new ArrayList<>();
    errors.add("test error");
    CallbackResponse callbackResponse = CallbackResponse.builder().data(responseCaseData).errors(errors).build();
    when(sendLetterApiMock.sendLetter(anyString(), any(LetterV3.class))).thenReturn(null);
    when(eventValidationService.validateBulkPrintResponse(any(), any())).thenReturn(callbackResponse);
    when(businessValidationMessageService.generateError(any(), any())).thenReturn(FieldErrorResponse.builder().build());
    assertThatThrownBy(() -> bulkPrintService.optionallySendToBulkPrint(callbackRequest, coverSheet, document, true)).isInstanceOf(BulkPrintException.class).hasMessage("Bulk print send letter response is null for: 0");
}
Also used : LetterV3(uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3) CallbackRequest(uk.gov.hmcts.probate.model.ccd.raw.request.CallbackRequest) CaveatCallbackRequest(uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatCallbackRequest) ResponseCaseData(uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData) CaseData(uk.gov.hmcts.probate.model.ccd.raw.request.CaseData) BulkPrintException(uk.gov.hmcts.probate.exception.BulkPrintException) SolsAddress(uk.gov.hmcts.probate.model.ccd.raw.SolsAddress) CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) DocumentLink(uk.gov.hmcts.probate.model.ccd.raw.DocumentLink) Test(org.junit.Test)

Aggregations

BulkPrintException (uk.gov.hmcts.probate.exception.BulkPrintException)3 CallbackResponse (uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse)3 SendLetterResponse (uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 CaveatCallbackRequest (uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatCallbackRequest)1 Document (uk.gov.hmcts.probate.model.ccd.raw.Document)1 DocumentLink (uk.gov.hmcts.probate.model.ccd.raw.DocumentLink)1 SolsAddress (uk.gov.hmcts.probate.model.ccd.raw.SolsAddress)1 CallbackRequest (uk.gov.hmcts.probate.model.ccd.raw.request.CallbackRequest)1 CaseData (uk.gov.hmcts.probate.model.ccd.raw.request.CaseData)1 CaseDetails (uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails)1 ResponseCaseData (uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData)1 LetterV3 (uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3)1