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;
}
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;
}
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");
}
Aggregations