Search in sources :

Example 1 with ConfidentialDivorceDocument

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());
}
Also used : CaseData(uk.gov.hmcts.divorce.divorcecase.model.CaseData) ConfidentialDivorceDocument(uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument) State(uk.gov.hmcts.divorce.divorcecase.model.State) CaseDetails(uk.gov.hmcts.ccd.sdk.api.CaseDetails) ListValue(uk.gov.hmcts.ccd.sdk.type.ListValue) Test(org.junit.jupiter.api.Test)

Example 2 with ConfidentialDivorceDocument

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();
}
Also used : User(uk.gov.hmcts.reform.idam.client.models.User) SendLetterResponse(uk.gov.hmcts.reform.sendletter.api.SendLetterResponse) LetterV3(uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3) Letter(uk.gov.hmcts.divorce.document.print.model.Letter) Print(uk.gov.hmcts.divorce.document.print.model.Print) ConfidentialDivorceDocument(uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument) ByteArrayInputStream(java.io.ByteArrayInputStream) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 3 with ConfidentialDivorceDocument

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());
}
Also used : ConfidentialDivorceDocument(uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument) DivorceDocument(uk.gov.hmcts.divorce.document.model.DivorceDocument) Print(uk.gov.hmcts.divorce.document.print.model.Print) ConfidentialDivorceDocument(uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument) CaseData(uk.gov.hmcts.divorce.divorcecase.model.CaseData) Test(org.junit.jupiter.api.Test)

Example 4 with ConfidentialDivorceDocument

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());
}
Also used : CaseData(uk.gov.hmcts.divorce.divorcecase.model.CaseData) ConfidentialDivorceDocument(uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument) State(uk.gov.hmcts.divorce.divorcecase.model.State) CaseDetails(uk.gov.hmcts.ccd.sdk.api.CaseDetails) ListValue(uk.gov.hmcts.ccd.sdk.type.ListValue) Test(org.junit.jupiter.api.Test)

Example 5 with ConfidentialDivorceDocument

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();
}
Also used : ConfidentialDivorceDocument(uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument) ScannedDocument(uk.gov.hmcts.ccd.sdk.type.ScannedDocument) ConfidentialDivorceDocument(uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument) DivorceDocument(uk.gov.hmcts.divorce.document.model.DivorceDocument) Document(uk.gov.hmcts.ccd.sdk.type.Document)

Aggregations

ConfidentialDivorceDocument (uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument)9 Test (org.junit.jupiter.api.Test)8 CaseData (uk.gov.hmcts.divorce.divorcecase.model.CaseData)7 ListValue (uk.gov.hmcts.ccd.sdk.type.ListValue)6 User (uk.gov.hmcts.reform.idam.client.models.User)5 HashMap (java.util.HashMap)4 DocumentInfo (uk.gov.hmcts.divorce.document.model.DocumentInfo)4 CaseDetails (uk.gov.hmcts.ccd.sdk.api.CaseDetails)2 State (uk.gov.hmcts.divorce.divorcecase.model.State)2 DivorceDocument (uk.gov.hmcts.divorce.document.model.DivorceDocument)2 Print (uk.gov.hmcts.divorce.document.print.model.Print)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 UUID (java.util.UUID)1 Document (uk.gov.hmcts.ccd.sdk.type.Document)1 ScannedDocument (uk.gov.hmcts.ccd.sdk.type.ScannedDocument)1 ConfidentialDocumentsReceived (uk.gov.hmcts.divorce.document.model.ConfidentialDocumentsReceived)1 Letter (uk.gov.hmcts.divorce.document.print.model.Letter)1 SendLetterResponse (uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)1 LetterV3 (uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3)1