Search in sources :

Example 16 with LetterV3

use of uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3 in project probate-back-office by hmcts.

the class BulkPrintServiceTest method sendToBulkPrintWith50ExtraCopiesAWDG.

@Test
public void sendToBulkPrintWith50ExtraCopiesAWDG() {
    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).extraCopiesOfGrant(50L).build();
    CallbackRequest callbackRequest = new CallbackRequest(new CaseDetails(caseData, null, 0L));
    DocumentLink documentLink = DocumentLink.builder().documentUrl("http://localhost").build();
    Document document = Document.builder().documentFileName("test.pdf").documentGeneratedBy("test").documentType(DocumentType.WELSH_ADMON_WILL_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);
    when(sendLetterApiMock.sendLetter(anyString(), any(LetterV3.class))).thenReturn(sendLetterResponse);
    when(documentTransformer.hasDocumentWithType(Collections.singletonList(document), DocumentType.WELSH_ADMON_WILL_GRANT)).thenReturn(true);
    SendLetterResponse response = bulkPrintService.sendToBulkPrintForGrant(callbackRequest, document, coverSheet);
    verify(sendLetterApiMock).sendLetter(anyString(), any(LetterV3.class));
    assertNotNull(response);
    assertThat(response.letterId, is(uuid));
}
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) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) 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) Test(org.junit.Test)

Example 17 with LetterV3

use of uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3 in project probate-back-office by hmcts.

the class BulkPrintServiceTest method sendToBulkPrintWith50ExtraCopiesWDG.

@Test
public void sendToBulkPrintWith50ExtraCopiesWDG() {
    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).extraCopiesOfGrant(50L).build();
    CallbackRequest callbackRequest = new CallbackRequest(new CaseDetails(caseData, null, 0L));
    DocumentLink documentLink = DocumentLink.builder().documentUrl("http://localhost").build();
    Document document = Document.builder().documentFileName("test.pdf").documentGeneratedBy("test").documentType(DocumentType.WELSH_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);
    when(sendLetterApiMock.sendLetter(anyString(), any(LetterV3.class))).thenReturn(sendLetterResponse);
    when(documentTransformer.hasDocumentWithType(Collections.singletonList(document), DocumentType.WELSH_DIGITAL_GRANT)).thenReturn(true);
    SendLetterResponse response = bulkPrintService.sendToBulkPrintForGrant(callbackRequest, document, coverSheet);
    verify(sendLetterApiMock).sendLetter(anyString(), any(LetterV3.class));
    assertNotNull(response);
    assertThat(response.letterId, is(uuid));
}
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) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) 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) Test(org.junit.Test)

Example 18 with LetterV3

use of uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3 in project probate-back-office by hmcts.

the class BulkPrintServiceTest method testHttpClientExceptionCaveats.

@Test
public void testHttpClientExceptionCaveats() {
    ProbateAddress address = ProbateAddress.builder().proAddressLine1("Address 1").proAddressLine2("Address 2").proPostCode("EC2").proCountry("UK").build();
    CaveatData caseData = CaveatData.builder().caveatorEmailAddress("caveator@probate-test.com").caveatorForenames("firstname").caveatorSurname("surname").caveatorAddress(address).build();
    CaveatCallbackRequest callbackRequest = new CaveatCallbackRequest(new CaveatDetails(caseData, null, 0L));
    DocumentLink documentLink = DocumentLink.builder().documentUrl("http://localhost").build();
    Document document = Document.builder().documentFileName("test.pdf").documentGeneratedBy("test").documentType(DocumentType.CAVEAT_RAISED).documentDateAdded(LocalDate.now()).documentLink(documentLink).build();
    Document coverSheet = Document.builder().documentFileName("test.pdf").documentGeneratedBy("test").documentDateAdded(LocalDate.now()).documentLink(documentLink).build();
    doThrow(new HttpClientErrorException(HttpStatus.BAD_REQUEST, "StatusText", "Body".getBytes(), Charset.defaultCharset())).when(sendLetterApiMock).sendLetter(anyString(), any(LetterV3.class));
    SendLetterResponse response = bulkPrintService.sendToBulkPrintForCaveat(callbackRequest, document, coverSheet);
    assertNull(response);
}
Also used : LetterV3(uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) CaveatDetails(uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatDetails) CaveatData(uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatData) CaveatCallbackRequest(uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatCallbackRequest) 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) ProbateAddress(uk.gov.hmcts.probate.model.ccd.ProbateAddress) Test(org.junit.Test)

Example 19 with LetterV3

use of uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3 in project probate-back-office by hmcts.

the class BulkPrintServiceTest method testHttpClientException.

@Test
public void testHttpClientException() {
    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).extraCopiesOfGrant(6L).build();
    CallbackRequest callbackRequest = new CallbackRequest(new CaseDetails(caseData, null, 0L));
    DocumentLink documentLink = DocumentLink.builder().documentUrl("http://localhost").build();
    Document document = 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();
    doThrow(new HttpClientErrorException(HttpStatus.BAD_REQUEST, "StatusText", "Body".getBytes(), Charset.defaultCharset())).when(sendLetterApiMock).sendLetter(anyString(), any(LetterV3.class));
    SendLetterResponse response = bulkPrintService.sendToBulkPrintForGrant(callbackRequest, document, coverSheet);
    assertNull(response);
}
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) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) SolsAddress(uk.gov.hmcts.probate.model.ccd.raw.SolsAddress) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) 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) Test(org.junit.Test)

Example 20 with LetterV3

use of uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3 in project probate-back-office by hmcts.

the class BulkPrintServiceTest method testSuccessfulSendToBulkPrintWithNoExtraCopies.

@Test
public void testSuccessfulSendToBulkPrintWithNoExtraCopies() {
    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).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);
    when(sendLetterApiMock.sendLetter(anyString(), any(LetterV3.class))).thenReturn(sendLetterResponse);
    SendLetterResponse response = bulkPrintService.sendToBulkPrintForGrant(callbackRequest, grant, coverSheet);
    verify(sendLetterApiMock).sendLetter(anyString(), any(LetterV3.class));
    assertNotNull(response);
    assertThat(response.letterId, is(uuid));
}
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) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) 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) Test(org.junit.Test)

Aggregations

LetterV3 (uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3)24 SendLetterResponse (uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)21 Document (uk.gov.hmcts.probate.model.ccd.raw.Document)17 UUID (java.util.UUID)15 CaveatCallbackRequest (uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatCallbackRequest)15 DocumentLink (uk.gov.hmcts.probate.model.ccd.raw.DocumentLink)15 Test (org.junit.Test)14 SolsAddress (uk.gov.hmcts.probate.model.ccd.raw.SolsAddress)12 CallbackRequest (uk.gov.hmcts.probate.model.ccd.raw.request.CallbackRequest)12 CaseData (uk.gov.hmcts.probate.model.ccd.raw.request.CaseData)12 CaseDetails (uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails)12 ResponseCaseData (uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData)12 ByteArrayInputStream (java.io.ByteArrayInputStream)5 Test (org.junit.jupiter.api.Test)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 ConfidentialDivorceDocument (uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument)5 Letter (uk.gov.hmcts.divorce.document.print.model.Letter)5 Print (uk.gov.hmcts.divorce.document.print.model.Print)5 CallbackResponse (uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse)5 User (uk.gov.hmcts.reform.idam.client.models.User)5