use of uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData in project probate-back-office by hmcts.
the class BusinessValidationUnitTest method shouldSubmitForPersonalWithEmail.
@Test
public void shouldSubmitForPersonalWithEmail() throws NotificationClientException {
String paperFormValue = "Any";
ResponseCaseData responseCaseData = ResponseCaseData.builder().paperForm(paperFormValue).build();
when(callbackRequestMock.getCaseDetails()).thenReturn(caseDetailsMock);
when(caseDetailsMock.getData()).thenReturn(caseDataMock);
when(caseDataMock.getApplicationType()).thenReturn(ApplicationType.PERSONAL);
when(eventValidationServiceMock.validateRequest(callbackRequestMock, caseworkerAmendAndCreateValidationRules)).thenReturn(callbackResponseMock);
when(callbackResponseMock.getData()).thenReturn(responseCaseData);
Document documentMock = Mockito.mock(Document.class);
when(notificationService.sendEmail(APPLICATION_RECEIVED, caseDetailsMock, Optional.of(CaseOrigin.CASEWORKER))).thenReturn(documentMock);
when(callbackResponseTransformerMock.paperForm(callbackRequestMock, documentMock)).thenReturn(callbackResponseMock);
when(emailAddressNotifyApplicantValidationRule.validate(any(CCDData.class))).thenReturn(Collections.EMPTY_LIST);
ResponseEntity<CallbackResponse> response = underTest.paperFormCaseDetails(callbackRequestMock, bindingResultMock);
assertThat(response.getStatusCode(), is(HttpStatus.OK));
assertThat(response.getBody().getData().getPaperForm(), is(paperFormValue));
}
use of uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData in project probate-back-office by hmcts.
the class BusinessValidationUnitTest method shouldSubmitForSolicitorWithoutEmail.
@Test
public void shouldSubmitForSolicitorWithoutEmail() throws NotificationClientException {
String paperFormValue = "YesNo";
ResponseCaseData responseCaseData = ResponseCaseData.builder().paperForm(paperFormValue).build();
when(callbackRequestMock.getCaseDetails()).thenReturn(caseDetailsMock);
when(caseDetailsMock.getData()).thenReturn(caseDataMock);
when(caseDataMock.getApplicationType()).thenReturn(ApplicationType.SOLICITOR);
when(eventValidationServiceMock.validateRequest(callbackRequestMock, caseworkerAmendAndCreateValidationRules)).thenReturn(callbackResponseMock);
when(callbackResponseMock.getData()).thenReturn(responseCaseData);
when(callbackResponseTransformerMock.paperForm(callbackRequestMock, null)).thenReturn(callbackResponseMock);
when(emailAddressNotifyApplicantValidationRule.validate(any(CCDData.class))).thenReturn(Arrays.asList(FieldErrorResponse.builder().build()));
ResponseEntity<CallbackResponse> response = underTest.paperFormCaseDetails(callbackRequestMock, bindingResultMock);
verify(notificationService, times(0)).sendEmail(APPLICATION_RECEIVED, caseDetailsMock, Optional.of(CaseOrigin.CASEWORKER));
assertThat(response.getStatusCode(), is(HttpStatus.OK));
assertThat(response.getBody().getData().getPaperForm(), is(paperFormValue));
}
use of uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData in project probate-back-office by hmcts.
the class InformationRequestServiceTest method testEmailRequestReturnsSentEmailDocumentSuccessfully.
@Test
public void testEmailRequestReturnsSentEmailDocumentSuccessfully() {
CollectionMember<Document> documentCollectionMember = new CollectionMember<>(Document.builder().documentType(DocumentType.SENT_EMAIL).build());
documentList = new ArrayList<>();
documentList.add(documentCollectionMember);
ResponseCaseData emailResponseCaseData = ResponseCaseData.builder().probateNotificationsGenerated(documentList).build();
CallbackResponse callbackResponse = CallbackResponse.builder().data(emailResponseCaseData).build();
when(callbackResponseTransformer.addInformationRequestDocuments(any(), eq(Arrays.asList(SENT_EMAIL_DOCUMENT)), eq(new ArrayList<>()))).thenReturn(callbackResponse);
caseData = CaseData.builder().executorsApplyingNotifications(executorsApplying).boRequestInfoSendToBulkPrintRequested("No").paperForm("No").primaryApplicantEmailAddress("primary@probate-test.com").build();
caseDetails = new CaseDetails(caseData, LAST_MODIFIED, ID);
callbackRequest = new CallbackRequest(caseDetails);
when(informationRequestCorrespondenceService.emailInformationRequest(caseDetails)).thenReturn(Arrays.asList(SENT_EMAIL_DOCUMENT));
when(callbackResponseTransformer.addInformationRequestDocuments(any(), eq(Arrays.asList(SENT_EMAIL_DOCUMENT)), eq(new ArrayList<>()))).thenReturn(callbackResponse);
assertEquals(SENT_EMAIL_DOCUMENT, informationRequestService.handleInformationRequest(callbackRequest).getData().getProbateNotificationsGenerated().get(0).getValue());
}
use of uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData in project probate-back-office by hmcts.
the class BulkPrintServiceTest method shouldSendToBulkPrintForReprint.
@Test
public void shouldSendToBulkPrintForReprint() {
SolsAddress address = SolsAddress.builder().addressLine1("Address 1").addressLine2("Address 2").postCode("EC2").country("UK").build();
CaseData caseData = CaseData.builder().primaryApplicantForenames("first").primaryApplicantSurname("last").primaryApplicantAddress(address).reprintNumberOfCopies("10").build();
CallbackRequest callbackRequest = new CallbackRequest(new CaseDetails(caseData, null, 0L));
DocumentLink documentLink = DocumentLink.builder().documentUrl("http://localhost").build();
Document grant = Document.builder().documentFileName("test.pdf").documentGeneratedBy("test").documentType(DocumentType.DIGITAL_GRANT).documentDateAdded(LocalDate.now()).documentLink(documentLink).build();
Document coverSheet = Document.builder().documentFileName("test.pdf").documentGeneratedBy("test").documentDateAdded(LocalDate.now()).documentLink(documentLink).build();
UUID uuid = UUID.randomUUID();
SendLetterResponse sendLetterResponse = new SendLetterResponse(uuid);
List<String> errors = new ArrayList<>();
CallbackResponse callbackResponse = CallbackResponse.builder().data(responseCaseData).errors(errors).build();
when(sendLetterApiMock.sendLetter(anyString(), letterV3ArgumentCaptor.capture())).thenReturn(sendLetterResponse);
when(eventValidationService.validateBulkPrintResponse(eq(uuid.toString()), any())).thenReturn(callbackResponse);
SendLetterResponse response = bulkPrintService.sendDocumentsForReprint(callbackRequest, grant, coverSheet);
assertEquals(sendLetterResponse, response);
assertEquals(1, letterV3ArgumentCaptor.getValue().documents.get(0).copies);
assertEquals(10, letterV3ArgumentCaptor.getValue().documents.get(1).copies);
verify(sendLetterApiMock).sendLetter(anyString(), any(LetterV3.class));
}
use of uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData in project probate-back-office by hmcts.
the class BulkPrintServiceTest method testSuccessfulSendToBulkPrintForDocumentType.
private void testSuccessfulSendToBulkPrintForDocumentType(DocumentType documentType) {
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).extraCopiesOfGrant(1L).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").documentType(documentType).documentDateAdded(LocalDate.now()).documentLink(documentLink).build();
final Document coverSheet = Document.builder().documentFileName("test.pdf").documentGeneratedBy("test").documentDateAdded(LocalDate.now()).documentLink(documentLink).build();
responseCaseData = ResponseCaseData.builder().registryLocation("leeds").deceasedForenames("name").deceasedSurname("name").build();
final CallbackResponse callbackResponse = CallbackResponse.builder().errors(new ArrayList<>()).data(responseCaseData).build();
UUID uuid = UUID.randomUUID();
SendLetterResponse sendLetterResponse = new SendLetterResponse(uuid);
when(sendLetterApiMock.sendLetter(anyString(), any(LetterV3.class))).thenReturn(sendLetterResponse);
when(eventValidationService.validateBulkPrintResponse(eq(uuid.toString()), any())).thenReturn(callbackResponse);
when(documentTransformer.hasDocumentWithType(Collections.singletonList(document), documentType)).thenReturn(true);
final String letterId = bulkPrintService.optionallySendToBulkPrint(callbackRequest, coverSheet, document, true);
verify(sendLetterApiMock).sendLetter(anyString(), letterV3ArgumentCaptor.capture());
assertEquals(1, letterV3ArgumentCaptor.getValue().documents.get(0).copies);
assertEquals(2, letterV3ArgumentCaptor.getValue().documents.get(1).copies);
assertNotNull(letterId);
assertThat(letterId, is(uuid.toString()));
}
Aggregations