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