Search in sources :

Example 1 with ResponseCaseData

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));
}
Also used : ResponseCaseData(uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData) CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) AfterSubmitCallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.AfterSubmitCallbackResponse) CCDData(uk.gov.hmcts.probate.model.ccd.CCDData) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) Test(org.junit.Test)

Example 2 with ResponseCaseData

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));
}
Also used : ResponseCaseData(uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData) CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) AfterSubmitCallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.AfterSubmitCallbackResponse) CCDData(uk.gov.hmcts.probate.model.ccd.CCDData) Test(org.junit.Test)

Example 3 with ResponseCaseData

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());
}
Also used : CallbackRequest(uk.gov.hmcts.probate.model.ccd.raw.request.CallbackRequest) ResponseCaseData(uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData) CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) CollectionMember(uk.gov.hmcts.probate.model.ccd.raw.CollectionMember) ArrayList(java.util.ArrayList) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) Test(org.junit.Test)

Example 4 with ResponseCaseData

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

Example 5 with ResponseCaseData

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()));
}
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) 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) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) UUID(java.util.UUID) DocumentLink(uk.gov.hmcts.probate.model.ccd.raw.DocumentLink) SendLetterResponse(uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)

Aggregations

ResponseCaseData (uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData)43 Test (org.junit.Test)32 CallbackResponse (uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse)18 CaseDetails (uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails)11 Document (uk.gov.hmcts.probate.model.ccd.raw.Document)10 CaseData (uk.gov.hmcts.probate.model.ccd.raw.request.CaseData)10 CallbackRequest (uk.gov.hmcts.probate.model.ccd.raw.request.CallbackRequest)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 CollectionMember (uk.gov.hmcts.probate.model.ccd.raw.CollectionMember)7 ArrayList (java.util.ArrayList)6 CCDData (uk.gov.hmcts.probate.model.ccd.CCDData)6 AfterSubmitCallbackResponse (uk.gov.hmcts.probate.model.ccd.raw.response.AfterSubmitCallbackResponse)6 ResponseCaseDataBuilder (uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData.ResponseCaseDataBuilder)6 CaveatCallbackRequest (uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatCallbackRequest)5 DocumentLink (uk.gov.hmcts.probate.model.ccd.raw.DocumentLink)5 SolsAddress (uk.gov.hmcts.probate.model.ccd.raw.SolsAddress)5 LetterV3 (uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3)5 UUID (java.util.UUID)4 SendLetterResponse (uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)4 Before (org.junit.Before)3