use of uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument in project nfdiv-case-api by hmcts.
the class CaseworkerUploadConfidentialDocumentTest method shouldSortDocumentsInDescendingOrderAndAddNewDocumentsToTopOfList.
@Test
void shouldSortDocumentsInDescendingOrderAndAddNewDocumentsToTopOfList() {
final CaseDetails<CaseData, State> previousCaseDetails = new CaseDetails<>();
final ListValue<ConfidentialDivorceDocument> doc1 = getDocumentListValue("http://localhost:4200/assets/59a54ccc-979f-11eb-a8b3-0242ac130003", "annex_a.pdf", ANNEX_A);
final ListValue<ConfidentialDivorceDocument> doc2 = getDocumentListValue("http://localhost:4200/assets/59a54ccc-979f-11eb-a8b3-0242ac130004", "bailiff.pdf", ConfidentialDocumentsReceived.BAILIFF_SERVICE);
final CaseData previousCaseData = caseData();
previousCaseData.getDocuments().setConfidentialDocumentsUploaded(List.of(doc1, doc2));
previousCaseDetails.setData(previousCaseData);
final ListValue<ConfidentialDivorceDocument> doc3 = getDocumentListValue("http://localhost:4200/assets/59a54ccc-979f-11eb-a8b3-0242ac130005", "aos.pdf", AOS);
final CaseData caseData = caseData();
final CaseDetails<CaseData, State> updatedCaseDetails = new CaseDetails<>();
caseData.getDocuments().setConfidentialDocumentsUploaded(List.of(doc1, doc2, doc3));
updatedCaseDetails.setData(caseData);
AboutToStartOrSubmitResponse<CaseData, State> response = caseworkerUploadConfidentialDocument.aboutToSubmit(updatedCaseDetails, previousCaseDetails);
List<ListValue<ConfidentialDivorceDocument>> actualDocuments = response.getData().getDocuments().getConfidentialDocumentsUploaded();
assertThat(actualDocuments.size()).isEqualTo(3);
assertThat(actualDocuments.get(0).getValue()).isSameAs(doc3.getValue());
assertThat(actualDocuments.get(1).getValue()).isSameAs(doc1.getValue());
assertThat(actualDocuments.get(2).getValue()).isSameAs(doc2.getValue());
}
use of uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument in project nfdiv-case-api by hmcts.
the class BulkPrintServiceTest method shouldReturnLetterIdForValidRequestForConfidentialDocuments.
@Test
void shouldReturnLetterIdForValidRequestForConfidentialDocuments() throws IOException {
List<String> solicitorRoles = List.of("caseworker-divorce", "caseworker-divorce-solicitor");
String solicitorRolesCsv = String.join(",", solicitorRoles);
String userId = UUID.randomUUID().toString();
User solicitorUser = solicitorUser(solicitorRoles, userId);
given(httpServletRequest.getHeader(AUTHORIZATION)).willReturn(APP_1_SOL_AUTH_TOKEN);
given(idamService.retrieveUser(APP_1_SOL_AUTH_TOKEN)).willReturn(solicitorUser);
given(authTokenGenerator.generate()).willReturn(TEST_SERVICE_AUTH_TOKEN);
UUID uuid = UUID.randomUUID();
byte[] firstFile = "data from file 1".getBytes(StandardCharsets.UTF_8);
given(sendLetterApi.sendLetter(eq(TEST_SERVICE_AUTH_TOKEN), isA(LetterV3.class))).willReturn(new SendLetterResponse(uuid));
given(resource.getInputStream()).willReturn(new ByteArrayInputStream(firstFile)).willReturn(new ByteArrayInputStream(firstFile));
ListValue<ConfidentialDivorceDocument> divorceDocumentListValue = confidentialDocumentWithType(ConfidentialDocumentsReceived.NOTICE_OF_PROCEEDINGS_APP_1);
final String documentUuid = FilenameUtils.getName(divorceDocumentListValue.getValue().getDocumentLink().getUrl());
given(documentManagementClient.downloadBinary(APP_1_SOL_AUTH_TOKEN, TEST_SERVICE_AUTH_TOKEN, solicitorRolesCsv, userId, documentUuid)).willReturn(ResponseEntity.ok(resource));
List<Letter> letters = List.of(new Letter(divorceDocumentListValue.getValue(), 1));
Print print = new Print(letters, "1234", "5678", "letterType");
UUID letterId = bulkPrintService.print(print);
assertThat(letterId).isEqualTo(uuid);
verify(sendLetterApi).sendLetter(eq(TEST_SERVICE_AUTH_TOKEN), letterV3ArgumentCaptor.capture());
LetterV3 letterV3 = letterV3ArgumentCaptor.getValue();
assertThat(letterV3.documents).extracting("content", "copies").contains(tuple(Base64.getEncoder().encodeToString(firstFile), 1));
assertThat(letterV3.additionalData).contains(entry(LETTER_TYPE_KEY, "letterType"), entry(CASE_REFERENCE_NUMBER_KEY, "5678"), entry(CASE_IDENTIFIER_KEY, "1234"));
verify(httpServletRequest, times(1)).getHeader(AUTHORIZATION);
verify(idamService, times(1)).retrieveUser(APP_1_SOL_AUTH_TOKEN);
verify(documentManagementClient).downloadBinary(APP_1_SOL_AUTH_TOKEN, TEST_SERVICE_AUTH_TOKEN, solicitorRolesCsv, userId, documentUuid);
verify(authTokenGenerator).generate();
}
use of uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument in project nfdiv-case-api by hmcts.
the class AosPackPrinterTest method shouldPrintAosPackForApplicantIfRequiredDocumentsArePresentAndApplicantContactIsPrivate.
@Test
void shouldPrintAosPackForApplicantIfRequiredDocumentsArePresentAndApplicantContactIsPrivate() {
final ListValue<ConfidentialDivorceDocument> doc1 = ListValue.<ConfidentialDivorceDocument>builder().value(ConfidentialDivorceDocument.builder().confidentialDocumentsReceived(ConfidentialDocumentsReceived.NOTICE_OF_PROCEEDINGS_APP_1).build()).build();
final ListValue<DivorceDocument> doc2 = ListValue.<DivorceDocument>builder().value(DivorceDocument.builder().documentType(APPLICATION).build()).build();
final ListValue<DivorceDocument> doc3 = ListValue.<DivorceDocument>builder().value(DivorceDocument.builder().documentType(NAME_CHANGE_EVIDENCE).build()).build();
final CaseData caseData = CaseData.builder().applicant1(Applicant.builder().contactDetailsType(ContactDetailsType.PRIVATE).build()).documents(CaseDocuments.builder().confidentialDocumentsGenerated(List.of(doc1)).documentsGenerated(asList(doc2, doc3)).build()).build();
when(bulkPrintService.print(printCaptor.capture())).thenReturn(randomUUID());
aosPackPrinter.sendAosLetterToApplicant(caseData, TEST_CASE_ID);
final Print print = printCaptor.getValue();
assertThat(print.getCaseId()).isEqualTo(TEST_CASE_ID.toString());
assertThat(print.getCaseRef()).isEqualTo(TEST_CASE_ID.toString());
assertThat(print.getLetterType()).isEqualTo("applicant-aos-pack");
assertThat(print.getLetters().size()).isEqualTo(2);
assertThat(print.getLetters().get(0).getConfidentialDivorceDocument()).isSameAs(doc1.getValue());
assertThat(print.getLetters().get(1).getDivorceDocument()).isSameAs(doc2.getValue());
}
use of uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument in project nfdiv-case-api by hmcts.
the class CaseworkerUploadConfidentialDocumentTest method shouldRetainDocumentsOrderWhenThereAreNoExistingDocuments.
@Test
void shouldRetainDocumentsOrderWhenThereAreNoExistingDocuments() {
final CaseDetails<CaseData, State> previousCaseDetails = new CaseDetails<>();
previousCaseDetails.setData(caseData());
final ListValue<ConfidentialDivorceDocument> doc1 = getDocumentListValue("http://localhost:4200/assets/59a54ccc-979f-11eb-a8b3-0242ac130003", "annex_a.pdf", ANNEX_A);
final ListValue<ConfidentialDivorceDocument> doc2 = getDocumentListValue("http://localhost:4200/assets/59a54ccc-979f-11eb-a8b3-0242ac130004", "aos.pdf", AOS);
final CaseData caseData = caseData();
final CaseDetails<CaseData, State> updatedCaseDetails = new CaseDetails<>();
caseData.getDocuments().setConfidentialDocumentsUploaded(List.of(doc1, doc2));
updatedCaseDetails.setData(caseData);
AboutToStartOrSubmitResponse<CaseData, State> response = caseworkerUploadConfidentialDocument.aboutToSubmit(updatedCaseDetails, previousCaseDetails);
List<ListValue<ConfidentialDivorceDocument>> actualDocuments = response.getData().getDocuments().getConfidentialDocumentsUploaded();
assertThat(actualDocuments.size()).isEqualTo(2);
assertThat(actualDocuments.get(0).getValue()).isSameAs(doc1.getValue());
assertThat(actualDocuments.get(1).getValue()).isSameAs(doc2.getValue());
}
use of uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument in project nfdiv-case-api by hmcts.
the class TestDataHelper method confidentialDocumentWithType.
public static ListValue<ConfidentialDivorceDocument> confidentialDocumentWithType(final ConfidentialDocumentsReceived documentType, final String documentId) {
String documentUrl = "http://localhost:8080/" + documentId;
Document ccdDocument = new Document(documentUrl, "test-draft-divorce-application.pdf", documentUrl + "/binary");
ConfidentialDivorceDocument confidentialDivorceDocument = ConfidentialDivorceDocument.builder().documentLink(ccdDocument).documentFileName("test-draft-divorce-application-12345.pdf").confidentialDocumentsReceived(documentType).build();
return ListValue.<ConfidentialDivorceDocument>builder().id(documentType.getLabel()).value(confidentialDivorceDocument).build();
}
Aggregations