From ba14d3991bac5b09922b78a52dd22e8be8db20af Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Thu, 29 Feb 2024 16:19:10 +0000 Subject: [PATCH 01/96] POC files --- ...eralDocumentsContestedMidEventHandler.java | 91 ++++++++++++++++++ .../documentchecker/DocumentChecker.java | 14 +++ .../DocumentCheckerService.java | 50 ++++++++++ .../DocumentContentCheckerException.java | 8 ++ .../documentchecker/DocxDocumentChecker.java | 50 ++++++++++ .../DuplicateFilenameDocumentChecker.java | 40 ++++++++ .../documentchecker/PdfDocumentChecker.java | 49 ++++++++++ .../ApplicantNameDocumentContentChecker.java | 40 ++++++++ .../CaseNumberDocumentContentChecker.java | 37 +++++++ .../DocumentContentChecker.java | 8 ++ .../RespondentNameDocumentContentChecker.java | 40 ++++++++ .../utils/pdf/PdfToText.java | 21 ++++ .../DocumentCheckerServiceTest.java | 4 + .../DocxDocumentCheckerTest.java | 4 + .../DuplicateFilenameDocumentCheckerTest.java | 46 +++++++++ .../PdfDocumentCheckerTest.java | 67 +++++++++++++ .../WordDocXValidatorTest.java | 37 +++++++ ...plicantNameDocumentContentCheckerTest.java | 4 + ...pondentNameDocumentContentCheckerTest.java | 4 + .../generalOrder.docx | Bin 0 -> 57045 bytes .../generalOrder.pdf | Bin 0 -> 73425 bytes 21 files changed, 614 insertions(+) create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedMidEventHandler.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentChecker.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentContentCheckerException.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/DocumentContentChecker.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/pdf/PdfToText.java create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/WordDocXValidatorTest.java create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java create mode 100644 src/test/resources/fixtures/documentcontentvalidation/generalOrder.docx create mode 100644 src/test/resources/fixtures/documentcontentvalidation/generalOrder.pdf diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedMidEventHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedMidEventHandler.java new file mode 100644 index 0000000000..d8b519c04f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedMidEventHandler.java @@ -0,0 +1,91 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; +import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; +import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackHandler; +import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackRequest; +import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +@Service +@Slf4j +public class UploadGeneralDocumentsContestedMidEventHandler extends FinremCallbackHandler { + + private final DocumentCheckerService documentCheckerService; + + public UploadGeneralDocumentsContestedMidEventHandler(FinremCaseDetailsMapper finremCaseDetailsMapper, + DocumentCheckerService documentCheckerService) { + super(finremCaseDetailsMapper); + this.documentCheckerService = documentCheckerService; + } + + @Override + public boolean canHandle(CallbackType callbackType, CaseType caseType, EventType eventType) { + return CallbackType.MID_EVENT.equals(callbackType) + && CaseType.CONTESTED.equals(caseType) + && EventType.UPLOAD_GENERAL_DOCUMENT.equals(eventType); + } + + @Override + public GenericAboutToStartOrSubmitCallbackResponse handle( + FinremCallbackRequest callbackRequestWithFinremCaseDetails, String userAuthorisation) { + + log.info("Mid-event Upload document callback for case {}", + callbackRequestWithFinremCaseDetails.getCaseDetails().getId()); + + FinremCaseData caseData = callbackRequestWithFinremCaseDetails.getCaseDetails().getData(); + + List warnings = new ArrayList<>(); + + List newDocuments = getNewlyUploadedDocuments( + callbackRequestWithFinremCaseDetails.getCaseDetails().getData().getUploadGeneralDocuments(), + callbackRequestWithFinremCaseDetails.getCaseDetailsBefore().getData().getUploadGeneralDocuments()); + if (ObjectUtils.isNotEmpty(newDocuments)) { + newDocuments.forEach(d -> { + List documentWarnings = documentCheckerService.getWarnings(d.getValue().getDocumentLink(), + callbackRequestWithFinremCaseDetails.getCaseDetails(), userAuthorisation); + warnings.addAll(documentWarnings); + }); + } + + return GenericAboutToStartOrSubmitCallbackResponse.builder() + .warnings(warnings) + .data(caseData) + .build(); + } + + private List getNewlyUploadedDocuments( + List uploadedDocuments, + List previousDocuments) { + + if (ObjectUtils.isEmpty(uploadedDocuments)) { + return Collections.emptyList(); + } else if (ObjectUtils.isEmpty(previousDocuments)) { + return uploadedDocuments; + } + + List newlyUploadedDocuments = new ArrayList<>(); + uploadedDocuments.forEach(d -> { + boolean exists = previousDocuments.stream() + .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); + if (!exists) { + newlyUploadedDocuments.add(d); + } + }); + + return newlyUploadedDocuments; + } + + +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentChecker.java new file mode 100644 index 0000000000..252d15202b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentChecker.java @@ -0,0 +1,14 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; + +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; + +import java.util.List; + +public interface DocumentChecker { + + boolean canCheck(CaseDocument caseDocument); + + List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails caseDetails) + throws DocumentContentCheckerException; +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java new file mode 100644 index 0000000000..4ba3dcd607 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java @@ -0,0 +1,50 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.evidencemanagement.EvidenceManagementDownloadService; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +@Service +@Slf4j +public class DocumentCheckerService { + + private final EvidenceManagementDownloadService downloadService; + + private final List documentCheckers; + + public DocumentCheckerService(EvidenceManagementDownloadService downloadService, + List documentCheckers) { + this.downloadService = downloadService; + this.documentCheckers = documentCheckers; + } + + public List getWarnings(CaseDocument caseDocument, FinremCaseDetails caseDetails, String authToken) { + List documentCheckersForDocument = documentCheckers.stream() + .filter(dc -> dc.canCheck(caseDocument)) + .toList(); + + + if (documentCheckersForDocument.isEmpty()) { + return Collections.emptyList(); + } + + byte[] bytes = downloadService.download(caseDocument.getDocumentBinaryUrl(), authToken); + + List warnings = new ArrayList<>(); + documentCheckersForDocument.forEach(dc -> { + try { + warnings.addAll(dc.getWarnings(caseDocument, bytes, caseDetails)); + } catch (DocumentContentCheckerException e) { + log.error("Unexpected error", e); + } + }); + + return warnings; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentContentCheckerException.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentContentCheckerException.java new file mode 100644 index 0000000000..295ca2682c --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentContentCheckerException.java @@ -0,0 +1,8 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; + +public class DocumentContentCheckerException extends Exception { + + public DocumentContentCheckerException(Throwable cause) { + super(cause); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java new file mode 100644 index 0000000000..d4f17d9dbd --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java @@ -0,0 +1,50 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; + +import org.apache.commons.io.FilenameUtils; +import org.apache.poi.xwpf.extractor.XWPFWordExtractor; +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.DocumentContentChecker; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + + +public class DocxDocumentChecker implements DocumentChecker { + + private final List documentContentCheckers; + + public DocxDocumentChecker(List documentContentCheckers) { + this.documentContentCheckers = documentContentCheckers; + } + + @Override + public boolean canCheck(CaseDocument caseDocument) { + return FilenameUtils.getExtension(caseDocument.getDocumentFilename()).equalsIgnoreCase("DOCX"); + } + + @Override + public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails caseDetails) + throws DocumentContentCheckerException { + String[] content = getContent(bytes); + + return documentContentCheckers.stream() + .map(dcc -> dcc.getWarning(caseDetails, content)) + .toList(); + } + + private String[] getContent(byte[] caseDocument) throws DocumentContentCheckerException { + InputStream is = new ByteArrayInputStream(caseDocument); + try (XWPFDocument wordDoc = new XWPFDocument(is)) { + XWPFWordExtractor extractor = new XWPFWordExtractor(wordDoc); + String content = extractor.getText(); + return content.split(System.lineSeparator()); + + } catch (IOException e) { + throw new DocumentContentCheckerException(e); + } + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java new file mode 100644 index 0000000000..a0d73aa4b6 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -0,0 +1,40 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; + +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; + +import java.util.Collections; +import java.util.List; +import java.util.function.Supplier; + +@Component +public class DuplicateFilenameDocumentChecker implements DocumentChecker { + + private static final String WARNING = "A document with this filename already exists on the case"; + + @Override + public boolean canCheck(CaseDocument caseDocument) { + return true; + } + + @Override + public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails caseDetails) + throws DocumentContentCheckerException { + + FinremCaseData caseData = caseDetails.getData(); + if (isDuplicateFilename(caseDocument, caseData::getAdditionalDocument)) { + return List.of(WARNING); + } + if (isDuplicateFilename(caseDocument, caseData.getGeneralOrderWrapper()::getGeneralOrderLatestDocument)) { + return List.of(WARNING); + } + + return Collections.emptyList(); + } + + private boolean isDuplicateFilename(CaseDocument caseDocument, Supplier caseDocumentSupplier) { + return caseDocumentSupplier.get() != null && caseDocumentSupplier.get().getDocumentFilename().equals(caseDocument.getDocumentFilename()); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java new file mode 100644 index 0000000000..9904305bba --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java @@ -0,0 +1,49 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; + +import org.apache.commons.io.FilenameUtils; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.text.PDFTextStripper; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.DocumentContentChecker; + +import java.io.IOException; +import java.util.List; + +@Component +public class PdfDocumentChecker implements DocumentChecker { + + private final List documentContentCheckers; + + public PdfDocumentChecker(List documentContentCheckers) { + this.documentContentCheckers = documentContentCheckers; + } + + @Override + public boolean canCheck(CaseDocument caseDocument) { + return FilenameUtils.getExtension(caseDocument.getDocumentFilename()).equalsIgnoreCase("PDF"); + } + + @Override + public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails caseDetails) + throws DocumentContentCheckerException { + try { + String[] content = getContent(bytes); + + return documentContentCheckers.stream() + .map(dcc -> dcc.getWarning(caseDetails, content)) + .toList(); + } catch (IOException e) { + throw new DocumentContentCheckerException(e); + } + } + + private String[] getContent(byte[] bytes) throws IOException { + try (PDDocument document = PDDocument.load(bytes)) { + PDFTextStripper stripper = new PDFTextStripper(); + String content = stripper.getText(document); + return content.split(System.lineSeparator()); + } + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java new file mode 100644 index 0000000000..424fe3a30e --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java @@ -0,0 +1,40 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; + +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; + +import java.util.stream.Stream; + +@Component +public class ApplicantNameDocumentContentChecker implements DocumentContentChecker { + + private static final String WARNING = "Applicant name may not match"; + + @Override + public String getWarning(FinremCaseDetails caseDetails, String[] content) { + boolean checkFails = Stream.of(content) + .filter(this::containsTheApplicantIs) + .anyMatch(c -> contentNameNotEqualsCaseName(caseDetails.getData(), c)); + + return checkFails ? WARNING : null; + } + + private boolean containsTheApplicantIs(String text) { + return text.contains("1. The applicant is"); + } + + private boolean contentNameNotEqualsCaseName(FinremCaseData caseData, String content) { + return !getApplicantNameFromCase(caseData).equals(getApplicantNameFromContent(content.trim())); + } + + private String getApplicantNameFromContent(String text) { + return text.replace("1. The applicant is ", "").trim(); + } + + private String getApplicantNameFromCase(FinremCaseData caseData) { + ContactDetailsWrapper contactDetails = caseData.getContactDetailsWrapper(); + return contactDetails.getApplicantFmName() + " " + contactDetails.getApplicantLname(); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java new file mode 100644 index 0000000000..719224e875 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java @@ -0,0 +1,37 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; + +import com.google.common.base.CharMatcher; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; + +import java.util.stream.Stream; + +@Component +public class CaseNumberDocumentContentChecker implements DocumentContentChecker { + + private static final String WARNING = "Case numbers may not match"; + + @Override + public String getWarning(FinremCaseDetails caseDetails, String[] content) { + boolean checkFails = Stream.of(content) + .filter(this::containsCaseNumber) + .anyMatch(c -> contentCaseNumberNotEqualsCaseNumber(caseDetails, c)); + + return checkFails ? WARNING : null; + } + + private boolean containsCaseNumber(String text) { + return text.contains("Case number"); + } + + private boolean contentCaseNumberNotEqualsCaseNumber(FinremCaseDetails caseDetails, String content) { + long caseNumberFromContent = getCaseNumberFromContent(content); + return caseNumberFromContent != caseDetails.getId(); + } + + private long getCaseNumberFromContent(String text) { + return Long.parseLong(CharMatcher.inRange('0', '9').retainFrom(text)); + } + + +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/DocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/DocumentContentChecker.java new file mode 100644 index 0000000000..1ee8bc49b5 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/DocumentContentChecker.java @@ -0,0 +1,8 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; + +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; + +public interface DocumentContentChecker { + + String getWarning(FinremCaseDetails caseDetails, String[] content); +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java new file mode 100644 index 0000000000..1ed0765ebe --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java @@ -0,0 +1,40 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; + +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; + +import java.util.stream.Stream; + +@Component +public class RespondentNameDocumentContentChecker implements DocumentContentChecker { + + private static final String WARNING = "Respondent name may not match"; + + @Override + public String getWarning(FinremCaseDetails caseDetails, String[] content) { + boolean checkFails = Stream.of(content) + .filter(this::containsTheRespondentIs) + .anyMatch(c -> contentNameNotEqualsCaseName(caseDetails.getData(), c)); + + return checkFails ? WARNING : null; + } + + private boolean containsTheRespondentIs(String text) { + return text.contains("The respondent is"); + } + + private boolean contentNameNotEqualsCaseName(FinremCaseData caseData, String content) { + return !getRespondentNameFromCase(caseData).equals(getRespondentNameFromContent(content.trim())); + } + + private String getRespondentNameFromContent(String text) { + return text.replace("The respondent is ", "").trim(); + } + + private String getRespondentNameFromCase(FinremCaseData caseData) { + ContactDetailsWrapper contactDetails = caseData.getContactDetailsWrapper(); + return contactDetails.getRespondentFmName() + " " + contactDetails.getRespondentLname(); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/pdf/PdfToText.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/pdf/PdfToText.java new file mode 100644 index 0000000000..ef6cdc35fb --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/pdf/PdfToText.java @@ -0,0 +1,21 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.utils.pdf; + +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.text.PDFTextStripper; + +import java.io.IOException; + +public class PdfToText { + + public static String textContent(byte[] bytes) throws IOException { + try (PDDocument document = PDDocument.load(bytes)) { + PDFTextStripper stripper = new PDFTextStripper(); + return stripper.getText(document); + } + } + + public static String[] textContentLines(byte[] bytes) throws IOException { + String content = textContent(bytes); + return content.split(System.lineSeparator()); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java new file mode 100644 index 0000000000..5bd14b191c --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java @@ -0,0 +1,4 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; + +class DocumentCheckerServiceTest { +} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java new file mode 100644 index 0000000000..958ab35bc4 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java @@ -0,0 +1,4 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; + +public class DocxDocumentCheckerTest { +} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java new file mode 100644 index 0000000000..6f5ce95f5a --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -0,0 +1,46 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; + +class DuplicateFilenameDocumentCheckerTest { + +// @Test +// void givenFilenameExistsOnGeneralOrderLatestDocument_whenChecksFailCalled_thenReturnsTrue() throws DocumentContentCheckerException { +// String filename = "generalOrder-123.pd"; +// CaseDocument caseDocument = CaseDocument.builder() +// .documentFilename(filename) +// .build(); +// FinremCaseData caseData = FinremCaseData.builder() +// .generalOrderWrapper(GeneralOrderWrapper.builder() +// .generalOrderLatestDocument(caseDocument) +// .build()) +// .build(); +// +// CaseDocument caseDocumentToCheck = CaseDocument.builder() +// .documentFilename(filename) +// .build(); +// +// DuplicateFilenameDocumentChecker checker = new DuplicateFilenameDocumentChecker(); +// +// assertThat(checker.checksFail(caseDocumentToCheck, new byte[0], caseData)).isTrue(); +// } +// +// @Test +// void givenFilenameNotExistsOnGeneralOrderLatestDocument_whenChecksFailCalled_thenReturnsFalse() throws DocumentContentCheckerException { +// String filename = "generalOrder-123.pdf"; +// CaseDocument caseDocument = CaseDocument.builder() +// .documentFilename(filename) +// .build(); +// FinremCaseData caseData = FinremCaseData.builder() +// .generalOrderWrapper(GeneralOrderWrapper.builder() +// .generalOrderLatestDocument(caseDocument) +// .build()) +// .build(); +// +// CaseDocument caseDocumentToCheck = CaseDocument.builder() +// .documentFilename("generalOrder-456.pdf") +// .build(); +// +// DuplicateFilenameDocumentChecker checker = new DuplicateFilenameDocumentChecker(); +// +// assertThat(checker.getWarnings(caseDocumentToCheck, new byte[0], caseData)).isFalse(); +// } +} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java new file mode 100644 index 0000000000..15154b0376 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java @@ -0,0 +1,67 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; + +class PdfDocumentCheckerTest { +} + +//package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; +// +//import com.google.common.net.MediaType; +//import org.junit.jupiter.api.Test; +//import org.junit.jupiter.params.ParameterizedTest; +//import org.junit.jupiter.params.provider.Arguments; +//import org.junit.jupiter.params.provider.MethodSource; +//import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +//import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; +//import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.ApplicantNameDocumentContentChecker; +// +//import java.io.IOException; +//import java.net.URISyntaxException; +//import java.nio.file.Files; +//import java.nio.file.Paths; +//import java.util.Objects; +//import java.util.stream.Stream; +// +//import static org.assertj.core.api.Assertions.assertThat; +// +//class PdfAppRespValidatorTest { +// +// @Test +// void testDoesNotHandleWordDoc() throws DocumentContentCheckerException { +// FinremCaseData caseData = new FinremCaseData(); +// MediaType mediaType = MediaType.MICROSOFT_WORD; +// byte[] document = new byte[100]; +// +// ApplicantNameDocumentContentChecker validator = new ApplicantNameDocumentContentChecker(); +// assertThat(validator.isContentInvalid(caseData, mediaType, document)).isFalse(); +// } +// @ParameterizedTest +// @MethodSource +// void testApplicantNameValidation(String applicantFirstName, String applicantLastName, boolean expectedIsInvalid) +// throws IOException, DocumentContentCheckerException, URISyntaxException { +// FinremCaseData caseData = FinremCaseData.builder() +// .contactDetailsWrapper(ContactDetailsWrapper.builder() +// .build() +// ) +// .build(); +// byte[] document = loadTestFile("fixtures/documentcontentvalidation/generalOrder.pdf"); +// +// ApplicantNameDocumentContentChecker validator = new ApplicantNameDocumentContentChecker(); +// +// assertThat(validator.isContentInvalid(caseData, MediaType.PDF, document)).isEqualTo(expectedIsInvalid); +// } +// +// private static Stream testApplicantNameValidation() { +// return Stream.of( +// Arguments.of("Doris", "Duck", false), +// Arguments.of("Davey", "Duck", false), +// Arguments.of("Donald", "Duck", true), +// Arguments.of("Bella", "Smith", true) +// ); +// } +// +// private byte[] loadTestFile(String filename) throws IOException, URISyntaxException { +// return Files.readAllBytes(Paths.get(Objects.requireNonNull(Thread.currentThread() +// .getContextClassLoader().getResource(filename)).toURI())); +// } +//} + diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/WordDocXValidatorTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/WordDocXValidatorTest.java new file mode 100644 index 0000000000..0037839307 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/WordDocXValidatorTest.java @@ -0,0 +1,37 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; + +class WordDocXValidatorTest { +// @ParameterizedTest +// @MethodSource +// void testApplicantNameValidation(String applicantFmName, String applicantLastName, boolean expectedIsInvalid) +// throws IOException, DocumentContentCheckerException, URISyntaxException { +// FinremCaseData caseData = FinremCaseData.builder() +// .contactDetailsWrapper(ContactDetailsWrapper.builder() +// .applicantFmName(applicantFmName) +// .applicantLname(applicantLastName) +// .respondentFmName("Davey") +// .respondentLname("Duck") +// .build() +// ) +// .build(); +// byte[] document = loadTestFile("fixtures/documentcontentvalidation/generalOrder.docx"); +// +// DocxDocumentChecker validator = new DocxDocumentChecker(); +// +// assertThat(validator.isContentInvalid(caseData, MediaType.MICROSOFT_WORD, document)).isEqualTo(expectedIsInvalid); +// } +// +// private static Stream testApplicantNameValidation() { +// return Stream.of( +// Arguments.of("Doris", "Duck", false), +// Arguments.of("Davey", "Duck", false), +// Arguments.of("Donald", "Duck", true), +// Arguments.of("Bella", "Smith", true) +// ); +// } +// +// private byte[] loadTestFile(String filename) throws IOException, URISyntaxException { +// return Files.readAllBytes(Paths.get(Objects.requireNonNull(Thread.currentThread() +// .getContextClassLoader().getResource(filename)).toURI())); +// } +} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java new file mode 100644 index 0000000000..b00f9f29aa --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java @@ -0,0 +1,4 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; + +class ApplicantNameDocumentContentCheckerTest { +} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java new file mode 100644 index 0000000000..c7d64e98a9 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java @@ -0,0 +1,4 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; + +class RespondentNameDocumentContentCheckerTest { +} diff --git a/src/test/resources/fixtures/documentcontentvalidation/generalOrder.docx b/src/test/resources/fixtures/documentcontentvalidation/generalOrder.docx new file mode 100644 index 0000000000000000000000000000000000000000..9a6da0da96eb4726c845669c3ebeb4224661e71b GIT binary patch literal 57045 zcmeFXg;!fav@eVmDb|)23sRuPt+=N^ixdgc7AO)Ng1fs@+?}8S3I&Qg6eqa5yF+jb zAHDCs``)+ipK#x-HJQnoedf%Zvwz!WE6Jf_yhg!9!A3zrp+U(#Zlp9qML|({hJr$b zf{msrX>H|TWaR+<>S|+Tug&gaY4J7(1C22Y1?`Fc|CRs2Z=fo^->if4#pkO)r2lBm z%$Ekn{La3dC?kOBE$UAmr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@hAYOzseR!Wp!;hUis863D>p(l`M^MBu#>n4Lbp4&J`psfk14& Date: Mon, 10 Jun 2024 12:22:50 +0100 Subject: [PATCH 02/96] Missing @Component tag --- .../service/documentchecker/DocxDocumentChecker.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java index d4f17d9dbd..4d7c72a067 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java @@ -3,6 +3,7 @@ import org.apache.commons.io.FilenameUtils; import org.apache.poi.xwpf.extractor.XWPFWordExtractor; import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.DocumentContentChecker; @@ -12,7 +13,7 @@ import java.io.InputStream; import java.util.List; - +@Component public class DocxDocumentChecker implements DocumentChecker { private final List documentContentCheckers; From 9b9679fa29127c57a7c3302595ec8eea22c051df Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 10 Jun 2024 16:47:20 +0100 Subject: [PATCH 03/96] Move the validation logic to AboutToSubmit event. --- ...dGeneralDocumentsAboutToSubmitHandler.java | 66 ----------- ...ocumentsContestedAboutToSubmitHandler.java | 111 ++++++++++++++++++ ...eralDocumentsContestedMidEventHandler.java | 91 -------------- ...ntsContestedAboutToSubmitHandlerTest.java} | 18 +-- 4 files changed, 122 insertions(+), 164 deletions(-) delete mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandler.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java delete mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedMidEventHandler.java rename src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/{UploadGeneralDocumentsAboutToSubmitHandlerTest.java => UploadGeneralDocumentsContestedAboutToSubmitHandlerTest.java} (86%) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandler.java deleted file mode 100644 index 679a77d2c8..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -package uk.gov.hmcts.reform.finrem.caseorchestration.handler; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; -import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; -import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadedGeneralDocumentService; -import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; -import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentcatergory.UploadGeneralDocumentsCategoriser; - -import java.util.Comparator; -import java.util.List; - -import static java.util.Comparator.comparing; -import static java.util.Comparator.nullsLast; - -@Slf4j -@Service -public class UploadGeneralDocumentsAboutToSubmitHandler extends FinremCallbackHandler { - - private final UploadedGeneralDocumentService uploadedGeneralDocumentHelper; - private final UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser; - - public UploadGeneralDocumentsAboutToSubmitHandler(FinremCaseDetailsMapper mapper, - UploadedGeneralDocumentService uploadedGeneralDocumentHelper, - UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser) { - super(mapper); - this.uploadedGeneralDocumentHelper = uploadedGeneralDocumentHelper; - this.uploadGeneralDocumentsCategoriser = uploadGeneralDocumentsCategoriser; - } - - @Override - public boolean canHandle(CallbackType callbackType, CaseType caseType, EventType eventType) { - return CallbackType.ABOUT_TO_SUBMIT.equals(callbackType) - && EventType.UPLOAD_GENERAL_DOCUMENT.equals(eventType); - } - - @Override - @SuppressWarnings("squid:CallToDeprecatedMethod") - public GenericAboutToStartOrSubmitCallbackResponse handle(FinremCallbackRequest callbackRequest, - String userAuthorisation) { - - FinremCaseData caseData = callbackRequest.getCaseDetails().getData(); - uploadedGeneralDocumentHelper.addUploadDateToNewDocuments( - caseData, - callbackRequest.getCaseDetailsBefore().getData()); - - List uploadedDocuments = caseData.getUploadGeneralDocuments(); - - uploadedDocuments.sort(comparing(UploadGeneralDocumentCollection::getValue, - comparing(UploadGeneralDocument::getGeneralDocumentUploadDateTime, nullsLast(Comparator.reverseOrder())))); - - uploadedDocuments.forEach(doc -> doc.getValue().getDocumentType()); - - caseData.setUploadGeneralDocuments(uploadedDocuments); - - uploadGeneralDocumentsCategoriser.categorise(caseData); - - return GenericAboutToStartOrSubmitCallbackResponse.builder().data(caseData).build(); - } -} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java new file mode 100644 index 0000000000..f520066281 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java @@ -0,0 +1,111 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; +import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; +import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackHandler; +import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackRequest; +import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadedGeneralDocumentService; +import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentcatergory.UploadGeneralDocumentsCategoriser; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import static java.util.Comparator.comparing; +import static java.util.Comparator.nullsLast; + +@Slf4j +@Service +public class UploadGeneralDocumentsContestedAboutToSubmitHandler extends FinremCallbackHandler { + + private final DocumentCheckerService documentCheckerService; + private final UploadedGeneralDocumentService uploadedGeneralDocumentHelper; + private final UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser; + + public UploadGeneralDocumentsContestedAboutToSubmitHandler(FinremCaseDetailsMapper mapper, + DocumentCheckerService documentCheckerService, + UploadedGeneralDocumentService uploadedGeneralDocumentHelper, + UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser) { + super(mapper); + this.documentCheckerService = documentCheckerService; + this.uploadedGeneralDocumentHelper = uploadedGeneralDocumentHelper; + this.uploadGeneralDocumentsCategoriser = uploadGeneralDocumentsCategoriser; + } + + @Override + public boolean canHandle(CallbackType callbackType, CaseType caseType, EventType eventType) { + return CallbackType.ABOUT_TO_SUBMIT.equals(callbackType) + && CaseType.CONTESTED.equals(caseType) + && EventType.UPLOAD_GENERAL_DOCUMENT.equals(eventType); + } + + @Override + @SuppressWarnings("squid:CallToDeprecatedMethod") + public GenericAboutToStartOrSubmitCallbackResponse handle(FinremCallbackRequest callbackRequest, + String userAuthorisation) { + + FinremCaseData caseData = callbackRequest.getCaseDetails().getData(); + uploadedGeneralDocumentHelper.addUploadDateToNewDocuments( + caseData, + callbackRequest.getCaseDetailsBefore().getData()); + + List warnings = new ArrayList<>(); + List newDocuments = getNewlyUploadedDocuments( + callbackRequest.getCaseDetails().getData().getUploadGeneralDocuments(), + callbackRequest.getCaseDetailsBefore().getData().getUploadGeneralDocuments()); + if (ObjectUtils.isNotEmpty(newDocuments)) { + newDocuments.forEach(d -> { + List documentWarnings = documentCheckerService.getWarnings(d.getValue().getDocumentLink(), + callbackRequest.getCaseDetails(), userAuthorisation); + warnings.addAll(documentWarnings); + }); + } + + List uploadedDocuments = caseData.getUploadGeneralDocuments(); + + uploadedDocuments.sort(comparing(UploadGeneralDocumentCollection::getValue, + comparing(UploadGeneralDocument::getGeneralDocumentUploadDateTime, nullsLast(Comparator.reverseOrder())))); + + caseData.setUploadGeneralDocuments(uploadedDocuments); + + uploadGeneralDocumentsCategoriser.categorise(caseData); + + return GenericAboutToStartOrSubmitCallbackResponse.builder() + .warnings(warnings) + .data(caseData).build(); + } + + private List getNewlyUploadedDocuments( + List uploadedDocuments, + List previousDocuments) { + + if (ObjectUtils.isEmpty(uploadedDocuments)) { + return Collections.emptyList(); + } else if (ObjectUtils.isEmpty(previousDocuments)) { + return uploadedDocuments; + } + + List newlyUploadedDocuments = new ArrayList<>(); + uploadedDocuments.forEach(d -> { + boolean exists = previousDocuments.stream() + .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); + if (!exists) { + newlyUploadedDocuments.add(d); + } + }); + + return newlyUploadedDocuments; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedMidEventHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedMidEventHandler.java deleted file mode 100644 index d8b519c04f..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedMidEventHandler.java +++ /dev/null @@ -1,91 +0,0 @@ -package uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments; - -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; -import org.springframework.stereotype.Service; -import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; -import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; -import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackHandler; -import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackRequest; -import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; -import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Service -@Slf4j -public class UploadGeneralDocumentsContestedMidEventHandler extends FinremCallbackHandler { - - private final DocumentCheckerService documentCheckerService; - - public UploadGeneralDocumentsContestedMidEventHandler(FinremCaseDetailsMapper finremCaseDetailsMapper, - DocumentCheckerService documentCheckerService) { - super(finremCaseDetailsMapper); - this.documentCheckerService = documentCheckerService; - } - - @Override - public boolean canHandle(CallbackType callbackType, CaseType caseType, EventType eventType) { - return CallbackType.MID_EVENT.equals(callbackType) - && CaseType.CONTESTED.equals(caseType) - && EventType.UPLOAD_GENERAL_DOCUMENT.equals(eventType); - } - - @Override - public GenericAboutToStartOrSubmitCallbackResponse handle( - FinremCallbackRequest callbackRequestWithFinremCaseDetails, String userAuthorisation) { - - log.info("Mid-event Upload document callback for case {}", - callbackRequestWithFinremCaseDetails.getCaseDetails().getId()); - - FinremCaseData caseData = callbackRequestWithFinremCaseDetails.getCaseDetails().getData(); - - List warnings = new ArrayList<>(); - - List newDocuments = getNewlyUploadedDocuments( - callbackRequestWithFinremCaseDetails.getCaseDetails().getData().getUploadGeneralDocuments(), - callbackRequestWithFinremCaseDetails.getCaseDetailsBefore().getData().getUploadGeneralDocuments()); - if (ObjectUtils.isNotEmpty(newDocuments)) { - newDocuments.forEach(d -> { - List documentWarnings = documentCheckerService.getWarnings(d.getValue().getDocumentLink(), - callbackRequestWithFinremCaseDetails.getCaseDetails(), userAuthorisation); - warnings.addAll(documentWarnings); - }); - } - - return GenericAboutToStartOrSubmitCallbackResponse.builder() - .warnings(warnings) - .data(caseData) - .build(); - } - - private List getNewlyUploadedDocuments( - List uploadedDocuments, - List previousDocuments) { - - if (ObjectUtils.isEmpty(uploadedDocuments)) { - return Collections.emptyList(); - } else if (ObjectUtils.isEmpty(previousDocuments)) { - return uploadedDocuments; - } - - List newlyUploadedDocuments = new ArrayList<>(); - uploadedDocuments.forEach(d -> { - boolean exists = previousDocuments.stream() - .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); - if (!exists) { - newlyUploadedDocuments.add(d); - } - }); - - return newlyUploadedDocuments; - } - - -} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsContestedAboutToSubmitHandlerTest.java similarity index 86% rename from src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java rename to src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsContestedAboutToSubmitHandlerTest.java index 44c56a70ff..700b1794c5 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsContestedAboutToSubmitHandlerTest.java @@ -8,6 +8,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; +import uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments.UploadGeneralDocumentsContestedAboutToSubmitHandler; import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadedGeneralDocumentService; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; @@ -20,6 +21,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.UploadCaseDocumentWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentcatergory.UploadGeneralDocumentsCategoriser; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; import java.time.LocalDate; import java.util.ArrayList; @@ -29,7 +31,7 @@ import static org.hamcrest.Matchers.is; @RunWith(MockitoJUnitRunner.class) -public class UploadGeneralDocumentsAboutToSubmitHandlerTest { +public class UploadGeneralDocumentsContestedAboutToSubmitHandlerTest { public static final String AUTH_TOKEN = "tokien:)"; public static final String CASE_ID = "1234567890"; @@ -39,8 +41,10 @@ public class UploadGeneralDocumentsAboutToSubmitHandlerTest { private FinremCaseData caseData; ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); @Mock + private DocumentCheckerService documentCheckerService; + @Mock private UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser; - private UploadGeneralDocumentsAboutToSubmitHandler uploadGeneralDocumentsAboutToSubmitHandler; + private UploadGeneralDocumentsContestedAboutToSubmitHandler uploadGeneralDocumentsContestedAboutToSubmitHandler; private final List uploadDocumentList = new ArrayList<>(); private final List existingDocumentList = new ArrayList<>(); @@ -57,21 +61,21 @@ public void setUpTest() { FinremCaseDetailsMapper finremCaseDetailsMapper = new FinremCaseDetailsMapper(objectMapper); uploadedGeneralDocumentHelper = new UploadedGeneralDocumentService(objectMapper); - uploadGeneralDocumentsAboutToSubmitHandler = - new UploadGeneralDocumentsAboutToSubmitHandler(finremCaseDetailsMapper, + uploadGeneralDocumentsContestedAboutToSubmitHandler = + new UploadGeneralDocumentsContestedAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, uploadedGeneralDocumentHelper, uploadGeneralDocumentsCategoriser); } @Test public void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { - assertThat(uploadGeneralDocumentsAboutToSubmitHandler + assertThat(uploadGeneralDocumentsContestedAboutToSubmitHandler .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_GENERAL_DOCUMENT), is(true)); } @Test public void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { - assertThat(uploadGeneralDocumentsAboutToSubmitHandler + assertThat(uploadGeneralDocumentsContestedAboutToSubmitHandler .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_GENERAL_DOCUMENT), is(true)); } @@ -98,7 +102,7 @@ public void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectio expectedDocumentIdList.add(newDoc); expectedDocumentIdList.add(oldDoc); - handledDocumentIdList.addAll(uploadGeneralDocumentsAboutToSubmitHandler.handle( + handledDocumentIdList.addAll(uploadGeneralDocumentsContestedAboutToSubmitHandler.handle( FinremCallbackRequest.builder().caseDetails(caseDetails).caseDetailsBefore(caseDetailsBefore).build(), AUTH_TOKEN).getData().getUploadGeneralDocuments()); From 04367de67eda6369c1537f7d5d83c85c91ba3e6f Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 10 Jun 2024 17:52:44 +0100 Subject: [PATCH 04/96] Fine tuning --- ...ocumentsContestedAboutToSubmitHandler.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java index f520066281..7151a5e23c 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java @@ -1,7 +1,6 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; @@ -12,6 +11,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentcatergory.UploadGeneralDocumentsCategoriser; @@ -24,6 +24,7 @@ import static java.util.Comparator.comparing; import static java.util.Comparator.nullsLast; +import static org.apache.commons.lang3.ObjectUtils.isEmpty; @Slf4j @Service @@ -54,22 +55,21 @@ public boolean canHandle(CallbackType callbackType, CaseType caseType, EventType @SuppressWarnings("squid:CallToDeprecatedMethod") public GenericAboutToStartOrSubmitCallbackResponse handle(FinremCallbackRequest callbackRequest, String userAuthorisation) { + FinremCaseDetails finremCaseDetails = callbackRequest.getCaseDetails(); + FinremCaseData caseData = finremCaseDetails.getData(); + FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); - FinremCaseData caseData = callbackRequest.getCaseDetails().getData(); uploadedGeneralDocumentHelper.addUploadDateToNewDocuments( caseData, callbackRequest.getCaseDetailsBefore().getData()); - List warnings = new ArrayList<>(); - List newDocuments = getNewlyUploadedDocuments( - callbackRequest.getCaseDetails().getData().getUploadGeneralDocuments(), - callbackRequest.getCaseDetailsBefore().getData().getUploadGeneralDocuments()); - if (ObjectUtils.isNotEmpty(newDocuments)) { - newDocuments.forEach(d -> { - List documentWarnings = documentCheckerService.getWarnings(d.getValue().getDocumentLink(), - callbackRequest.getCaseDetails(), userAuthorisation); - warnings.addAll(documentWarnings); - }); + final List warnings = getNewlyUploadedDocuments(caseData, caseDataBefore).stream() + .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) + .flatMap(List::stream) + .toList(); + if (!warnings.isEmpty()) { + log.info("Number of warnings encountered when uploading general document for a case {}: {}", + finremCaseDetails.getId(), warnings.size()); } List uploadedDocuments = caseData.getUploadGeneralDocuments(); @@ -86,13 +86,13 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem .data(caseData).build(); } - private List getNewlyUploadedDocuments( - List uploadedDocuments, - List previousDocuments) { + private List getNewlyUploadedDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { + List uploadedDocuments = caseData.getUploadGeneralDocuments(); + List previousDocuments = caseDataBefore.getUploadGeneralDocuments(); - if (ObjectUtils.isEmpty(uploadedDocuments)) { + if (isEmpty(uploadedDocuments)) { return Collections.emptyList(); - } else if (ObjectUtils.isEmpty(previousDocuments)) { + } else if (isEmpty(previousDocuments)) { return uploadedDocuments; } From cdad066227918547a04b70ab09cc703d4f345b57 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 11 Jun 2024 10:02:45 +0100 Subject: [PATCH 05/96] Test case for UploadGeneralDocumentService --- ...ocumentsContestedAboutToSubmitHandler.java | 27 +------ .../UploadedGeneralDocumentService.java | 34 +++++++- .../model/ccd/FinremCaseData.java | 3 +- .../UploadedGeneralDocumentServiceTest.java | 78 +++++++++++++++++++ 4 files changed, 113 insertions(+), 29 deletions(-) create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java index 7151a5e23c..ba4878d79d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java @@ -17,14 +17,11 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentcatergory.UploadGeneralDocumentsCategoriser; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; -import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.List; import static java.util.Comparator.comparing; import static java.util.Comparator.nullsLast; -import static org.apache.commons.lang3.ObjectUtils.isEmpty; @Slf4j @Service @@ -63,7 +60,7 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem caseData, callbackRequest.getCaseDetailsBefore().getData()); - final List warnings = getNewlyUploadedDocuments(caseData, caseDataBefore).stream() + final List warnings = uploadedGeneralDocumentHelper.getNewlyUploadedDocuments(caseData, caseDataBefore).stream() .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) .flatMap(List::stream) .toList(); @@ -86,26 +83,4 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem .data(caseData).build(); } - private List getNewlyUploadedDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { - List uploadedDocuments = caseData.getUploadGeneralDocuments(); - List previousDocuments = caseDataBefore.getUploadGeneralDocuments(); - - if (isEmpty(uploadedDocuments)) { - return Collections.emptyList(); - } else if (isEmpty(previousDocuments)) { - return uploadedDocuments; - } - - List newlyUploadedDocuments = new ArrayList<>(); - uploadedDocuments.forEach(d -> { - boolean exists = previousDocuments.stream() - .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); - if (!exists) { - newlyUploadedDocuments.add(d); - } - }); - - return newlyUploadedDocuments; - } - } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedGeneralDocumentService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedGeneralDocumentService.java index 53a58a4bb7..2f8b08094b 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedGeneralDocumentService.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedGeneralDocumentService.java @@ -1,14 +1,44 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.helper; import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralUploadedDocumentData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadService; -@Component +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.apache.commons.lang3.ObjectUtils.isEmpty; + +@Service public class UploadedGeneralDocumentService extends DocumentUploadService { public UploadedGeneralDocumentService(ObjectMapper objectMapper) { super(objectMapper, GeneralUploadedDocumentData.class); } + + public List getNewlyUploadedDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { + List uploadedDocuments = caseData.getUploadGeneralDocuments(); + List previousDocuments = caseDataBefore.getUploadGeneralDocuments(); + + if (isEmpty(uploadedDocuments)) { + return Collections.emptyList(); + } else if (isEmpty(previousDocuments)) { + return uploadedDocuments; + } + + List newlyUploadedDocuments = new ArrayList<>(); + uploadedDocuments.forEach(d -> { + boolean exists = previousDocuments.stream() + .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); + if (!exists) { + newlyUploadedDocuments.add(d); + } + }); + + return newlyUploadedDocuments; + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/FinremCaseData.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/FinremCaseData.java index 804a506d78..1bdab55d18 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/FinremCaseData.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/FinremCaseData.java @@ -14,6 +14,7 @@ import lombok.Data; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; import org.apache.commons.lang3.StringUtils; import uk.gov.hmcts.reform.bsp.common.model.document.Addressee; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.AllocatedRegionWrapper; @@ -55,7 +56,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_EMPTY) @Data -@Builder +@SuperBuilder(toBuilder = true) @AllArgsConstructor @NoArgsConstructor public class FinremCaseData { diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java new file mode 100644 index 0000000000..dd3ebb7719 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java @@ -0,0 +1,78 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service; + +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import uk.gov.hmcts.reform.finrem.caseorchestration.BaseServiceTest; +import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadedGeneralDocumentService; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; + +import java.util.List; +import java.util.stream.Stream; + +import static org.junit.Assert.assertEquals; + +public class UploadedGeneralDocumentServiceTest extends BaseServiceTest { + + @Autowired + private UploadedGeneralDocumentService uploadedGeneralDocumentService; + + @Test + public void givenContestedCaseWithExistingGeneralDocument_whenNewGeneralDocumentUploaded_thenReturnNewGeneralDocument() { + final List existingGeneralDocument = List.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(buildCaseDocument("url1", "binaryUrl1", "filename1")) + .build()) + .build() + ); + + FinremCaseData caseDataBefore = FinremCaseData.builder() + .uploadGeneralDocuments(existingGeneralDocument) + .build(); + FinremCaseData caseData = caseDataBefore.toBuilder() + .uploadGeneralDocuments(Stream.concat(existingGeneralDocument.stream(), Stream.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) + .build()) + .build() + )).toList()) + .build(); + + List actual = uploadedGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); + List expected = List.of(UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) + .build()) + .build()); + + assertEquals(expected, actual); + } + + @Test + public void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentUploaded_thenReturnNewGeneralDocument() { + FinremCaseData caseDataBefore = FinremCaseData.builder() + .uploadGeneralDocuments(List.of()) + .build(); + FinremCaseData caseData = caseDataBefore.toBuilder() + .uploadGeneralDocuments(List.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) + .build()) + .build() + )) + .build(); + + List actual = uploadedGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); + List expected = List.of(UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) + .build()) + .build()); + + assertEquals(expected, actual); + } +} \ No newline at end of file From 49d1d2eb0726f3d3bfc07250932da4893f0b8832 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 11 Jun 2024 14:14:36 +0100 Subject: [PATCH 06/96] add one more test case and enable @ParameterizedTest --- .../UploadedGeneralDocumentServiceTest.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java index dd3ebb7719..e2e1f4292f 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java @@ -1,7 +1,11 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service; import org.junit.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.NullAndEmptySource; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.hmcts.reform.finrem.caseorchestration.BaseServiceTest; import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadedGeneralDocumentService; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; @@ -13,7 +17,8 @@ import static org.junit.Assert.assertEquals; -public class UploadedGeneralDocumentServiceTest extends BaseServiceTest { +@ExtendWith(SpringExtension.class) +class UploadedGeneralDocumentServiceTest extends BaseServiceTest { @Autowired private UploadedGeneralDocumentService uploadedGeneralDocumentService; @@ -51,10 +56,12 @@ public void givenContestedCaseWithExistingGeneralDocument_whenNewGeneralDocument assertEquals(expected, actual); } - @Test - public void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentUploaded_thenReturnNewGeneralDocument() { + @ParameterizedTest + @NullAndEmptySource + void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentUploaded_thenReturnNewGeneralDocument( + List existing) { FinremCaseData caseDataBefore = FinremCaseData.builder() - .uploadGeneralDocuments(List.of()) + .uploadGeneralDocuments(existing) .build(); FinremCaseData caseData = caseDataBefore.toBuilder() .uploadGeneralDocuments(List.of( @@ -75,4 +82,4 @@ public void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocum assertEquals(expected, actual); } -} \ No newline at end of file +} From 227e1f4e5fe4460524544ad98e137c8868e8f9b1 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 11 Jun 2024 14:45:39 +0100 Subject: [PATCH 07/96] add a test that no new document uploaded. --- .../UploadedGeneralDocumentServiceTest.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java index e2e1f4292f..49bd776fd6 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java @@ -1,6 +1,6 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.NullAndEmptySource; @@ -24,7 +24,7 @@ class UploadedGeneralDocumentServiceTest extends BaseServiceTest { private UploadedGeneralDocumentService uploadedGeneralDocumentService; @Test - public void givenContestedCaseWithExistingGeneralDocument_whenNewGeneralDocumentUploaded_thenReturnNewGeneralDocument() { + void givenContestedCaseWithExistingGeneralDocument_whenNewGeneralDocumentUploaded_thenReturnNewGeneralDocument() { final List existingGeneralDocument = List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() @@ -56,6 +56,29 @@ public void givenContestedCaseWithExistingGeneralDocument_whenNewGeneralDocument assertEquals(expected, actual); } + @Test + void givenContestedCaseWithExistingGeneralDocument_whenNoNewGeneralDocumentUploaded_thenReturnAnEmptyList() { + final List existingGeneralDocument = List.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(buildCaseDocument("url1", "binaryUrl1", "filename1")) + .build()) + .build() + ); + + FinremCaseData caseDataBefore = FinremCaseData.builder() + .uploadGeneralDocuments(existingGeneralDocument) + .build(); + FinremCaseData caseData = caseDataBefore.toBuilder() + .uploadGeneralDocuments(existingGeneralDocument) + .build(); + + List actual = uploadedGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); + List expected = List.of(); + + assertEquals(expected, actual); + } + @ParameterizedTest @NullAndEmptySource void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentUploaded_thenReturnNewGeneralDocument( From 5277377443c1a25b5711ab81487954be009caa60 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 11 Jun 2024 14:49:20 +0100 Subject: [PATCH 08/96] test case for multiple upload documents --- .../UploadedGeneralDocumentServiceTest.java | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java index 49bd776fd6..20dc9a35e6 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java @@ -90,7 +90,7 @@ void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentUplo .uploadGeneralDocuments(List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) + .documentLink(buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) .build()) .build() )) @@ -99,10 +99,48 @@ void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentUplo List actual = uploadedGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); List expected = List.of(UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) + .documentLink(buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) .build()) .build()); assertEquals(expected, actual); } + + @ParameterizedTest + @NullAndEmptySource + void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentsUploaded_thenReturnMultipleNewGeneralDocument( + List existing) { + FinremCaseData caseDataBefore = FinremCaseData.builder() + .uploadGeneralDocuments(existing) + .build(); + FinremCaseData caseData = caseDataBefore.toBuilder() + .uploadGeneralDocuments(List.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .build()) + .build(), + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(buildCaseDocument("newUrl2", "newBinaryUrl2", "newFilename2")) + .build()) + .build() + )) + .build(); + + List actual = uploadedGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); + List expected = List.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .build()) + .build(), + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(buildCaseDocument("newUrl2", "newBinaryUrl2", "newFilename2")) + .build()) + .build()); + + assertEquals(expected, actual); + } } From 77f5491e05e2c27c2c1327950e988ce0297e1eb5 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 12 Jun 2024 11:29:00 +0100 Subject: [PATCH 09/96] Bug fix --- .../UploadGeneralDocumentsContestedAboutToSubmitHandler.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java index ba4878d79d..d211b872a9 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; @@ -63,6 +64,7 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem final List warnings = uploadedGeneralDocumentHelper.getNewlyUploadedDocuments(caseData, caseDataBefore).stream() .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) .flatMap(List::stream) + .filter(ObjectUtils::isNotEmpty) .toList(); if (!warnings.isEmpty()) { log.info("Number of warnings encountered when uploading general document for a case {}: {}", From fd33f0d5bf1dfadcec942e0b12a596d781935718 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 12 Jun 2024 11:49:10 +0100 Subject: [PATCH 10/96] Fix test case --- ...cumentsContestedAboutToSubmitHandlerTest.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsContestedAboutToSubmitHandlerTest.java index 700b1794c5..faf20dd968 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsContestedAboutToSubmitHandlerTest.java @@ -33,12 +33,11 @@ @RunWith(MockitoJUnitRunner.class) public class UploadGeneralDocumentsContestedAboutToSubmitHandlerTest { - public static final String AUTH_TOKEN = "tokien:)"; + public static final String AUTH_TOKEN = "token:)"; public static final String CASE_ID = "1234567890"; private FinremCaseDetails caseDetails; private FinremCaseDetails caseDetailsBefore; - private FinremCaseData caseData; ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); @Mock private DocumentCheckerService documentCheckerService; @@ -51,19 +50,15 @@ public class UploadGeneralDocumentsContestedAboutToSubmitHandlerTest { private final List expectedDocumentIdList = new ArrayList<>(); List handledDocumentIdList = new ArrayList<>(); - private UploadedGeneralDocumentService uploadedGeneralDocumentHelper; - @Before public void setUpTest() { caseDetails = buildCaseDetails(); caseDetailsBefore = buildCaseDetails(); - caseData = caseDetails.getData(); FinremCaseDetailsMapper finremCaseDetailsMapper = new FinremCaseDetailsMapper(objectMapper); - uploadedGeneralDocumentHelper = new UploadedGeneralDocumentService(objectMapper); uploadGeneralDocumentsContestedAboutToSubmitHandler = new UploadGeneralDocumentsContestedAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, - uploadedGeneralDocumentHelper, uploadGeneralDocumentsCategoriser); + new UploadedGeneralDocumentService(objectMapper), uploadGeneralDocumentsCategoriser); } @Test @@ -73,13 +68,6 @@ public void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadGeneral is(true)); } - @Test - public void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { - assertThat(uploadGeneralDocumentsContestedAboutToSubmitHandler - .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_GENERAL_DOCUMENT), - is(true)); - } - @Test public void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectionByDate() { From 56ab9160f927d4cefdcfb3096ca842b747d0372c Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 12 Jun 2024 16:36:57 +0100 Subject: [PATCH 11/96] rollback (+1 squashed commit) Squashed commits: [bc0c5f5c7] TEMP --- ...GeneralDocumentsAboutToSubmitHandler.java} | 26 ++++---- ...ocumentsConsentedAboutToSubmitHandler.java | 65 +++++++++++++++++++ .../helper/UploadedDocumentService.java | 45 +++++++++++++ .../UploadedGeneralDocumentService.java | 34 +--------- .../caseorchestration/model/EventType.java | 1 + .../service/DocumentUploadService.java | 9 ++- ...ralDocumentsAboutToSubmitHandlerTest.java} | 18 ++--- ... => UploadGeneralDocumentServiceTest.java} | 14 ++-- 8 files changed, 145 insertions(+), 67 deletions(-) rename src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/{UploadGeneralDocumentsContestedAboutToSubmitHandler.java => UploadGeneralDocumentsAboutToSubmitHandler.java} (77%) create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsConsentedAboutToSubmitHandler.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedDocumentService.java rename src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/{UploadGeneralDocumentsContestedAboutToSubmitHandlerTest.java => UploadGeneralDocumentsAboutToSubmitHandlerTest.java} (88%) rename src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/{UploadedGeneralDocumentServiceTest.java => UploadGeneralDocumentServiceTest.java} (89%) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsAboutToSubmitHandler.java similarity index 77% rename from src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java rename to src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsAboutToSubmitHandler.java index d211b872a9..920d6b676e 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsContestedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsAboutToSubmitHandler.java @@ -7,7 +7,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackHandler; import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackRequest; -import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadedGeneralDocumentService; +import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadGeneralDocumentService; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; @@ -26,19 +26,19 @@ @Slf4j @Service -public class UploadGeneralDocumentsContestedAboutToSubmitHandler extends FinremCallbackHandler { +public class UploadGeneralDocumentsAboutToSubmitHandler extends FinremCallbackHandler { private final DocumentCheckerService documentCheckerService; - private final UploadedGeneralDocumentService uploadedGeneralDocumentHelper; + private final UploadGeneralDocumentService uploadGeneralDocumentService; private final UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser; - public UploadGeneralDocumentsContestedAboutToSubmitHandler(FinremCaseDetailsMapper mapper, - DocumentCheckerService documentCheckerService, - UploadedGeneralDocumentService uploadedGeneralDocumentHelper, - UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser) { + public UploadGeneralDocumentsAboutToSubmitHandler(FinremCaseDetailsMapper mapper, + DocumentCheckerService documentCheckerService, + UploadGeneralDocumentService uploadGeneralDocumentService, + UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser) { super(mapper); this.documentCheckerService = documentCheckerService; - this.uploadedGeneralDocumentHelper = uploadedGeneralDocumentHelper; + this.uploadGeneralDocumentService = uploadGeneralDocumentService; this.uploadGeneralDocumentsCategoriser = uploadGeneralDocumentsCategoriser; } @@ -57,11 +57,9 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); - uploadedGeneralDocumentHelper.addUploadDateToNewDocuments( - caseData, - callbackRequest.getCaseDetailsBefore().getData()); + uploadGeneralDocumentService.addUploadDateToNewDocuments(caseData, caseDataBefore); - final List warnings = uploadedGeneralDocumentHelper.getNewlyUploadedDocuments(caseData, caseDataBefore).stream() + final List warnings = uploadGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore).stream() .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) .flatMap(List::stream) .filter(ObjectUtils::isNotEmpty) @@ -81,8 +79,8 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem uploadGeneralDocumentsCategoriser.categorise(caseData); return GenericAboutToStartOrSubmitCallbackResponse.builder() - .warnings(warnings) - .data(caseData).build(); + .warnings(warnings) + .data(caseData).build(); } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsConsentedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsConsentedAboutToSubmitHandler.java new file mode 100644 index 0000000000..dd069e598c --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsConsentedAboutToSubmitHandler.java @@ -0,0 +1,65 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; +import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; +import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackHandler; +import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackRequest; +import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; + +@Slf4j +@Service +public class UploadGeneralDocumentsConsentedAboutToSubmitHandler extends FinremCallbackHandler { + + private final DocumentCheckerService documentCheckerService; +// private final UploadGeneralDocumentService uploadGeneralDocumentService; + + public UploadGeneralDocumentsConsentedAboutToSubmitHandler(FinremCaseDetailsMapper mapper, + DocumentCheckerService documentCheckerService +// , +// UploadGeneralDocumentService uploadGeneralDocumentService + ) { + super(mapper); + this.documentCheckerService = documentCheckerService; +// this.uploadGeneralDocumentService = uploadGeneralDocumentService; + } + + @Override + public boolean canHandle(CallbackType callbackType, CaseType caseType, EventType eventType) { + return CallbackType.ABOUT_TO_SUBMIT.equals(callbackType) + && CaseType.CONSENTED.equals(caseType) + && EventType.UPLOAD_GENERAL_DOCUMENT_CONSENTED.equals(eventType); + } + + @Override + @SuppressWarnings("squid:CallToDeprecatedMethod") + public GenericAboutToStartOrSubmitCallbackResponse handle(FinremCallbackRequest callbackRequest, + String userAuthorisation) { + FinremCaseDetails finremCaseDetails = callbackRequest.getCaseDetails(); + FinremCaseData caseData = finremCaseDetails.getData(); + FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); + +// final List warnings = uploadGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore).stream() +// .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) +// .flatMap(List::stream) +// .filter(ObjectUtils::isNotEmpty) +// .toList(); +// if (!warnings.isEmpty()) { +// log.info("Number of warnings encountered when uploading general document for a case {}: {}", +// finremCaseDetails.getId(), warnings.size()); +// } +// +// List uploadedDocuments = caseData.getUploadGeneralDocuments(); + + return GenericAboutToStartOrSubmitCallbackResponse.builder() +// .warnings(warnings) + .data(caseData).build(); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedDocumentService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedDocumentService.java new file mode 100644 index 0000000000..85a5750c7b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedDocumentService.java @@ -0,0 +1,45 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.helper; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralUploadedDocumentData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadService; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.apache.commons.lang3.ObjectUtils.isEmpty; + +@Service +public class UploadedDocumentService extends DocumentUploadService { + + public UploadedDocumentService(ObjectMapper objectMapper) { + super(objectMapper, GeneralUploadedDocumentData.class); + } + + public List getNewlyUploadedDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { + List uploadedDocuments = caseData.getUploadDocuments(); + List previousDocuments = caseDataBefore.getUploadDocuments(); + + if (isEmpty(uploadedDocuments)) { + return Collections.emptyList(); + } else if (isEmpty(previousDocuments)) { + return uploadedDocuments; + } + + List newlyUploadedDocuments = new ArrayList<>(); + uploadedDocuments.forEach(d -> { + boolean exists = previousDocuments.stream() + .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); + if (!exists) { + newlyUploadedDocuments.add(d); + } + }); + + return newlyUploadedDocuments; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedGeneralDocumentService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedGeneralDocumentService.java index 2f8b08094b..53a58a4bb7 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedGeneralDocumentService.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedGeneralDocumentService.java @@ -1,44 +1,14 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.helper; import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.stereotype.Service; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralUploadedDocumentData; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadService; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import static org.apache.commons.lang3.ObjectUtils.isEmpty; - -@Service +@Component public class UploadedGeneralDocumentService extends DocumentUploadService { public UploadedGeneralDocumentService(ObjectMapper objectMapper) { super(objectMapper, GeneralUploadedDocumentData.class); } - - public List getNewlyUploadedDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { - List uploadedDocuments = caseData.getUploadGeneralDocuments(); - List previousDocuments = caseDataBefore.getUploadGeneralDocuments(); - - if (isEmpty(uploadedDocuments)) { - return Collections.emptyList(); - } else if (isEmpty(previousDocuments)) { - return uploadedDocuments; - } - - List newlyUploadedDocuments = new ArrayList<>(); - uploadedDocuments.forEach(d -> { - boolean exists = previousDocuments.stream() - .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); - if (!exists) { - newlyUploadedDocuments.add(d); - } - }); - - return newlyUploadedDocuments; - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/EventType.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/EventType.java index 2dd3e9cc68..87e5403ccb 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/EventType.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/EventType.java @@ -15,6 +15,7 @@ public enum EventType { PREPARE_FOR_HEARING("FR_prepareForHearing"), UPLOAD_CASE_FILES("FR_uploadCaseFiles"), UPLOAD_CONFIDENTIAL_DOCUMENT("FR_uploadConfidentialDocument"), + UPLOAD_GENERAL_DOCUMENT_CONSENTED("FR_uploadDocument"), UPLOAD_GENERAL_DOCUMENT("FR_uploadGeneralDocument"), INTERIM_HEARING("FR_listForInterimHearing"), SOLICITOR_CREATE("FR_solicitorCreate"), diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadService.java index c115049674..40b0a16b23 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadService.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadService.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import uk.gov.hmcts.reform.finrem.caseorchestration.model.CaseDocumentTabData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadCaseDocumentCollection; import java.time.LocalDateTime; import java.util.ArrayList; @@ -45,14 +46,12 @@ public Map addUploadDateToNewDocuments(Map caseD } public void addUploadDateToNewDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { - List allDocuments = (List) caseData.getUploadCaseDocumentWrapper().getAllManageableCollections(); - List documentsBeforeEvent = (List) caseDataBefore.getUploadCaseDocumentWrapper().getAllManageableCollections(); + List allDocuments = caseData.getUploadCaseDocumentWrapper().getAllManageableCollections(); + List documentsBeforeEvent = caseDataBefore.getUploadCaseDocumentWrapper().getAllManageableCollections(); - allDocuments.stream().forEach(document -> addDateToNewDocuments(documentsBeforeEvent, document)); + allDocuments.forEach(document -> addDateToNewDocuments((List) documentsBeforeEvent, (T) document)); } - - private void addDateToNewDocuments(List documentsBeforeEvent, T document) { if (isNewDocument.test(document.getElementId(), documentsBeforeEvent)) { document.setUploadDateTime(LocalDateTime.now()); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java similarity index 88% rename from src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsContestedAboutToSubmitHandlerTest.java rename to src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java index faf20dd968..fab0759820 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java @@ -8,8 +8,8 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; -import uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments.UploadGeneralDocumentsContestedAboutToSubmitHandler; -import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadedGeneralDocumentService; +import uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments.UploadGeneralDocumentsAboutToSubmitHandler; +import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadGeneralDocumentService; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; @@ -31,7 +31,7 @@ import static org.hamcrest.Matchers.is; @RunWith(MockitoJUnitRunner.class) -public class UploadGeneralDocumentsContestedAboutToSubmitHandlerTest { +public class UploadGeneralDocumentsAboutToSubmitHandlerTest { public static final String AUTH_TOKEN = "token:)"; public static final String CASE_ID = "1234567890"; @@ -43,7 +43,7 @@ public class UploadGeneralDocumentsContestedAboutToSubmitHandlerTest { private DocumentCheckerService documentCheckerService; @Mock private UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser; - private UploadGeneralDocumentsContestedAboutToSubmitHandler uploadGeneralDocumentsContestedAboutToSubmitHandler; + private UploadGeneralDocumentsAboutToSubmitHandler uploadGeneralDocumentsAboutToSubmitHandler; private final List uploadDocumentList = new ArrayList<>(); private final List existingDocumentList = new ArrayList<>(); @@ -56,14 +56,14 @@ public void setUpTest() { caseDetailsBefore = buildCaseDetails(); FinremCaseDetailsMapper finremCaseDetailsMapper = new FinremCaseDetailsMapper(objectMapper); - uploadGeneralDocumentsContestedAboutToSubmitHandler = - new UploadGeneralDocumentsContestedAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, - new UploadedGeneralDocumentService(objectMapper), uploadGeneralDocumentsCategoriser); + uploadGeneralDocumentsAboutToSubmitHandler = + new UploadGeneralDocumentsAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, + new UploadGeneralDocumentService(), uploadGeneralDocumentsCategoriser); } @Test public void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { - assertThat(uploadGeneralDocumentsContestedAboutToSubmitHandler + assertThat(uploadGeneralDocumentsAboutToSubmitHandler .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_GENERAL_DOCUMENT), is(true)); } @@ -90,7 +90,7 @@ public void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectio expectedDocumentIdList.add(newDoc); expectedDocumentIdList.add(oldDoc); - handledDocumentIdList.addAll(uploadGeneralDocumentsContestedAboutToSubmitHandler.handle( + handledDocumentIdList.addAll(uploadGeneralDocumentsAboutToSubmitHandler.handle( FinremCallbackRequest.builder().caseDetails(caseDetails).caseDetailsBefore(caseDetailsBefore).build(), AUTH_TOKEN).getData().getUploadGeneralDocuments()); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadGeneralDocumentServiceTest.java similarity index 89% rename from src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java rename to src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadGeneralDocumentServiceTest.java index 20dc9a35e6..f404242b24 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadedGeneralDocumentServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadGeneralDocumentServiceTest.java @@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.hmcts.reform.finrem.caseorchestration.BaseServiceTest; -import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadedGeneralDocumentService; +import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadGeneralDocumentService; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; @@ -18,10 +18,10 @@ import static org.junit.Assert.assertEquals; @ExtendWith(SpringExtension.class) -class UploadedGeneralDocumentServiceTest extends BaseServiceTest { +class UploadGeneralDocumentServiceTest extends BaseServiceTest { @Autowired - private UploadedGeneralDocumentService uploadedGeneralDocumentService; + private UploadGeneralDocumentService uploadGeneralDocumentService; @Test void givenContestedCaseWithExistingGeneralDocument_whenNewGeneralDocumentUploaded_thenReturnNewGeneralDocument() { @@ -46,7 +46,7 @@ void givenContestedCaseWithExistingGeneralDocument_whenNewGeneralDocumentUploade )).toList()) .build(); - List actual = uploadedGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); + List actual = uploadGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); List expected = List.of(UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() .documentLink(buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) @@ -73,7 +73,7 @@ void givenContestedCaseWithExistingGeneralDocument_whenNoNewGeneralDocumentUploa .uploadGeneralDocuments(existingGeneralDocument) .build(); - List actual = uploadedGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); + List actual = uploadGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); List expected = List.of(); assertEquals(expected, actual); @@ -96,7 +96,7 @@ void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentUplo )) .build(); - List actual = uploadedGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); + List actual = uploadGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); List expected = List.of(UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() .documentLink(buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) @@ -128,7 +128,7 @@ void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentsUpl )) .build(); - List actual = uploadedGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); + List actual = uploadGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); List expected = List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() From ebedf0f97129877924f5212362e696dd01587991 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 12 Jun 2024 17:36:45 +0100 Subject: [PATCH 12/96] introduced DocumentUploadServiceV2 --- ...dGeneralDocumentsAboutToSubmitHandler.java | 13 ++-- ...ocumentsConsentedAboutToSubmitHandler.java | 65 ------------------- .../helper/UploadedDocumentService.java | 45 ------------- .../service/DocumentUploadServiceV2.java | 37 +++++++++++ ...eralDocumentsAboutToSubmitHandlerTest.java | 4 +- ....java => DocumentUploadServiceV2Test.java} | 13 ++-- 6 files changed, 52 insertions(+), 125 deletions(-) delete mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsConsentedAboutToSubmitHandler.java delete mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedDocumentService.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java rename src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/{UploadGeneralDocumentServiceTest.java => DocumentUploadServiceV2Test.java} (88%) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsAboutToSubmitHandler.java index 920d6b676e..b07772f62e 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsAboutToSubmitHandler.java @@ -7,7 +7,6 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackHandler; import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackRequest; -import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadGeneralDocumentService; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; @@ -15,6 +14,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadServiceV2; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentcatergory.UploadGeneralDocumentsCategoriser; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; @@ -29,16 +29,16 @@ public class UploadGeneralDocumentsAboutToSubmitHandler extends FinremCallbackHandler { private final DocumentCheckerService documentCheckerService; - private final UploadGeneralDocumentService uploadGeneralDocumentService; + private final DocumentUploadServiceV2 documentUploadService; private final UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser; public UploadGeneralDocumentsAboutToSubmitHandler(FinremCaseDetailsMapper mapper, DocumentCheckerService documentCheckerService, - UploadGeneralDocumentService uploadGeneralDocumentService, + DocumentUploadServiceV2 documentUploadService, UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser) { super(mapper); this.documentCheckerService = documentCheckerService; - this.uploadGeneralDocumentService = uploadGeneralDocumentService; + this.documentUploadService = documentUploadService; this.uploadGeneralDocumentsCategoriser = uploadGeneralDocumentsCategoriser; } @@ -57,9 +57,10 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); - uploadGeneralDocumentService.addUploadDateToNewDocuments(caseData, caseDataBefore); + // TODO setting upload date to new uploaded general documents + // uploadGeneralDocumentService.addUploadDateToNewDocuments(caseData, caseDataBefore) - final List warnings = uploadGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore).stream() + final List warnings = documentUploadService.getNewUploadGeneralDocuments(caseData, caseDataBefore).stream() .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) .flatMap(List::stream) .filter(ObjectUtils::isNotEmpty) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsConsentedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsConsentedAboutToSubmitHandler.java deleted file mode 100644 index dd069e598c..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsConsentedAboutToSubmitHandler.java +++ /dev/null @@ -1,65 +0,0 @@ -package uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; -import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; -import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackHandler; -import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackRequest; -import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; -import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; - -@Slf4j -@Service -public class UploadGeneralDocumentsConsentedAboutToSubmitHandler extends FinremCallbackHandler { - - private final DocumentCheckerService documentCheckerService; -// private final UploadGeneralDocumentService uploadGeneralDocumentService; - - public UploadGeneralDocumentsConsentedAboutToSubmitHandler(FinremCaseDetailsMapper mapper, - DocumentCheckerService documentCheckerService -// , -// UploadGeneralDocumentService uploadGeneralDocumentService - ) { - super(mapper); - this.documentCheckerService = documentCheckerService; -// this.uploadGeneralDocumentService = uploadGeneralDocumentService; - } - - @Override - public boolean canHandle(CallbackType callbackType, CaseType caseType, EventType eventType) { - return CallbackType.ABOUT_TO_SUBMIT.equals(callbackType) - && CaseType.CONSENTED.equals(caseType) - && EventType.UPLOAD_GENERAL_DOCUMENT_CONSENTED.equals(eventType); - } - - @Override - @SuppressWarnings("squid:CallToDeprecatedMethod") - public GenericAboutToStartOrSubmitCallbackResponse handle(FinremCallbackRequest callbackRequest, - String userAuthorisation) { - FinremCaseDetails finremCaseDetails = callbackRequest.getCaseDetails(); - FinremCaseData caseData = finremCaseDetails.getData(); - FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); - -// final List warnings = uploadGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore).stream() -// .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) -// .flatMap(List::stream) -// .filter(ObjectUtils::isNotEmpty) -// .toList(); -// if (!warnings.isEmpty()) { -// log.info("Number of warnings encountered when uploading general document for a case {}: {}", -// finremCaseDetails.getId(), warnings.size()); -// } -// -// List uploadedDocuments = caseData.getUploadGeneralDocuments(); - - return GenericAboutToStartOrSubmitCallbackResponse.builder() -// .warnings(warnings) - .data(caseData).build(); - } - -} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedDocumentService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedDocumentService.java deleted file mode 100644 index 85a5750c7b..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/helper/UploadedDocumentService.java +++ /dev/null @@ -1,45 +0,0 @@ -package uk.gov.hmcts.reform.finrem.caseorchestration.helper; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.stereotype.Service; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralUploadedDocumentData; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocumentCollection; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; -import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadService; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import static org.apache.commons.lang3.ObjectUtils.isEmpty; - -@Service -public class UploadedDocumentService extends DocumentUploadService { - - public UploadedDocumentService(ObjectMapper objectMapper) { - super(objectMapper, GeneralUploadedDocumentData.class); - } - - public List getNewlyUploadedDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { - List uploadedDocuments = caseData.getUploadDocuments(); - List previousDocuments = caseDataBefore.getUploadDocuments(); - - if (isEmpty(uploadedDocuments)) { - return Collections.emptyList(); - } else if (isEmpty(previousDocuments)) { - return uploadedDocuments; - } - - List newlyUploadedDocuments = new ArrayList<>(); - uploadedDocuments.forEach(d -> { - boolean exists = previousDocuments.stream() - .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); - if (!exists) { - newlyUploadedDocuments.add(d); - } - }); - - return newlyUploadedDocuments; - } -} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java new file mode 100644 index 0000000000..407950bafd --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java @@ -0,0 +1,37 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service; + + +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.apache.commons.lang3.ObjectUtils.isEmpty; + +@Service +public class DocumentUploadServiceV2 { + public List getNewUploadGeneralDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { + List uploadedDocuments = caseData.getUploadGeneralDocuments(); + List previousDocuments = caseDataBefore.getUploadGeneralDocuments(); + + if (isEmpty(uploadedDocuments)) { + return Collections.emptyList(); + } else if (isEmpty(previousDocuments)) { + return uploadedDocuments; + } + + List newlyUploadedDocuments = new ArrayList<>(); + uploadedDocuments.forEach(d -> { + boolean exists = previousDocuments.stream() + .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); + if (!exists) { + newlyUploadedDocuments.add(d); + } + }); + + return newlyUploadedDocuments; + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java index fab0759820..11285a70a0 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java @@ -9,7 +9,6 @@ import org.mockito.junit.MockitoJUnitRunner; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; import uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments.UploadGeneralDocumentsAboutToSubmitHandler; -import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadGeneralDocumentService; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; @@ -20,6 +19,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.UploadCaseDocumentWrapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadServiceV2; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentcatergory.UploadGeneralDocumentsCategoriser; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; @@ -58,7 +58,7 @@ public void setUpTest() { new FinremCaseDetailsMapper(objectMapper); uploadGeneralDocumentsAboutToSubmitHandler = new UploadGeneralDocumentsAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, - new UploadGeneralDocumentService(), uploadGeneralDocumentsCategoriser); + new DocumentUploadServiceV2(), uploadGeneralDocumentsCategoriser); } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadGeneralDocumentServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java similarity index 88% rename from src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadGeneralDocumentServiceTest.java rename to src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java index f404242b24..f7fa1d8af1 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/UploadGeneralDocumentServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java @@ -7,7 +7,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.hmcts.reform.finrem.caseorchestration.BaseServiceTest; -import uk.gov.hmcts.reform.finrem.caseorchestration.helper.UploadGeneralDocumentService; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; @@ -18,10 +17,10 @@ import static org.junit.Assert.assertEquals; @ExtendWith(SpringExtension.class) -class UploadGeneralDocumentServiceTest extends BaseServiceTest { +class DocumentUploadServiceV2Test extends BaseServiceTest { @Autowired - private UploadGeneralDocumentService uploadGeneralDocumentService; + private DocumentUploadServiceV2 documentUploadService; @Test void givenContestedCaseWithExistingGeneralDocument_whenNewGeneralDocumentUploaded_thenReturnNewGeneralDocument() { @@ -46,7 +45,7 @@ void givenContestedCaseWithExistingGeneralDocument_whenNewGeneralDocumentUploade )).toList()) .build(); - List actual = uploadGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); + List actual = documentUploadService.getNewUploadGeneralDocuments(caseData, caseDataBefore); List expected = List.of(UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() .documentLink(buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) @@ -73,7 +72,7 @@ void givenContestedCaseWithExistingGeneralDocument_whenNoNewGeneralDocumentUploa .uploadGeneralDocuments(existingGeneralDocument) .build(); - List actual = uploadGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); + List actual = documentUploadService.getNewUploadGeneralDocuments(caseData, caseDataBefore); List expected = List.of(); assertEquals(expected, actual); @@ -96,7 +95,7 @@ void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentUplo )) .build(); - List actual = uploadGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); + List actual = documentUploadService.getNewUploadGeneralDocuments(caseData, caseDataBefore); List expected = List.of(UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() .documentLink(buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) @@ -128,7 +127,7 @@ void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentsUpl )) .build(); - List actual = uploadGeneralDocumentService.getNewlyUploadedDocuments(caseData, caseDataBefore); + List actual = documentUploadService.getNewUploadGeneralDocuments(caseData, caseDataBefore); List expected = List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() From 411cb25d26fa002d5ff12c63f842da0d8446a0ad Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 12 Jun 2024 17:46:18 +0100 Subject: [PATCH 13/96] adding back test case --- .../UploadGeneralDocumentsAboutToSubmitHandlerTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java index 11285a70a0..2f807183fd 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java @@ -68,6 +68,13 @@ public void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadGeneral is(true)); } + @Test + public void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { + assertThat(uploadGeneralDocumentsAboutToSubmitHandler + .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_GENERAL_DOCUMENT), + is(false)); + } + @Test public void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectionByDate() { From f2001a218b01775c72a09326df1ee9cb5c6311eb Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 12 Jun 2024 17:50:38 +0100 Subject: [PATCH 14/96] update package --- .../UploadGeneralDocumentsAboutToSubmitHandler.java | 4 +--- .../UploadGeneralDocumentsAboutToSubmitHandlerTest.java | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) rename src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/{uploadgeneraldocuments => }/UploadGeneralDocumentsAboutToSubmitHandler.java (94%) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandler.java similarity index 94% rename from src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsAboutToSubmitHandler.java rename to src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandler.java index b07772f62e..5e2f6827f7 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/uploadgeneraldocuments/UploadGeneralDocumentsAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandler.java @@ -1,12 +1,10 @@ -package uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments; +package uk.gov.hmcts.reform.finrem.caseorchestration.handler; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; -import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackHandler; -import uk.gov.hmcts.reform.finrem.caseorchestration.handler.FinremCallbackRequest; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java index 2f807183fd..dbafe5fd99 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java @@ -8,7 +8,6 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; -import uk.gov.hmcts.reform.finrem.caseorchestration.handler.uploadgeneraldocuments.UploadGeneralDocumentsAboutToSubmitHandler; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; From 0b5060862b7f443ce6d389bec1b1649a577a6c64 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 12 Jun 2024 18:29:01 +0100 Subject: [PATCH 15/96] add UploadDocumentConsentedAboutToSubmitHandler --- ...DocumentConsentedAboutToSubmitHandler.java | 63 +++++++++++++++++++ ...ocumentContestedAboutToSubmitHandler.java} | 12 ++-- .../caseorchestration/model/EventType.java | 4 +- .../service/DocumentUploadServiceV2.java | 24 +++++++ ...mentConsentedAboutToSubmitHandlerTest.java | 54 ++++++++++++++++ ...entContestedAboutToSubmitHandlerTest.java} | 18 +++--- 6 files changed, 158 insertions(+), 17 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java rename src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/{UploadGeneralDocumentsAboutToSubmitHandler.java => UploadDocumentContestedAboutToSubmitHandler.java} (87%) create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java rename src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/{UploadGeneralDocumentsAboutToSubmitHandlerTest.java => UploadDocumentContestedAboutToSubmitHandlerTest.java} (90%) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java new file mode 100644 index 0000000000..4dd8482377 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java @@ -0,0 +1,63 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.handler; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; +import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; +import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadServiceV2; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; + +import java.util.List; + +@Slf4j +@Service +public class UploadDocumentConsentedAboutToSubmitHandler extends FinremCallbackHandler { + + private final DocumentCheckerService documentCheckerService; + private final DocumentUploadServiceV2 documentUploadService; + + public UploadDocumentConsentedAboutToSubmitHandler(FinremCaseDetailsMapper mapper, + DocumentCheckerService documentCheckerService, + DocumentUploadServiceV2 documentUploadService) { + super(mapper); + this.documentCheckerService = documentCheckerService; + this.documentUploadService = documentUploadService; + } + + @Override + public boolean canHandle(CallbackType callbackType, CaseType caseType, EventType eventType) { + return CallbackType.ABOUT_TO_SUBMIT.equals(callbackType) + && CaseType.CONSENTED.equals(caseType) + && EventType.UPLOAD_DOCUMENT_CONSENTED.equals(eventType); + } + + @Override + @SuppressWarnings("squid:CallToDeprecatedMethod") + public GenericAboutToStartOrSubmitCallbackResponse handle(FinremCallbackRequest callbackRequest, + String userAuthorisation) { + FinremCaseDetails finremCaseDetails = callbackRequest.getCaseDetails(); + FinremCaseData caseData = finremCaseDetails.getData(); + FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); + + final List warnings = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore).stream() + .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) + .flatMap(List::stream) + .filter(ObjectUtils::isNotEmpty) + .toList(); + if (!warnings.isEmpty()) { + log.info("Number of warnings encountered when uploading document for a case {}: {}", + finremCaseDetails.getId(), warnings.size()); + } + + return GenericAboutToStartOrSubmitCallbackResponse.builder() + .warnings(warnings) + .data(caseData).build(); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java similarity index 87% rename from src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandler.java rename to src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java index 5e2f6827f7..7843814c19 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java @@ -24,16 +24,16 @@ @Slf4j @Service -public class UploadGeneralDocumentsAboutToSubmitHandler extends FinremCallbackHandler { +public class UploadDocumentContestedAboutToSubmitHandler extends FinremCallbackHandler { private final DocumentCheckerService documentCheckerService; private final DocumentUploadServiceV2 documentUploadService; private final UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser; - public UploadGeneralDocumentsAboutToSubmitHandler(FinremCaseDetailsMapper mapper, - DocumentCheckerService documentCheckerService, - DocumentUploadServiceV2 documentUploadService, - UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser) { + public UploadDocumentContestedAboutToSubmitHandler(FinremCaseDetailsMapper mapper, + DocumentCheckerService documentCheckerService, + DocumentUploadServiceV2 documentUploadService, + UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser) { super(mapper); this.documentCheckerService = documentCheckerService; this.documentUploadService = documentUploadService; @@ -44,7 +44,7 @@ public UploadGeneralDocumentsAboutToSubmitHandler(FinremCaseDetailsMapper mapper public boolean canHandle(CallbackType callbackType, CaseType caseType, EventType eventType) { return CallbackType.ABOUT_TO_SUBMIT.equals(callbackType) && CaseType.CONTESTED.equals(caseType) - && EventType.UPLOAD_GENERAL_DOCUMENT.equals(eventType); + && EventType.UPLOAD_DOCUMENT_CONTESTED.equals(eventType); } @Override diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/EventType.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/EventType.java index 87e5403ccb..ae868d4510 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/EventType.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/EventType.java @@ -15,8 +15,8 @@ public enum EventType { PREPARE_FOR_HEARING("FR_prepareForHearing"), UPLOAD_CASE_FILES("FR_uploadCaseFiles"), UPLOAD_CONFIDENTIAL_DOCUMENT("FR_uploadConfidentialDocument"), - UPLOAD_GENERAL_DOCUMENT_CONSENTED("FR_uploadDocument"), - UPLOAD_GENERAL_DOCUMENT("FR_uploadGeneralDocument"), + UPLOAD_DOCUMENT_CONSENTED("FR_uploadDocument"), + UPLOAD_DOCUMENT_CONTESTED("FR_uploadGeneralDocument"), INTERIM_HEARING("FR_listForInterimHearing"), SOLICITOR_CREATE("FR_solicitorCreate"), AMEND_APP_DETAILS("FR_amendApplicationDetails"), diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java index 407950bafd..f63387a636 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java @@ -3,6 +3,7 @@ import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; import java.util.ArrayList; @@ -13,6 +14,7 @@ @Service public class DocumentUploadServiceV2 { + public List getNewUploadGeneralDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { List uploadedDocuments = caseData.getUploadGeneralDocuments(); List previousDocuments = caseDataBefore.getUploadGeneralDocuments(); @@ -34,4 +36,26 @@ public List getNewUploadGeneralDocuments(Finrem return newlyUploadedDocuments; } + + public List getNewUploadDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { + List uploadedDocuments = caseData.getUploadDocuments(); + List previousDocuments = caseDataBefore.getUploadDocuments(); + + if (isEmpty(uploadedDocuments)) { + return Collections.emptyList(); + } else if (isEmpty(previousDocuments)) { + return uploadedDocuments; + } + + List newlyUploadedDocuments = new ArrayList<>(); + uploadedDocuments.forEach(d -> { + boolean exists = previousDocuments.stream() + .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); + if (!exists) { + newlyUploadedDocuments.add(d); + } + }); + + return newlyUploadedDocuments; + } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java new file mode 100644 index 0000000000..6c1810e6ef --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java @@ -0,0 +1,54 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.handler; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; +import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadServiceV2; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +@RunWith(MockitoJUnitRunner.class) +public class UploadDocumentConsentedAboutToSubmitHandlerTest { + + public static final String AUTH_TOKEN = "token:)"; + public static final String CASE_ID = "1234567890"; + + ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); + @Mock + private DocumentCheckerService documentCheckerService; + + private UploadDocumentConsentedAboutToSubmitHandler uploadDocumentConsentedAboutToSubmitHandler; + + @Before + public void setUpTest() { + FinremCaseDetailsMapper finremCaseDetailsMapper = + new FinremCaseDetailsMapper(objectMapper); + uploadDocumentConsentedAboutToSubmitHandler = + new UploadDocumentConsentedAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, + new DocumentUploadServiceV2()); + } + + @Test + public void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { + assertThat(uploadDocumentConsentedAboutToSubmitHandler + .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONSENTED), + is(false)); + } + + @Test + public void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { + assertThat(uploadDocumentConsentedAboutToSubmitHandler + .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONSENTED), + is(true)); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java similarity index 90% rename from src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java rename to src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java index dbafe5fd99..89cd3ebb17 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadGeneralDocumentsAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java @@ -30,7 +30,7 @@ import static org.hamcrest.Matchers.is; @RunWith(MockitoJUnitRunner.class) -public class UploadGeneralDocumentsAboutToSubmitHandlerTest { +public class UploadDocumentContestedAboutToSubmitHandlerTest { public static final String AUTH_TOKEN = "token:)"; public static final String CASE_ID = "1234567890"; @@ -42,7 +42,7 @@ public class UploadGeneralDocumentsAboutToSubmitHandlerTest { private DocumentCheckerService documentCheckerService; @Mock private UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser; - private UploadGeneralDocumentsAboutToSubmitHandler uploadGeneralDocumentsAboutToSubmitHandler; + private UploadDocumentContestedAboutToSubmitHandler uploadDocumentContestedAboutToSubmitHandler; private final List uploadDocumentList = new ArrayList<>(); private final List existingDocumentList = new ArrayList<>(); @@ -55,22 +55,22 @@ public void setUpTest() { caseDetailsBefore = buildCaseDetails(); FinremCaseDetailsMapper finremCaseDetailsMapper = new FinremCaseDetailsMapper(objectMapper); - uploadGeneralDocumentsAboutToSubmitHandler = - new UploadGeneralDocumentsAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, + uploadDocumentContestedAboutToSubmitHandler = + new UploadDocumentContestedAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, new DocumentUploadServiceV2(), uploadGeneralDocumentsCategoriser); } @Test public void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { - assertThat(uploadGeneralDocumentsAboutToSubmitHandler - .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_GENERAL_DOCUMENT), + assertThat(uploadDocumentContestedAboutToSubmitHandler + .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONTESTED), is(true)); } @Test public void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { - assertThat(uploadGeneralDocumentsAboutToSubmitHandler - .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_GENERAL_DOCUMENT), + assertThat(uploadDocumentContestedAboutToSubmitHandler + .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONTESTED), is(false)); } @@ -96,7 +96,7 @@ public void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectio expectedDocumentIdList.add(newDoc); expectedDocumentIdList.add(oldDoc); - handledDocumentIdList.addAll(uploadGeneralDocumentsAboutToSubmitHandler.handle( + handledDocumentIdList.addAll(uploadDocumentContestedAboutToSubmitHandler.handle( FinremCallbackRequest.builder().caseDetails(caseDetails).caseDetailsBefore(caseDetailsBefore).build(), AUTH_TOKEN).getData().getUploadGeneralDocuments()); From 11eb2f532eefa63cb95aec64d0f63a10afb58fd0 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 12 Jun 2024 19:13:01 +0100 Subject: [PATCH 16/96] Fine tuning UploadDocumentContestedAboutToSubmitHandlerTest --- ...DocumentContestedAboutToSubmitHandler.java | 12 +-- .../caseorchestration/BaseServiceTest.java | 7 +- ...mentContestedAboutToSubmitHandlerTest.java | 85 ++++++++++++------- .../caseorchestration/util/TestResource.java | 14 +++ 4 files changed, 77 insertions(+), 41 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java index 7843814c19..b0b1202ff7 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java @@ -16,11 +16,13 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentcatergory.UploadGeneralDocumentsCategoriser; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; +import java.util.ArrayList; import java.util.Comparator; import java.util.List; import static java.util.Comparator.comparing; import static java.util.Comparator.nullsLast; +import static java.util.Optional.ofNullable; @Slf4j @Service @@ -55,9 +57,6 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); - // TODO setting upload date to new uploaded general documents - // uploadGeneralDocumentService.addUploadDateToNewDocuments(caseData, caseDataBefore) - final List warnings = documentUploadService.getNewUploadGeneralDocuments(caseData, caseDataBefore).stream() .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) .flatMap(List::stream) @@ -68,13 +67,14 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem finremCaseDetails.getId(), warnings.size()); } - List uploadedDocuments = caseData.getUploadGeneralDocuments(); - + // Do sorting + List uploadedDocuments = new ArrayList<>(ofNullable(caseData.getUploadGeneralDocuments()) + .orElse(List.of())); uploadedDocuments.sort(comparing(UploadGeneralDocumentCollection::getValue, comparing(UploadGeneralDocument::getGeneralDocumentUploadDateTime, nullsLast(Comparator.reverseOrder())))); - caseData.setUploadGeneralDocuments(uploadedDocuments); + // Execute the categoriser for CFV uploadGeneralDocumentsCategoriser.categorise(caseData); return GenericAboutToStartOrSubmitCallbackResponse.builder() diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/BaseServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/BaseServiceTest.java index 7fc26fd211..0f8acde27a 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/BaseServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/BaseServiceTest.java @@ -27,6 +27,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.NatureApplicationWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.notifications.service.EmailService; +import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource; import java.io.File; import java.io.IOException; @@ -409,11 +410,7 @@ protected Map convertCaseDataToStringRepresentation(Map uploadDocumentList = new ArrayList<>(); - private final List existingDocumentList = new ArrayList<>(); - private final List expectedDocumentIdList = new ArrayList<>(); - List handledDocumentIdList = new ArrayList<>(); + private UploadDocumentContestedAboutToSubmitHandler underTest; @Before public void setUpTest() { - caseDetails = buildCaseDetails(); - caseDetailsBefore = buildCaseDetails(); - FinremCaseDetailsMapper finremCaseDetailsMapper = - new FinremCaseDetailsMapper(objectMapper); - uploadDocumentContestedAboutToSubmitHandler = - new UploadDocumentContestedAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, - new DocumentUploadServiceV2(), uploadGeneralDocumentsCategoriser); + FinremCaseDetailsMapper finremCaseDetailsMapper = new FinremCaseDetailsMapper(objectMapper); + underTest = new UploadDocumentContestedAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, documentUploadService, + uploadGeneralDocumentsCategoriser); } @Test public void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { - assertThat(uploadDocumentContestedAboutToSubmitHandler - .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONTESTED), - is(true)); + assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONTESTED), is(true)); } @Test public void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { - assertThat(uploadDocumentContestedAboutToSubmitHandler - .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONTESTED), - is(false)); + assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONTESTED), is(false)); } @Test - public void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectionByDate() { + public void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings() { + List expectedWarnings = List.of("warnings"); + when(documentUploadService.getNewUploadGeneralDocuments(any(), any())).thenReturn(List.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder().build()) + .build() + )); + when(documentCheckerService.getWarnings(any(), any(), any())).thenReturn(expectedWarnings); + + FinremCaseDetails finremCaseDetails = buildCaseDetails(); + finremCaseDetails.getData().setUploadGeneralDocuments(List.of( + createGeneralUploadDocumentItem( + UploadGeneralDocumentType.LETTER_EMAIL_FROM_RESPONDENT, "New email content", + buildCaseDocument("/fileUrl", "document.extension", + "/binaryUrl", ""), LocalDate.now(), "New Example", "newDocument.filename") + )); + + FinremCaseDetails finremCaseDetailsBefore = buildCaseDetails(); + + GenericAboutToStartOrSubmitCallbackResponse response = underTest.handle( + FinremCallbackRequest.builder() + .caseDetails(finremCaseDetails) + .caseDetailsBefore(finremCaseDetailsBefore).build(), + AUTH_TOKEN); + assertThat(response.getWarnings(), is(expectedWarnings)); + } - CaseDocument documentLink = new CaseDocument("/fileUrl", "document.extension", + @Test + public void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectionByDateAndCategoriserInvoked() { + CaseDocument documentLink = buildCaseDocument("/fileUrl", "document.extension", "/binaryUrl", ""); + FinremCaseDetails finremCaseDetails = buildCaseDetails(); + FinremCaseDetails finremCaseDetailsBefore = buildCaseDetails(); + UploadGeneralDocumentCollection oldDoc = createGeneralUploadDocumentItem( UploadGeneralDocumentType.LETTER_EMAIL_FROM_APPLICANT, "Old email content", documentLink, LocalDate.now().minusDays(1), "Old Example", "oldDocument.filename"); - existingDocumentList.add(oldDoc); - caseDetailsBefore.getData().setUploadGeneralDocuments(existingDocumentList); + + finremCaseDetails.getData().setUploadGeneralDocuments(List.of(oldDoc)); UploadGeneralDocumentCollection newDoc = createGeneralUploadDocumentItem( UploadGeneralDocumentType.LETTER_EMAIL_FROM_RESPONDENT, "New email content", documentLink, LocalDate.now(), "New Example", "newDocument.filename"); - uploadDocumentList.addAll(List.of(newDoc, oldDoc)); - caseDetails.getData().setUploadGeneralDocuments(uploadDocumentList); + finremCaseDetails.getData().setUploadGeneralDocuments(List.of(newDoc, oldDoc)); + List expectedDocumentIdList = new ArrayList<>(); expectedDocumentIdList.add(newDoc); expectedDocumentIdList.add(oldDoc); - handledDocumentIdList.addAll(uploadDocumentContestedAboutToSubmitHandler.handle( - FinremCallbackRequest.builder().caseDetails(caseDetails).caseDetailsBefore(caseDetailsBefore).build(), - AUTH_TOKEN).getData().getUploadGeneralDocuments()); + List actual = underTest.handle( + FinremCallbackRequest.builder().caseDetails(finremCaseDetails) + .caseDetailsBefore(finremCaseDetailsBefore).build(), + AUTH_TOKEN).getData().getUploadGeneralDocuments(); - assertThat(handledDocumentIdList.equals(expectedDocumentIdList), is(true)); + assertThat(actual, is(expectedDocumentIdList)); + verify(uploadGeneralDocumentsCategoriser).categorise(finremCaseDetails.getData()); } protected FinremCaseDetails buildCaseDetails() { diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java index a521e54134..0c8db9192b 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.util; import org.springframework.http.HttpStatus; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.document.Document; import uk.gov.hmcts.reform.finrem.caseorchestration.model.evidence.FileUploadResponse; @@ -38,4 +39,17 @@ public static Document testDocument() { .binaryUrl(BINARY_URL) .build(); } + + public static CaseDocument buildCaseDocument(String url, String binaryUrl, String filename) { + return buildCaseDocument(url, binaryUrl, filename, null); + } + + public static CaseDocument buildCaseDocument(String url, String binaryUrl, String filename, String categoryId) { + CaseDocument document = new CaseDocument(); + document.setDocumentUrl(url); + document.setDocumentBinaryUrl(binaryUrl); + document.setDocumentFilename(filename); + document.setCategoryId(categoryId); + return document; + } } From a584ab55943d9ff8093cce947e715ff93c96b57e Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 12 Jun 2024 19:14:28 +0100 Subject: [PATCH 17/96] missing new line --- .../UploadDocumentConsentedAboutToSubmitHandlerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java index 6c1810e6ef..09533a94d1 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java @@ -51,4 +51,4 @@ public void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadGeneral .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONSENTED), is(true)); } -} \ No newline at end of file +} From f3fd917c0444845996c675a0d88fd9bebb7526ea Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 13 Jun 2024 08:53:11 +0100 Subject: [PATCH 18/96] Introduced TestLogger --- .../DocumentCheckerService.java | 1 - ...mentContestedAboutToSubmitHandlerTest.java | 102 +++++++++--------- .../caseorchestration/util/TestLogger.java | 70 ++++++++++++ .../caseorchestration/util/TestLogs.java | 13 +++ .../caseorchestration/util/TestResource.java | 23 ++++ 5 files changed, 160 insertions(+), 49 deletions(-) create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogger.java create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogs.java diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java index 4ba3dcd607..266ddc05fc 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java @@ -29,7 +29,6 @@ public List getWarnings(CaseDocument caseDocument, FinremCaseDetails cas .filter(dc -> dc.canCheck(caseDocument)) .toList(); - if (documentCheckersForDocument.isEmpty()) { return Collections.emptyList(); } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java index 42f0ddc37c..12a382d1f8 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java @@ -2,11 +2,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; @@ -18,29 +20,32 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentType; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.UploadCaseDocumentWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadServiceV2; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentcatergory.UploadGeneralDocumentsCategoriser; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; +import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogger; +import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogs; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; +import static java.lang.String.format; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.AUTH_TOKEN; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.CASE_ID; import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.buildCaseDocument; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getContestedFinremCaseDetailsBuilder; -@RunWith(MockitoJUnitRunner.class) -public class UploadDocumentContestedAboutToSubmitHandlerTest { +@ExtendWith(SpringExtension.class) +class UploadDocumentContestedAboutToSubmitHandlerTest { - public static final String AUTH_TOKEN = "token:)"; - public static final String CASE_ID = "1234567890"; + @TestLogs + private final TestLogger logs = new TestLogger(UploadDocumentContestedAboutToSubmitHandler.class); - ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); @Mock private DocumentUploadServiceV2 documentUploadService; @Mock @@ -50,26 +55,27 @@ public class UploadDocumentContestedAboutToSubmitHandlerTest { private UploadDocumentContestedAboutToSubmitHandler underTest; - @Before + @BeforeEach public void setUpTest() { - FinremCaseDetailsMapper finremCaseDetailsMapper = new FinremCaseDetailsMapper(objectMapper); - underTest = new UploadDocumentContestedAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, documentUploadService, - uploadGeneralDocumentsCategoriser); + underTest = new UploadDocumentContestedAboutToSubmitHandler( + new FinremCaseDetailsMapper(new ObjectMapper().registerModule(new JavaTimeModule())), + documentCheckerService, documentUploadService, uploadGeneralDocumentsCategoriser); } @Test - public void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { - assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONTESTED), is(true)); + void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { + assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONTESTED)).isTrue(); } @Test - public void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { - assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONTESTED), is(false)); + void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { + assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONTESTED)).isFalse(); } - @Test - public void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings() { - List expectedWarnings = List.of("warnings"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasWarnings) { + List expectedWarnings = hasWarnings ? List.of("warnings") : List.of(); when(documentUploadService.getNewUploadGeneralDocuments(any(), any())).thenReturn(List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder().build()) @@ -77,43 +83,51 @@ public void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings() { )); when(documentCheckerService.getWarnings(any(), any(), any())).thenReturn(expectedWarnings); - FinremCaseDetails finremCaseDetails = buildCaseDetails(); - finremCaseDetails.getData().setUploadGeneralDocuments(List.of( - createGeneralUploadDocumentItem( - UploadGeneralDocumentType.LETTER_EMAIL_FROM_RESPONDENT, "New email content", - buildCaseDocument("/fileUrl", "document.extension", - "/binaryUrl", ""), LocalDate.now(), "New Example", "newDocument.filename") - )); + FinremCaseDetails finremCaseDetails = getContestedFinremCaseDetailsBuilder(FinremCaseData.builder() + .uploadGeneralDocuments(List.of( + createGeneralUploadDocumentItem( + UploadGeneralDocumentType.LETTER_EMAIL_FROM_RESPONDENT, "New email content", + buildCaseDocument("/fileUrl", "document.extension", + "/binaryUrl", ""), LocalDate.now(), "New Example", "newDocument.filename") + ))) + .build(); - FinremCaseDetails finremCaseDetailsBefore = buildCaseDetails(); + FinremCaseDetails finremCaseDetailsBefore = getContestedFinremCaseDetailsBuilder(FinremCaseData.builder()).build(); GenericAboutToStartOrSubmitCallbackResponse response = underTest.handle( FinremCallbackRequest.builder() .caseDetails(finremCaseDetails) .caseDetailsBefore(finremCaseDetailsBefore).build(), AUTH_TOKEN); - assertThat(response.getWarnings(), is(expectedWarnings)); + assertThat(response.getWarnings()).isEqualTo(expectedWarnings); + if (hasWarnings) { + assertThat(logs.getInfos()).containsExactly(format( + "Number of warnings encountered when uploading general document for a case %s: %s", CASE_ID, 1)); + } else { + assertThat(logs.getInfos()).isEmpty(); + } } @Test - public void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectionByDateAndCategoriserInvoked() { + void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectionByDateAndCategoriserInvoked() { CaseDocument documentLink = buildCaseDocument("/fileUrl", "document.extension", "/binaryUrl", ""); - FinremCaseDetails finremCaseDetails = buildCaseDetails(); - FinremCaseDetails finremCaseDetailsBefore = buildCaseDetails(); UploadGeneralDocumentCollection oldDoc = createGeneralUploadDocumentItem( UploadGeneralDocumentType.LETTER_EMAIL_FROM_APPLICANT, "Old email content", documentLink, LocalDate.now().minusDays(1), "Old Example", "oldDocument.filename"); - - finremCaseDetails.getData().setUploadGeneralDocuments(List.of(oldDoc)); - UploadGeneralDocumentCollection newDoc = createGeneralUploadDocumentItem( UploadGeneralDocumentType.LETTER_EMAIL_FROM_RESPONDENT, "New email content", documentLink, LocalDate.now(), "New Example", "newDocument.filename"); - finremCaseDetails.getData().setUploadGeneralDocuments(List.of(newDoc, oldDoc)); + + FinremCaseDetails finremCaseDetails = getContestedFinremCaseDetailsBuilder(FinremCaseData.builder() + .uploadGeneralDocuments(List.of(newDoc, oldDoc))) + .build(); + FinremCaseDetails finremCaseDetailsBefore = getContestedFinremCaseDetailsBuilder(FinremCaseData.builder() + .uploadGeneralDocuments(List.of(oldDoc))) + .build(); List expectedDocumentIdList = new ArrayList<>(); expectedDocumentIdList.add(newDoc); @@ -124,18 +138,10 @@ public void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectio .caseDetailsBefore(finremCaseDetailsBefore).build(), AUTH_TOKEN).getData().getUploadGeneralDocuments(); - assertThat(actual, is(expectedDocumentIdList)); + assertThat(actual).isEqualTo(expectedDocumentIdList); verify(uploadGeneralDocumentsCategoriser).categorise(finremCaseDetails.getData()); } - protected FinremCaseDetails buildCaseDetails() { - FinremCaseData finremCaseData = FinremCaseData.builder() - .uploadCaseDocumentWrapper(UploadCaseDocumentWrapper.builder().build()) - .build(); - return FinremCaseDetails.builder().id(Long.valueOf(CASE_ID)).caseType(CaseType.CONTESTED) - .data(finremCaseData).build(); - } - protected UploadGeneralDocumentCollection createGeneralUploadDocumentItem(UploadGeneralDocumentType type, String emailContent, CaseDocument link, LocalDate dateAdded, String comment, String fileName) { diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogger.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogger.java new file mode 100644 index 0000000000..5976b59bdf --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogger.java @@ -0,0 +1,70 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.util; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.read.ListAppender; +import org.slf4j.LoggerFactory; + +import java.util.List; +import java.util.stream.Collectors; + +public class TestLogger extends ListAppender implements AutoCloseable { + + private final Logger logger; + + public TestLogger(Class loggedClass) { + this.logger = (Logger) LoggerFactory.getLogger(loggedClass); + this.start(); + this.logger.addAppender(this); + } + + public List getWarns() { + return get(Level.WARN); + } + + public List getInfos() { + return get(Level.INFO); + } + + public List getErrors() { + return get(Level.ERROR); + } + + public List getErrorThrowableClassNames() { + return this.list.stream() + .filter(event -> Level.ERROR.equals(event.getLevel())) + .map(e -> e.getThrowableProxy().getClassName()) + .collect(Collectors.toList()); + } + + public List getErrorThrowableMessages() { + return this.list.stream() + .filter(event -> Level.ERROR.equals(event.getLevel())) + .map(e -> e.getThrowableProxy().getMessage()) + .collect(Collectors.toList()); + } + + public List get(Level level) { + return this.list.stream() + .filter(event -> level.equals(event.getLevel())) + .map(ILoggingEvent::getFormattedMessage) + .collect(Collectors.toList()); + } + + public List get() { + return this.list.stream() + .map(ILoggingEvent::getFormattedMessage) + .collect(Collectors.toList()); + } + + public void reset() { + this.list.clear(); + } + + @Override + public void close() { + this.stop(); + logger.detachAppender(this); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogs.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogs.java new file mode 100644 index 0000000000..6fb2d7ac17 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogs.java @@ -0,0 +1,13 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.util; + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface TestLogs { + +} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java index 0c8db9192b..64952586b3 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java @@ -2,6 +2,9 @@ import org.springframework.http.HttpStatus; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.model.document.Document; import uk.gov.hmcts.reform.finrem.caseorchestration.model.evidence.FileUploadResponse; @@ -18,6 +21,8 @@ public class TestResource { public static final String CREATED_ON = "20th October 2018"; public static final String MIME_TYPE = "app/pdf"; public static final String CREATED_BY = "user"; + public static final String CASE_ID = "1234567890"; + public static final String AUTH_TOKEN = "token:)"; public static List fileUploadResponse() { FileUploadResponse response = new FileUploadResponse(); @@ -40,6 +45,24 @@ public static Document testDocument() { .build(); } + public static FinremCaseDetails.FinremCaseDetailsBuilder getContestedFinremCaseDetailsBuilder( + FinremCaseData.FinremCaseDataBuilder finremCaseDataBuilder) { + return getFinremCaseDetailsBuilder(finremCaseDataBuilder, CaseType.CONTESTED); + } + + public static FinremCaseDetails.FinremCaseDetailsBuilder getConsentedFinremCaseDetailsBuilder( + FinremCaseData.FinremCaseDataBuilder finremCaseDataBuilder) { + return getFinremCaseDetailsBuilder(finremCaseDataBuilder, CaseType.CONSENTED); + } + + private static FinremCaseDetails.FinremCaseDetailsBuilder getFinremCaseDetailsBuilder(FinremCaseData.FinremCaseDataBuilder finremCaseDataBuilder, + CaseType caseType) { + FinremCaseData finremCaseData = finremCaseDataBuilder.build(); + return FinremCaseDetails.builder().id(Long.valueOf(CASE_ID)) + .caseType(caseType) + .data(finremCaseData); + } + public static CaseDocument buildCaseDocument(String url, String binaryUrl, String filename) { return buildCaseDocument(url, binaryUrl, filename, null); } From 4da333df2b1f62989def79888958801db6d2b62d Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 13 Jun 2024 08:54:01 +0100 Subject: [PATCH 19/96] missing new line --- .../UploadDocumentContestedAboutToSubmitHandlerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java index 12a382d1f8..c5de47e606 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java @@ -157,4 +157,4 @@ protected UploadGeneralDocumentCollection createGeneralUploadDocumentItem(Upload .build()) .build(); } -} \ No newline at end of file +} From 970a7eea261adc4779d034fe9efeda3733e39ca5 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 13 Jun 2024 09:03:07 +0100 Subject: [PATCH 20/96] tidy up --- ...mentContestedAboutToSubmitHandlerTest.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java index c5de47e606..245ae5599d 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java @@ -87,8 +87,7 @@ void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasW .uploadGeneralDocuments(List.of( createGeneralUploadDocumentItem( UploadGeneralDocumentType.LETTER_EMAIL_FROM_RESPONDENT, "New email content", - buildCaseDocument("/fileUrl", "document.extension", - "/binaryUrl", ""), LocalDate.now(), "New Example", "newDocument.filename") + createCaseDocument(), LocalDate.now(), "New Example", "newDocument.filename") ))) .build(); @@ -110,17 +109,13 @@ void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasW @Test void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectionByDateAndCategoriserInvoked() { - CaseDocument documentLink = buildCaseDocument("/fileUrl", "document.extension", - "/binaryUrl", ""); - - UploadGeneralDocumentCollection oldDoc = createGeneralUploadDocumentItem( UploadGeneralDocumentType.LETTER_EMAIL_FROM_APPLICANT, - "Old email content", documentLink, LocalDate.now().minusDays(1), + "Old email content", createCaseDocument(), LocalDate.now().minusDays(1), "Old Example", "oldDocument.filename"); UploadGeneralDocumentCollection newDoc = createGeneralUploadDocumentItem( UploadGeneralDocumentType.LETTER_EMAIL_FROM_RESPONDENT, "New email content", - documentLink, LocalDate.now(), "New Example", "newDocument.filename"); + createCaseDocument(), LocalDate.now(), "New Example", "newDocument.filename"); FinremCaseDetails finremCaseDetails = getContestedFinremCaseDetailsBuilder(FinremCaseData.builder() .uploadGeneralDocuments(List.of(newDoc, oldDoc))) @@ -142,9 +137,13 @@ void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectionByDate verify(uploadGeneralDocumentsCategoriser).categorise(finremCaseDetails.getData()); } - protected UploadGeneralDocumentCollection createGeneralUploadDocumentItem(UploadGeneralDocumentType type, String emailContent, - CaseDocument link, LocalDate dateAdded, String comment, - String fileName) { + private CaseDocument createCaseDocument() { + return buildCaseDocument("/fileUrl", "/binaryUrl","document.extension"); + } + + private UploadGeneralDocumentCollection createGeneralUploadDocumentItem(UploadGeneralDocumentType type, String emailContent, + CaseDocument link, LocalDate dateAdded, String comment, + String fileName) { return UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument .builder() From fde1a1b172cf2eab693173009d72b9d730c92c3b Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 13 Jun 2024 10:47:40 +0100 Subject: [PATCH 21/96] update test cases --- ...mentConsentedAboutToSubmitHandlerTest.java | 49 +++++++++---------- ...mentContestedAboutToSubmitHandlerTest.java | 4 +- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java index 09533a94d1..0806f928a6 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java @@ -2,53 +2,48 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadServiceV2; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; +import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogger; +import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogs; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; +@ExtendWith(SpringExtension.class) +class UploadDocumentConsentedAboutToSubmitHandlerTest { -@RunWith(MockitoJUnitRunner.class) -public class UploadDocumentConsentedAboutToSubmitHandlerTest { + @TestLogs + private final TestLogger logs = new TestLogger(UploadDocumentConsentedAboutToSubmitHandler.class); - public static final String AUTH_TOKEN = "token:)"; - public static final String CASE_ID = "1234567890"; - - ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); @Mock private DocumentCheckerService documentCheckerService; - private UploadDocumentConsentedAboutToSubmitHandler uploadDocumentConsentedAboutToSubmitHandler; + @Mock + private DocumentUploadServiceV2 documentUploadService; + + private UploadDocumentConsentedAboutToSubmitHandler underTest; - @Before + @BeforeEach public void setUpTest() { - FinremCaseDetailsMapper finremCaseDetailsMapper = - new FinremCaseDetailsMapper(objectMapper); - uploadDocumentConsentedAboutToSubmitHandler = - new UploadDocumentConsentedAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, - new DocumentUploadServiceV2()); + FinremCaseDetailsMapper finremCaseDetailsMapper = new FinremCaseDetailsMapper(new ObjectMapper().registerModule(new JavaTimeModule())); + underTest = new UploadDocumentConsentedAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, documentUploadService); } @Test - public void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { - assertThat(uploadDocumentConsentedAboutToSubmitHandler - .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONSENTED), - is(false)); + void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadDocumentConsented_thenHandlerCanHandleReturnTrue() { + Assertions.assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONSENTED)).isTrue(); } @Test - public void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { - assertThat(uploadDocumentConsentedAboutToSubmitHandler - .canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONSENTED), - is(true)); + void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadDocumentConsented_thenHandlerCanHandleReturnFalse() { + Assertions.assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONSENTED)).isFalse(); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java index 245ae5599d..d68186b1bc 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java @@ -63,12 +63,12 @@ public void setUpTest() { } @Test - void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { + void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadDocumentContested_thenHandlerCanHandleReturnTrue() { assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONTESTED)).isTrue(); } @Test - void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadGeneralDocument_thenHandlerCanHandle() { + void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadDocumentContested_thenHandlerCanHandleReturnFalse() { assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONTESTED)).isFalse(); } From 7fb756dc949331a1ca5a695c95b86ed0deddae90 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 13 Jun 2024 11:50:40 +0100 Subject: [PATCH 22/96] Decoupling --- ...DocumentConsentedAboutToSubmitHandler.java | 3 +- ...DocumentContestedAboutToSubmitHandler.java | 3 +- .../model/ccd/CaseDocumentCollection.java | 5 +++ .../model/ccd/HasCaseDocument.java | 5 +++ .../model/ccd/UploadDocument.java | 2 +- .../model/ccd/UploadDocumentCollection.java | 2 +- .../model/ccd/UploadGeneralDocument.java | 2 +- .../ccd/UploadGeneralDocumentCollection.java | 2 +- .../service/DocumentUploadServiceV2.java | 39 +++++-------------- ...mentContestedAboutToSubmitHandlerTest.java | 2 +- .../service/DocumentUploadServiceV2Test.java | 12 ++++-- 11 files changed, 36 insertions(+), 41 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/HasCaseDocument.java diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java index 4dd8482377..2ca79d80ea 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java @@ -45,7 +45,8 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); - final List warnings = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore).stream() + final List warnings = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, FinremCaseData::getUploadDocuments) + .stream() .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) .flatMap(List::stream) .filter(ObjectUtils::isNotEmpty) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java index b0b1202ff7..dd0fc75635 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java @@ -57,7 +57,8 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); - final List warnings = documentUploadService.getNewUploadGeneralDocuments(caseData, caseDataBefore).stream() + final List warnings = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, FinremCaseData::getUploadGeneralDocuments) + .stream() .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) .flatMap(List::stream) .filter(ObjectUtils::isNotEmpty) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java new file mode 100644 index 0000000000..9c6ceb8d2e --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java @@ -0,0 +1,5 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd; + +public interface CaseDocumentCollection { + T getValue(); +} \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/HasCaseDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/HasCaseDocument.java new file mode 100644 index 0000000000..58bb10dbb2 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/HasCaseDocument.java @@ -0,0 +1,5 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd; + +public interface HasCaseDocument { + CaseDocument getDocumentLink(); +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocument.java index f8222d9404..fde4835bbb 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocument.java @@ -19,7 +19,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class UploadDocument { +public class UploadDocument implements HasCaseDocument { @JsonProperty("DocumentType") private UploadDocumentType documentType; @JsonProperty("DocumentEmailContent") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocumentCollection.java index 2a10b055a3..f6f8c8d76d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocumentCollection.java @@ -11,6 +11,6 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadDocumentCollection { +public class UploadDocumentCollection implements CaseDocumentCollection { private UploadDocument value; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocument.java index 0a5f4e21ab..67590d3493 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocument.java @@ -21,7 +21,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class UploadGeneralDocument { +public class UploadGeneralDocument implements HasCaseDocument { @JsonProperty("DocumentType") private UploadGeneralDocumentType documentType; @JsonProperty("DocumentEmailContent") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocumentCollection.java index f622ec46d0..26922b3f7b 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocumentCollection.java @@ -11,6 +11,6 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadGeneralDocumentCollection { +public class UploadGeneralDocumentCollection implements CaseDocumentCollection { private UploadGeneralDocument value; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java index f63387a636..9cfcd9f6f0 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java @@ -2,44 +2,23 @@ import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocumentCollection; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.function.Function; import static org.apache.commons.lang3.ObjectUtils.isEmpty; @Service public class DocumentUploadServiceV2 { - - public List getNewUploadGeneralDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { - List uploadedDocuments = caseData.getUploadGeneralDocuments(); - List previousDocuments = caseDataBefore.getUploadGeneralDocuments(); - if (isEmpty(uploadedDocuments)) { - return Collections.emptyList(); - } else if (isEmpty(previousDocuments)) { - return uploadedDocuments; - } - - List newlyUploadedDocuments = new ArrayList<>(); - uploadedDocuments.forEach(d -> { - boolean exists = previousDocuments.stream() - .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); - if (!exists) { - newlyUploadedDocuments.add(d); - } - }); - - return newlyUploadedDocuments; - } - - public List getNewUploadDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { - List uploadedDocuments = caseData.getUploadDocuments(); - List previousDocuments = caseDataBefore.getUploadDocuments(); + public > List getNewUploadDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore, + Function> accessor) { + List uploadedDocuments = accessor.apply(caseData); + List previousDocuments = accessor.apply(caseDataBefore); if (isEmpty(uploadedDocuments)) { return Collections.emptyList(); @@ -47,15 +26,15 @@ public List getNewUploadDocuments(FinremCaseData caseD return uploadedDocuments; } - List newlyUploadedDocuments = new ArrayList<>(); + List ret = new ArrayList<>(); uploadedDocuments.forEach(d -> { boolean exists = previousDocuments.stream() .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); if (!exists) { - newlyUploadedDocuments.add(d); + ret.add(d); } }); - return newlyUploadedDocuments; + return ret; } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java index d68186b1bc..61fc6e9a5d 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java @@ -76,7 +76,7 @@ void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadDocumentContes @ValueSource(booleans = {true, false}) void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasWarnings) { List expectedWarnings = hasWarnings ? List.of("warnings") : List.of(); - when(documentUploadService.getNewUploadGeneralDocuments(any(), any())).thenReturn(List.of( + when(documentUploadService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder().build()) .build() diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java index f7fa1d8af1..3b408c3dc6 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java @@ -45,7 +45,8 @@ void givenContestedCaseWithExistingGeneralDocument_whenNewGeneralDocumentUploade )).toList()) .build(); - List actual = documentUploadService.getNewUploadGeneralDocuments(caseData, caseDataBefore); + List actual = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, + FinremCaseData::getUploadGeneralDocuments); List expected = List.of(UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() .documentLink(buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) @@ -72,7 +73,8 @@ void givenContestedCaseWithExistingGeneralDocument_whenNoNewGeneralDocumentUploa .uploadGeneralDocuments(existingGeneralDocument) .build(); - List actual = documentUploadService.getNewUploadGeneralDocuments(caseData, caseDataBefore); + List actual = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, + FinremCaseData::getUploadGeneralDocuments); List expected = List.of(); assertEquals(expected, actual); @@ -95,7 +97,8 @@ void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentUplo )) .build(); - List actual = documentUploadService.getNewUploadGeneralDocuments(caseData, caseDataBefore); + List actual = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, + FinremCaseData::getUploadGeneralDocuments); List expected = List.of(UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() .documentLink(buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) @@ -127,7 +130,8 @@ void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentsUpl )) .build(); - List actual = documentUploadService.getNewUploadGeneralDocuments(caseData, caseDataBefore); + List actual = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, + FinremCaseData::getUploadGeneralDocuments); List expected = List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() From d600dbd48f43451716a57c9a828b72e63163653d Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 13 Jun 2024 12:30:14 +0100 Subject: [PATCH 23/96] checkstyle --- .../caseorchestration/model/ccd/CaseDocumentCollection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java index 9c6ceb8d2e..8490823730 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java @@ -1,5 +1,5 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd; public interface CaseDocumentCollection { - T getValue(); + T getValue(); } \ No newline at end of file From 803b46cd51ce2afe04f5b509282656822e692b16 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 13 Jun 2024 12:33:27 +0100 Subject: [PATCH 24/96] revert it --- .../caseorchestration/service/DocumentUploadService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadService.java index 40b0a16b23..c115049674 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadService.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadService.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import uk.gov.hmcts.reform.finrem.caseorchestration.model.CaseDocumentTabData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadCaseDocumentCollection; import java.time.LocalDateTime; import java.util.ArrayList; @@ -46,12 +45,14 @@ public Map addUploadDateToNewDocuments(Map caseD } public void addUploadDateToNewDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore) { - List allDocuments = caseData.getUploadCaseDocumentWrapper().getAllManageableCollections(); - List documentsBeforeEvent = caseDataBefore.getUploadCaseDocumentWrapper().getAllManageableCollections(); + List allDocuments = (List) caseData.getUploadCaseDocumentWrapper().getAllManageableCollections(); + List documentsBeforeEvent = (List) caseDataBefore.getUploadCaseDocumentWrapper().getAllManageableCollections(); - allDocuments.forEach(document -> addDateToNewDocuments((List) documentsBeforeEvent, (T) document)); + allDocuments.stream().forEach(document -> addDateToNewDocuments(documentsBeforeEvent, document)); } + + private void addDateToNewDocuments(List documentsBeforeEvent, T document) { if (isNewDocument.test(document.getElementId(), documentsBeforeEvent)) { document.setUploadDateTime(LocalDateTime.now()); From 9227760f4a5e7ed7df5fdb0d7ec2d3ec8c07581f Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 13 Jun 2024 13:26:48 +0100 Subject: [PATCH 25/96] decoupling the test case --- .../service/DocumentUploadServiceV2Test.java | 64 ++++++++++++------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java index 3b408c3dc6..57f78d253c 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java @@ -3,18 +3,23 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.NullAndEmptySource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.hmcts.reform.finrem.caseorchestration.BaseServiceTest; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource; import java.util.List; +import java.util.function.Function; import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; @ExtendWith(SpringExtension.class) class DocumentUploadServiceV2Test extends BaseServiceTest { @@ -22,38 +27,51 @@ class DocumentUploadServiceV2Test extends BaseServiceTest { @Autowired private DocumentUploadServiceV2 documentUploadService; - @Test - void givenContestedCaseWithExistingGeneralDocument_whenNewGeneralDocumentUploaded_thenReturnNewGeneralDocument() { + private static Stream provideDocumentModifier() { final List existingGeneralDocument = List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(buildCaseDocument("url1", "binaryUrl1", "filename1")) + .documentLink(TestResource.buildCaseDocument("url1", "binaryUrl1", "filename1")) .build()) .build() ); - FinremCaseData caseDataBefore = FinremCaseData.builder() - .uploadGeneralDocuments(existingGeneralDocument) - .build(); - FinremCaseData caseData = caseDataBefore.toBuilder() - .uploadGeneralDocuments(Stream.concat(existingGeneralDocument.stream(), Stream.of( - UploadGeneralDocumentCollection.builder() + return Stream.of( + // uloadGeneralDocuments + Arguments.of((Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(existingGeneralDocument); + return finremCaseDataBuilder; + }, + (Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(Stream.concat(existingGeneralDocument.stream(), Stream.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(TestResource.buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) + .build()) + .build() + )).toList()); + return finremCaseDataBuilder; + }, + (Function) FinremCaseData::getUploadGeneralDocuments, + List.of(UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) + .documentLink(TestResource.buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) .build()) - .build() - )).toList()) - .build(); - - List actual = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, - FinremCaseData::getUploadGeneralDocuments); - List expected = List.of(UploadGeneralDocumentCollection.builder() - .value(UploadGeneralDocument.builder() - .documentLink(buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) - .build()) - .build()); + .build()) + ) + ); + } - assertEquals(expected, actual); + @ParameterizedTest + @MethodSource("provideDocumentModifier") + void givenCaseWithExistingDocument_whenNewDocumentUploaded_thenReturnNewDocument( + Function caseDataBeforeModifier, + Function caseDataModifier, + Function>> accessor, + List> expectedReturn) { + FinremCaseData caseDataBefore = caseDataBeforeModifier.apply(FinremCaseData.builder()).build(); + FinremCaseData caseData = caseDataModifier.apply(caseDataBefore.toBuilder()).build(); + assertEquals(expectedReturn, documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, accessor)); } @Test From e8b318d5171ee6835e2889495ca1bc2c6b299f6e Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 13 Jun 2024 14:45:31 +0100 Subject: [PATCH 26/96] To make test case much more generic. --- .../service/DocumentUploadServiceV2Test.java | 209 +++++++++--------- 1 file changed, 108 insertions(+), 101 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java index 57f78d253c..1d40f4a171 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java @@ -1,16 +1,16 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.NullAndEmptySource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.hmcts.reform.finrem.caseorchestration.BaseServiceTest; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource; @@ -27,26 +27,34 @@ class DocumentUploadServiceV2Test extends BaseServiceTest { @Autowired private DocumentUploadServiceV2 documentUploadService; - private static Stream provideDocumentModifier() { - final List existingGeneralDocument = List.of( + private static Stream provideArguments() { + final List existingUploadGeneralDocument = List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() .documentLink(TestResource.buildCaseDocument("url1", "binaryUrl1", "filename1")) .build()) .build() ); + final List existingUploadDocument = List.of( + UploadDocumentCollection.builder() + .value(UploadDocument.builder() + .documentLink(TestResource.buildCaseDocument("url1", "binaryUrl1", "filename1")) + .build()) + .build() + ); return Stream.of( - // uloadGeneralDocuments + // 1. uploadGeneralDocuments + // 1.1 with new doc Arguments.of((Function) finremCaseDataBuilder -> { - finremCaseDataBuilder.uploadGeneralDocuments(existingGeneralDocument); + finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); return finremCaseDataBuilder; }, (Function) finremCaseDataBuilder -> { - finremCaseDataBuilder.uploadGeneralDocuments(Stream.concat(existingGeneralDocument.stream(), Stream.of( + finremCaseDataBuilder.uploadGeneralDocuments(Stream.concat(existingUploadGeneralDocument.stream(), Stream.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(TestResource.buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) + .documentLink(TestResource.buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) .build()) .build() )).toList()); @@ -55,6 +63,96 @@ private static Stream provideDocumentModifier() { (Function) FinremCaseData::getUploadGeneralDocuments, List.of(UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() + .documentLink(TestResource.buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .build()) + .build()) + ), + // 1.2 without new doc + Arguments.of((Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); + return finremCaseDataBuilder; + }, + (Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); + return finremCaseDataBuilder; + }, + (Function) FinremCaseData::getUploadGeneralDocuments, + List.of() + ), + // 1.3 with multiple new docs + Arguments.of((Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); + return finremCaseDataBuilder; + }, + (Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(Stream.concat(existingUploadGeneralDocument.stream(), Stream.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(TestResource.buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .build()) + .build(), + + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(TestResource.buildCaseDocument("newUrl2", "newBinaryUrl2", "newFilename2")) + .build()) + .build() + )).toList()); + return finremCaseDataBuilder; + }, + (Function) FinremCaseData::getUploadGeneralDocuments, + List.of(UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(TestResource.buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .build()) + .build(), + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(TestResource.buildCaseDocument("newUrl2", "newBinaryUrl2", "newFilename2")) + .build()) + .build()) + ), + // 1.4 no existing doc with a new doc + Arguments.of((Function) finremCaseDataBuilder -> + finremCaseDataBuilder, + (Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(List.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(TestResource.buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .build()) + .build() + )); + return finremCaseDataBuilder; + }, + (Function) FinremCaseData::getUploadGeneralDocuments, + List.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(TestResource.buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .build()) + .build() + ) + ), + + // 2. uploadDocuments + Arguments.of((Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadDocuments(existingUploadDocument); + return finremCaseDataBuilder; + }, + (Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadDocuments(Stream.concat(existingUploadDocument.stream(), Stream.of( + UploadDocumentCollection.builder() + .value(UploadDocument.builder() + .documentLink(TestResource.buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) + .build()) + .build() + )).toList()); + return finremCaseDataBuilder; + }, + (Function) FinremCaseData::getUploadDocuments, + List.of(UploadDocumentCollection.builder() + .value(UploadDocument.builder() .documentLink(TestResource.buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) .build()) .build()) @@ -63,8 +161,8 @@ private static Stream provideDocumentModifier() { } @ParameterizedTest - @MethodSource("provideDocumentModifier") - void givenCaseWithExistingDocument_whenNewDocumentUploaded_thenReturnNewDocument( + @MethodSource("provideArguments") + void givenCaseWithExistingDocument_whenDocumentUploadedOrNot_thenReturnExpectedDocument( Function caseDataBeforeModifier, Function caseDataModifier, Function>> accessor, @@ -73,95 +171,4 @@ void givenCaseWithExistingDocument_whenNewDocumentUploaded_thenReturnNewDocument FinremCaseData caseData = caseDataModifier.apply(caseDataBefore.toBuilder()).build(); assertEquals(expectedReturn, documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, accessor)); } - - @Test - void givenContestedCaseWithExistingGeneralDocument_whenNoNewGeneralDocumentUploaded_thenReturnAnEmptyList() { - final List existingGeneralDocument = List.of( - UploadGeneralDocumentCollection.builder() - .value(UploadGeneralDocument.builder() - .documentLink(buildCaseDocument("url1", "binaryUrl1", "filename1")) - .build()) - .build() - ); - - FinremCaseData caseDataBefore = FinremCaseData.builder() - .uploadGeneralDocuments(existingGeneralDocument) - .build(); - FinremCaseData caseData = caseDataBefore.toBuilder() - .uploadGeneralDocuments(existingGeneralDocument) - .build(); - - List actual = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, - FinremCaseData::getUploadGeneralDocuments); - List expected = List.of(); - - assertEquals(expected, actual); - } - - @ParameterizedTest - @NullAndEmptySource - void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentUploaded_thenReturnNewGeneralDocument( - List existing) { - FinremCaseData caseDataBefore = FinremCaseData.builder() - .uploadGeneralDocuments(existing) - .build(); - FinremCaseData caseData = caseDataBefore.toBuilder() - .uploadGeneralDocuments(List.of( - UploadGeneralDocumentCollection.builder() - .value(UploadGeneralDocument.builder() - .documentLink(buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) - .build()) - .build() - )) - .build(); - - List actual = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, - FinremCaseData::getUploadGeneralDocuments); - List expected = List.of(UploadGeneralDocumentCollection.builder() - .value(UploadGeneralDocument.builder() - .documentLink(buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) - .build()) - .build()); - - assertEquals(expected, actual); - } - - @ParameterizedTest - @NullAndEmptySource - void givenContestedCaseWithoutExistingGeneralDocument_whenNewGeneralDocumentsUploaded_thenReturnMultipleNewGeneralDocument( - List existing) { - FinremCaseData caseDataBefore = FinremCaseData.builder() - .uploadGeneralDocuments(existing) - .build(); - FinremCaseData caseData = caseDataBefore.toBuilder() - .uploadGeneralDocuments(List.of( - UploadGeneralDocumentCollection.builder() - .value(UploadGeneralDocument.builder() - .documentLink(buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) - .build()) - .build(), - UploadGeneralDocumentCollection.builder() - .value(UploadGeneralDocument.builder() - .documentLink(buildCaseDocument("newUrl2", "newBinaryUrl2", "newFilename2")) - .build()) - .build() - )) - .build(); - - List actual = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, - FinremCaseData::getUploadGeneralDocuments); - List expected = List.of( - UploadGeneralDocumentCollection.builder() - .value(UploadGeneralDocument.builder() - .documentLink(buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) - .build()) - .build(), - UploadGeneralDocumentCollection.builder() - .value(UploadGeneralDocument.builder() - .documentLink(buildCaseDocument("newUrl2", "newBinaryUrl2", "newFilename2")) - .build()) - .build()); - - assertEquals(expected, actual); - } } From c030503fb3f2f877124dd269270d95e061405aec Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 13 Jun 2024 18:00:38 +0100 Subject: [PATCH 27/96] Resolving code smells --- .../finrem/caseorchestration/utils/pdf/PdfToText.java | 7 ++++++- .../service/DocumentUploadServiceV2Test.java | 1 + .../reform/finrem/caseorchestration/util/TestLogger.java | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/pdf/PdfToText.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/pdf/PdfToText.java index ef6cdc35fb..ffbe27ac57 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/pdf/PdfToText.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/pdf/PdfToText.java @@ -5,7 +5,11 @@ import java.io.IOException; -public class PdfToText { +class PdfToText { + + private PdfToText() { + throw new IllegalStateException("Utility class"); + } public static String textContent(byte[] bytes) throws IOException { try (PDDocument document = PDDocument.load(bytes)) { @@ -18,4 +22,5 @@ public static String[] textContentLines(byte[] bytes) throws IOException { String content = textContent(bytes); return content.split(System.lineSeparator()); } + } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java index 1d40f4a171..e3e5022d1c 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java @@ -136,6 +136,7 @@ private static Stream provideArguments() { ), // 2. uploadDocuments + // 2.1 with new doc Arguments.of((Function) finremCaseDataBuilder -> { finremCaseDataBuilder.uploadDocuments(existingUploadDocument); return finremCaseDataBuilder; diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogger.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogger.java index 5976b59bdf..fd9ad76934 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogger.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogger.java @@ -42,20 +42,20 @@ public List getErrorThrowableMessages() { return this.list.stream() .filter(event -> Level.ERROR.equals(event.getLevel())) .map(e -> e.getThrowableProxy().getMessage()) - .collect(Collectors.toList()); + .toList(); } public List get(Level level) { return this.list.stream() .filter(event -> level.equals(event.getLevel())) .map(ILoggingEvent::getFormattedMessage) - .collect(Collectors.toList()); + .toList(); } public List get() { return this.list.stream() .map(ILoggingEvent::getFormattedMessage) - .collect(Collectors.toList()); + .toList(); } public void reset() { From bd561782a60e50d40c5dd0f1e9eb79a28a2b3bb0 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 13 Jun 2024 18:57:02 +0100 Subject: [PATCH 28/96] Resolving code smell and update test cases. --- ...mentConsentedAboutToSubmitHandlerTest.java | 80 +++++++++++++++++-- ...mentContestedAboutToSubmitHandlerTest.java | 10 +-- .../caseorchestration/util/TestLogger.java | 3 +- 3 files changed, 78 insertions(+), 15 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java index 0806f928a6..d7950f0a7b 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java @@ -2,21 +2,42 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.Mock; import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; +import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocumentType; import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadServiceV2; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogger; import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogs; +import java.time.LocalDate; +import java.util.List; + +import static java.lang.String.format; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.finrem.caseorchestration.test.Assertions.assertCanHandle; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.AUTH_TOKEN; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.CASE_ID; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.buildCaseDocument; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getContestedFinremCaseDetailsBuilder; + @ExtendWith(SpringExtension.class) class UploadDocumentConsentedAboutToSubmitHandlerTest { @@ -38,12 +59,59 @@ public void setUpTest() { } @Test - void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadDocumentConsented_thenHandlerCanHandleReturnTrue() { - Assertions.assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONSENTED)).isTrue(); + void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadDocumentConsented_thenHandlerCanHandle() { + assertCanHandle(underTest, CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONSENTED); } - @Test - void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadDocumentConsented_thenHandlerCanHandleReturnFalse() { - Assertions.assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONSENTED)).isFalse(); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasWarnings) { + List expectedWarnings = hasWarnings ? List.of("warnings") : List.of(); + when(documentUploadService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( + UploadDocumentCollection.builder() + .value(UploadDocument.builder().build()) + .build() + )); + when(documentCheckerService.getWarnings(any(), any(), any())).thenReturn(expectedWarnings); + + FinremCaseDetails finremCaseDetails = getContestedFinremCaseDetailsBuilder(FinremCaseData.builder() + .uploadDocuments(List.of( + createUploadDocumentCollection( + UploadDocumentType.APPLICATION, "New email content", + buildCaseDocument("/fileUrl", "/binaryUrl","document.extension"), LocalDate.now(), "New Example", + "newDocument.filename") + ))) + .build(); + + FinremCaseDetails finremCaseDetailsBefore = getContestedFinremCaseDetailsBuilder(FinremCaseData.builder()).build(); + + GenericAboutToStartOrSubmitCallbackResponse response = underTest.handle( + FinremCallbackRequest.builder() + .caseDetails(finremCaseDetails) + .caseDetailsBefore(finremCaseDetailsBefore).build(), + AUTH_TOKEN); + assertThat(response.getWarnings()).isEqualTo(expectedWarnings); + if (hasWarnings) { + assertThat(logs.getInfos()).containsExactly(format( + "Number of warnings encountered when uploading document for a case %s: %s", CASE_ID, 1)); + } else { + assertThat(logs.getInfos()).isEmpty(); + } + } + + private UploadDocumentCollection createUploadDocumentCollection(UploadDocumentType type, String emailContent, + CaseDocument link, LocalDate dateAdded, String comment, + String fileName) { + return UploadDocumentCollection.builder() + .value(UploadDocument + .builder() + .documentType(type) + .documentEmailContent(emailContent) + .documentLink(link) + .documentDateAdded(dateAdded) + .documentComment(comment) + .documentFileName(fileName) + .build()) + .build(); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java index 61fc6e9a5d..670df3e783 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java @@ -35,6 +35,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.finrem.caseorchestration.test.Assertions.assertCanHandle; import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.AUTH_TOKEN; import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.CASE_ID; import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.buildCaseDocument; @@ -63,13 +64,8 @@ public void setUpTest() { } @Test - void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadDocumentContested_thenHandlerCanHandleReturnTrue() { - assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONTESTED)).isTrue(); - } - - @Test - void givenACcdCallbackConsentedCase_WhenAnAboutToSubmitEventUploadDocumentContested_thenHandlerCanHandleReturnFalse() { - assertThat(underTest.canHandle(CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONTESTED)).isFalse(); + void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadDocumentContested_thenHandlerCanHandle() { + assertCanHandle(underTest, CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONTESTED); } @ParameterizedTest diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogger.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogger.java index fd9ad76934..dd3862cb3e 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogger.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestLogger.java @@ -7,7 +7,6 @@ import org.slf4j.LoggerFactory; import java.util.List; -import java.util.stream.Collectors; public class TestLogger extends ListAppender implements AutoCloseable { @@ -35,7 +34,7 @@ public List getErrorThrowableClassNames() { return this.list.stream() .filter(event -> Level.ERROR.equals(event.getLevel())) .map(e -> e.getThrowableProxy().getClassName()) - .collect(Collectors.toList()); + .toList(); } public List getErrorThrowableMessages() { From 0496e49044f632baca1c37713d3528bcd29e0583 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 14 Jun 2024 08:53:36 +0100 Subject: [PATCH 29/96] update RespondentNameDocumentContentChecker --- ...pondentNameDocumentContentCheckerTest.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java index c7d64e98a9..e11a3286e8 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java @@ -1,4 +1,61 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; + +import static org.assertj.core.api.Assertions.assertThat; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getConsentedFinremCaseDetailsBuilder; + class RespondentNameDocumentContentCheckerTest { + + private final RespondentNameDocumentContentChecker underTest = new RespondentNameDocumentContentChecker(); + + @Test + void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName() { + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .respondentFmName("Joe") + .respondentLname("Bloggs") + .build())).build(), + new String[] {"The respondent is Joe Bloggs"})) + .isNull(); + } + + @Test + void givenCaseData_whenContentContainsNameDoesNotMatchRespondentFirstNameAndLastName() { + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .respondentFmName("Joey") + .respondentLname("Bloggs") + .build())).build(), + new String[] {"The respondent is Joe Bloggs"})) + .isEqualTo("Respondent name may not match"); + } + + @Test + void givenCaseData_whenOneOfTheContentsContainsNameDoesNotMatchRespondentFirstNameAndLastName() { + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .respondentFmName("Joey") + .respondentLname("Bloggs") + .build())).build(), + new String[] {"The respondent is Joe Bloggs", "Whatever", "Whenever"})) + .isEqualTo("Respondent name may not match"); + } + + @Test + void givenCaseData_whenEmptyContentProvided() { + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .respondentFmName("Joey") + .respondentLname("Bloggs") + .build())).build(), + new String[] {})) + .isNull(); + } } From 4a20a2260e4a952be5bbe2d0ee61045ac7a95ff6 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 14 Jun 2024 11:14:50 +0100 Subject: [PATCH 30/96] Test cases for ApplicantNameDocumentContentChecker --- .../ApplicantNameDocumentContentChecker.java | 14 +++- .../DocumentContentChecker.java | 1 + .../RespondentNameDocumentContentChecker.java | 14 +++- ...plicantNameDocumentContentCheckerTest.java | 65 +++++++++++++++++++ ...pondentNameDocumentContentCheckerTest.java | 8 +++ 5 files changed, 98 insertions(+), 4 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java index 424fe3a30e..76a936c4ae 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java @@ -1,5 +1,6 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; @@ -7,6 +8,10 @@ import java.util.stream.Stream; +import static java.util.Optional.ofNullable; +import static org.apache.commons.lang3.StringUtils.isEmpty; +import static org.apache.commons.lang3.StringUtils.trim; + @Component public class ApplicantNameDocumentContentChecker implements DocumentContentChecker { @@ -26,7 +31,11 @@ private boolean containsTheApplicantIs(String text) { } private boolean contentNameNotEqualsCaseName(FinremCaseData caseData, String content) { - return !getApplicantNameFromCase(caseData).equals(getApplicantNameFromContent(content.trim())); + String applicantName = getApplicantNameFromCase(caseData); + if (isEmpty(trim(applicantName))) { + return false; + } + return !applicantName.equals(getApplicantNameFromContent(content.trim())); } private String getApplicantNameFromContent(String text) { @@ -35,6 +44,7 @@ private String getApplicantNameFromContent(String text) { private String getApplicantNameFromCase(FinremCaseData caseData) { ContactDetailsWrapper contactDetails = caseData.getContactDetailsWrapper(); - return contactDetails.getApplicantFmName() + " " + contactDetails.getApplicantLname(); + return ofNullable(contactDetails.getApplicantFmName()).orElse(StringUtils.EMPTY) + SPACE + + ofNullable(contactDetails.getApplicantLname()).orElse(StringUtils.EMPTY); } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/DocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/DocumentContentChecker.java index 1ee8bc49b5..200226f8a2 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/DocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/DocumentContentChecker.java @@ -4,5 +4,6 @@ public interface DocumentContentChecker { + public static String SPACE = " "; String getWarning(FinremCaseDetails caseDetails, String[] content); } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java index 1ed0765ebe..54e574eb41 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java @@ -1,5 +1,6 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; @@ -7,6 +8,10 @@ import java.util.stream.Stream; +import static java.util.Optional.ofNullable; +import static org.apache.commons.lang3.StringUtils.isEmpty; +import static org.apache.commons.lang3.StringUtils.trim; + @Component public class RespondentNameDocumentContentChecker implements DocumentContentChecker { @@ -26,7 +31,11 @@ private boolean containsTheRespondentIs(String text) { } private boolean contentNameNotEqualsCaseName(FinremCaseData caseData, String content) { - return !getRespondentNameFromCase(caseData).equals(getRespondentNameFromContent(content.trim())); + String respondentName = getRespondentNameFromCase(caseData); + if (isEmpty(trim(respondentName))) { + return false; + } + return !respondentName.equals(getRespondentNameFromContent(content.trim())); } private String getRespondentNameFromContent(String text) { @@ -35,6 +44,7 @@ private String getRespondentNameFromContent(String text) { private String getRespondentNameFromCase(FinremCaseData caseData) { ContactDetailsWrapper contactDetails = caseData.getContactDetailsWrapper(); - return contactDetails.getRespondentFmName() + " " + contactDetails.getRespondentLname(); + return ofNullable(contactDetails.getRespondentFmName()).orElse(StringUtils.EMPTY) + SPACE + + ofNullable(contactDetails.getRespondentLname()).orElse(StringUtils.EMPTY); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java index b00f9f29aa..a6f1913cb6 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java @@ -1,4 +1,69 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; + +import static org.assertj.core.api.Assertions.assertThat; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getConsentedFinremCaseDetailsBuilder; + class ApplicantNameDocumentContentCheckerTest { + + private final ApplicantNameDocumentContentChecker underTest = new ApplicantNameDocumentContentChecker(); + + @Test + void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndLastName() { + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .applicantFmName("Joe") + .applicantLname("Bloggs") + .build())).build(), + new String[] {"The applicant is Joe Bloggs"})) + .isNull(); + } + + @Test + void givenCaseData_whenContentContainsNameDoesNotMatchApplicantFirstNameAndLastName() { + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .applicantFmName("Joey") + .applicantLname("Bloggs") + .build())).build(), + new String[] {"1. The applicant is Joe Bloggs"})) + .isEqualTo("Applicant name may not match"); + } + + @Test + void givenCaseData_whenOneOfTheContentsContainsNameDoesNotMatchApplicantFirstNameAndLastName() { + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .applicantFmName("Joey") + .applicantLname("Bloggs") + .build())).build(), + new String[] {"1. The applicant is Joe Bloggs", "Whatever", "Whenever"})) + .isEqualTo("Applicant name may not match"); + } + + @Test + void givenCaseData_whenEmptyContentProvided() { + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .applicantFmName("Joey") + .applicantLname("Bloggs") + .build())).build(), + new String[] {})) + .isNull(); + } + + @Test + void givenCaseDataWithoutContactDetailsWrapper_whenContentProvided() { + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder()).build(), + new String[] {"1. The applicant is Joe Bloggs"})) + .isNull(); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java index e11a3286e8..6ff48da0a3 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java @@ -58,4 +58,12 @@ void givenCaseData_whenEmptyContentProvided() { new String[] {})) .isNull(); } + + @Test + void givenCaseDataWithoutContactDetailsWrapper_whenContentProvided() { + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder()).build(), + new String[] {"The respondent is Joe Bloggs"})) + .isNull(); + } } From 648934deecf7ff713ade08c458161d9808d0e24e Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 14 Jun 2024 11:15:35 +0100 Subject: [PATCH 31/96] Remove unused class --- .../utils/pdf/PdfToText.java | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/pdf/PdfToText.java diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/pdf/PdfToText.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/pdf/PdfToText.java deleted file mode 100644 index ffbe27ac57..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/pdf/PdfToText.java +++ /dev/null @@ -1,26 +0,0 @@ -package uk.gov.hmcts.reform.finrem.caseorchestration.utils.pdf; - -import org.apache.pdfbox.pdmodel.PDDocument; -import org.apache.pdfbox.text.PDFTextStripper; - -import java.io.IOException; - -class PdfToText { - - private PdfToText() { - throw new IllegalStateException("Utility class"); - } - - public static String textContent(byte[] bytes) throws IOException { - try (PDDocument document = PDDocument.load(bytes)) { - PDFTextStripper stripper = new PDFTextStripper(); - return stripper.getText(document); - } - } - - public static String[] textContentLines(byte[] bytes) throws IOException { - String content = textContent(bytes); - return content.split(System.lineSeparator()); - } - -} From ce4d1b188aba1e50db8fd06c92efcba3c6863cb8 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 14 Jun 2024 12:19:55 +0100 Subject: [PATCH 32/96] Test case for DocumentCheckerService --- .../caseorchestration/BaseServiceTest.java | 4 ++ .../DocumentCheckerServiceTest.java | 59 ++++++++++++++++++- .../caseorchestration/util/TestResource.java | 4 ++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/BaseServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/BaseServiceTest.java index 0f8acde27a..b606899bc3 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/BaseServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/BaseServiceTest.java @@ -409,6 +409,10 @@ protected Map convertCaseDataToStringRepresentation(Map actual = documentCheckerService.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN); + assertThat(actual).containsExactly("docx warning"); + } + + @Test + void testMultipleWarningsReturnedCheckers() throws DocumentContentCheckerException { + final CaseDocument caseDocument = buildCaseDocument(); + + when(downloadService.download(any(), eq(AUTH_TOKEN))).thenReturn(new byte[]{}); + when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); + when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any())).thenReturn(List.of("docx warning")); + when(duplicateFilenameDocumentChecker.canCheck(caseDocument)).thenReturn(true); + when(duplicateFilenameDocumentChecker.getWarnings(eq(caseDocument), any(), any())).thenReturn(List.of("duplicate warning")); + + List actual = documentCheckerService.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN); + assertThat(actual).contains("docx warning", "duplicate warning"); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java index 64952586b3..f7e7919943 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java @@ -63,6 +63,10 @@ private static FinremCaseDetails.FinremCaseDetailsBuilder getFinremCaseDetailsBu .data(finremCaseData); } + public static CaseDocument buildCaseDocument() { + return buildCaseDocument("url", "binaryUrl", "filename"); + } + public static CaseDocument buildCaseDocument(String url, String binaryUrl, String filename) { return buildCaseDocument(url, binaryUrl, filename, null); } From 281c65d8cdd6fb1c3f9f6ed3b953a6195c6c34f6 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 14 Jun 2024 16:05:58 +0100 Subject: [PATCH 33/96] Add test case for the logger. --- .../DocumentCheckerService.java | 4 +++- .../DocumentCheckerServiceTest.java | 23 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java index 266ddc05fc..f780b2693f 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java @@ -10,6 +10,8 @@ import java.util.Collections; import java.util.List; +import static java.lang.String.format; + @Service @Slf4j public class DocumentCheckerService { @@ -40,7 +42,7 @@ public List getWarnings(CaseDocument caseDocument, FinremCaseDetails cas try { warnings.addAll(dc.getWarnings(caseDocument, bytes, caseDetails)); } catch (DocumentContentCheckerException e) { - log.error("Unexpected error", e); + log.error(format("Unexpected error when getting warnings from %s", dc.getClass().getName()), e); } }); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java index 78c8b5e8ca..4511de166a 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java @@ -9,6 +9,8 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.service.evidencemanagement.EvidenceManagementDownloadService; +import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogger; +import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogs; import java.util.List; @@ -21,8 +23,12 @@ @ExtendWith(SpringExtension.class) class DocumentCheckerServiceTest extends BaseServiceTest { + + @TestLogs + private final TestLogger logs = new TestLogger(DocumentCheckerService.class); + @Autowired - private DocumentCheckerService documentCheckerService; + private DocumentCheckerService underTest; @MockBean private DocxDocumentChecker docxDocumentChecker; @@ -41,7 +47,7 @@ void testSingleWarningReturnedByDocxDocumentChecker() throws DocumentContentChec when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any())).thenReturn(List.of("docx warning")); - List actual = documentCheckerService.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN); + List actual = underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN); assertThat(actual).containsExactly("docx warning"); } @@ -55,7 +61,18 @@ void testMultipleWarningsReturnedCheckers() throws DocumentContentCheckerExcepti when(duplicateFilenameDocumentChecker.canCheck(caseDocument)).thenReturn(true); when(duplicateFilenameDocumentChecker.getWarnings(eq(caseDocument), any(), any())).thenReturn(List.of("duplicate warning")); - List actual = documentCheckerService.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN); + List actual = underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN); assertThat(actual).contains("docx warning", "duplicate warning"); } + + @Test + void testIfDockerCheckerThrowDocumentContentCheckerException() throws DocumentContentCheckerException { + final CaseDocument caseDocument = buildCaseDocument(); + when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); + when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any())) + .thenThrow(new DocumentContentCheckerException(new RuntimeException("test"))); + + underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN); + assertThat(logs.getErrors()).isNotEmpty().contains("Unexpected error when getting warnings from " + DocxDocumentChecker.class.getName()); + } } From ec5001af1642488e3bbb25599b948e548847b853 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 14 Jun 2024 16:22:31 +0100 Subject: [PATCH 34/96] add missing case - removing the existing doc. --- .../service/DocumentUploadServiceV2Test.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java index e3e5022d1c..f38ad45447 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java @@ -134,6 +134,17 @@ private static Stream provideArguments() { .build() ) ), + // 1.5 removing existing doc + Arguments.of((Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); + return finremCaseDataBuilder; + }, + (Function) finremCaseDataBuilder -> { + return finremCaseDataBuilder; + }, + (Function) FinremCaseData::getUploadGeneralDocuments, + List.of() + ), // 2. uploadDocuments // 2.1 with new doc From e3a394433d70a7dbde41051da11644555be6240b Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 14 Jun 2024 16:37:06 +0100 Subject: [PATCH 35/96] update test cases --- .../ApplicantNameDocumentContentCheckerTest.java | 13 ++++++++++--- .../RespondentNameDocumentContentCheckerTest.java | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java index a6f1913cb6..996aefe436 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java @@ -1,6 +1,8 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; @@ -11,15 +13,20 @@ class ApplicantNameDocumentContentCheckerTest { private final ApplicantNameDocumentContentChecker underTest = new ApplicantNameDocumentContentChecker(); - @Test - void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndLastName() { + @ParameterizedTest + @ValueSource(strings = { + "The applicant is Joe Bloggs", + "The applicant is Joe Bloggs ", + " The applicant is Joe Blogg", + " The applicant is Joe Bloggs "}) + void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndLastName(String validContent) { assertThat(underTest.getWarning( getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .applicantFmName("Joe") .applicantLname("Bloggs") .build())).build(), - new String[] {"The applicant is Joe Bloggs"})) + new String[] {validContent})) .isNull(); } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java index 6ff48da0a3..c879259c7a 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java @@ -1,6 +1,8 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; @@ -11,15 +13,20 @@ class RespondentNameDocumentContentCheckerTest { private final RespondentNameDocumentContentChecker underTest = new RespondentNameDocumentContentChecker(); - @Test - void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName() { + @ParameterizedTest + @ValueSource(strings = { + "The respondent is Joe Bloggs", + "The respondent is Joe Bloggs ", + " The respondent is Joe Bloggs", + " The respondent is Joe Bloggs "}) + void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName(String validContent) { assertThat(underTest.getWarning( getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .respondentFmName("Joe") .respondentLname("Bloggs") .build())).build(), - new String[] {"The respondent is Joe Bloggs"})) + new String[] {validContent})) .isNull(); } From 8e8025f40562f4107cedb361de69d15d14e0d0e4 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 14 Jun 2024 16:40:52 +0100 Subject: [PATCH 36/96] fixing test case for removing existing doc --- .../service/DocumentUploadServiceV2Test.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java index f38ad45447..3ad39bde59 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java @@ -67,7 +67,7 @@ private static Stream provideArguments() { .build()) .build()) ), - // 1.2 without new doc + // 1.2 without new doc - no change Arguments.of((Function) finremCaseDataBuilder -> { finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); return finremCaseDataBuilder; @@ -139,9 +139,8 @@ private static Stream provideArguments() { finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); return finremCaseDataBuilder; }, - (Function) finremCaseDataBuilder -> { - return finremCaseDataBuilder; - }, + (Function) finremCaseDataBuilder -> + finremCaseDataBuilder, (Function) FinremCaseData::getUploadGeneralDocuments, List.of() ), @@ -180,7 +179,7 @@ void givenCaseWithExistingDocument_whenDocumentUploadedOrNot_thenReturnExpectedD Function>> accessor, List> expectedReturn) { FinremCaseData caseDataBefore = caseDataBeforeModifier.apply(FinremCaseData.builder()).build(); - FinremCaseData caseData = caseDataModifier.apply(caseDataBefore.toBuilder()).build(); + FinremCaseData caseData = caseDataModifier.apply(FinremCaseData.builder()).build(); assertEquals(expectedReturn, documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, accessor)); } } From 4d5594291c0ad35e9c6fe7d4ad0f3485e6247a37 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 14 Jun 2024 17:15:57 +0100 Subject: [PATCH 37/96] Add testNoDocumentCheckerCanCheck --- .../DocumentCheckerServiceTest.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java index 4511de166a..5c111d931a 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java @@ -1,10 +1,11 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.finrem.caseorchestration.BaseServiceTest; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; @@ -12,6 +13,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogger; import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogs; +import java.util.Arrays; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -20,25 +22,30 @@ import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.AUTH_TOKEN; -@ExtendWith(SpringExtension.class) +@ExtendWith(MockitoExtension.class) class DocumentCheckerServiceTest extends BaseServiceTest { - @TestLogs private final TestLogger logs = new TestLogger(DocumentCheckerService.class); - @Autowired + @InjectMocks private DocumentCheckerService underTest; - @MockBean + @Mock private DocxDocumentChecker docxDocumentChecker; - @MockBean + @Mock private DuplicateFilenameDocumentChecker duplicateFilenameDocumentChecker; - @MockBean + @Mock private EvidenceManagementDownloadService downloadService; + @BeforeEach + public void setUp() { + List documentCheckers = Arrays.asList(docxDocumentChecker, duplicateFilenameDocumentChecker); + underTest = new DocumentCheckerService(downloadService, documentCheckers); + } + @Test void testSingleWarningReturnedByDocxDocumentChecker() throws DocumentContentCheckerException { final CaseDocument caseDocument = buildCaseDocument(); @@ -66,7 +73,7 @@ void testMultipleWarningsReturnedCheckers() throws DocumentContentCheckerExcepti } @Test - void testIfDockerCheckerThrowDocumentContentCheckerException() throws DocumentContentCheckerException { + void testIfDocxCheckerThrowDocumentContentCheckerException() throws DocumentContentCheckerException { final CaseDocument caseDocument = buildCaseDocument(); when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any())) @@ -75,4 +82,13 @@ void testIfDockerCheckerThrowDocumentContentCheckerException() throws DocumentCo underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN); assertThat(logs.getErrors()).isNotEmpty().contains("Unexpected error when getting warnings from " + DocxDocumentChecker.class.getName()); } + + @Test + void testNoDocumentCheckerCanCheck(){ + final CaseDocument caseDocument = buildCaseDocument(); + when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(false); + when(duplicateFilenameDocumentChecker.canCheck(caseDocument)).thenReturn(false); + + assertThat(underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN)).isEmpty(); + } } From 0a9e580b18218c0d1d76a539a2bc27a55b316e73 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 17 Jun 2024 10:58:25 +0100 Subject: [PATCH 38/96] Write test case for DocxDocumentChecker --- .../documentchecker/DocxDocumentChecker.java | 5 +- .../DocumentCheckerServiceTest.java | 2 +- .../DocxDocumentCheckerTest.java | 101 +++++++++++++++++- .../caseorchestration/util/TestResource.java | 6 ++ 4 files changed, 110 insertions(+), 4 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java index 4d7c72a067..c4809bd8e9 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java @@ -9,9 +9,9 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.DocumentContentChecker; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.io.InputStream; import java.util.List; +import java.util.Objects; @Component public class DocxDocumentChecker implements DocumentChecker { @@ -34,6 +34,7 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC return documentContentCheckers.stream() .map(dcc -> dcc.getWarning(caseDetails, content)) + .filter(Objects::nonNull) .toList(); } @@ -44,7 +45,7 @@ private String[] getContent(byte[] caseDocument) throws DocumentContentCheckerEx String content = extractor.getText(); return content.split(System.lineSeparator()); - } catch (IOException e) { + } catch (Exception e) { throw new DocumentContentCheckerException(e); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java index 5c111d931a..dc3cec4ca5 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java @@ -84,7 +84,7 @@ void testIfDocxCheckerThrowDocumentContentCheckerException() throws DocumentCont } @Test - void testNoDocumentCheckerCanCheck(){ + void testNoDocumentCheckerCanCheck() { final CaseDocument caseDocument = buildCaseDocument(); when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(false); when(duplicateFilenameDocumentChecker.canCheck(caseDocument)).thenReturn(false); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java index 958ab35bc4..8c89e61988 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java @@ -1,4 +1,103 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; -public class DocxDocumentCheckerTest { +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.CaseNumberDocumentContentChecker; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.DocumentContentChecker; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.RespondentNameDocumentContentChecker; + +import java.io.IOException; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getPathFromResources; + +@ExtendWith(MockitoExtension.class) +class DocxDocumentCheckerTest { + + @InjectMocks + private DocxDocumentChecker underTest; + + @Mock + private RespondentNameDocumentContentChecker respondentNameDocumentContentChecker; + + @Mock + private CaseNumberDocumentContentChecker caseNumberDocumentContentChecker; + + @BeforeEach + public void setUp() { + List documentContentCheckers = Arrays.asList(respondentNameDocumentContentChecker, + caseNumberDocumentContentChecker); + underTest = new DocxDocumentChecker(documentContentCheckers); + } + + @Test + void testCanCheck_withDocxExtension() { + CaseDocument caseDocument = new CaseDocument(); + caseDocument.setDocumentFilename("test.docx"); + + assertThat(underTest.canCheck(caseDocument)).isTrue(); + } + + @Test + void testCanCheck_withNonDocxExtension() { + CaseDocument caseDocument = new CaseDocument(); + caseDocument.setDocumentFilename("test.pdf"); + + assertThat(underTest.canCheck(caseDocument)).isFalse(); + } + + @ParameterizedTest + @ValueSource(ints = {0, 1}) + void testGetWarnings_withValidContent(int testCase) throws DocumentContentCheckerException, IOException { + CaseDocument caseDocument = new CaseDocument(); + caseDocument.setDocumentFilename("generalOrder.docx"); + FinremCaseDetails caseDetails = new FinremCaseDetails(); + + byte[] documentBytes = Files.readAllBytes(getPathFromResources("fixtures/documentcontentvalidation/generalOrder.docx")); + + when(respondentNameDocumentContentChecker.getWarning(eq(caseDetails), any(String[].class))) + .thenReturn("Warning1"); + when(caseNumberDocumentContentChecker.getWarning(eq(caseDetails), any(String[].class))) + .thenReturn(testCase == 1 ? null : "Warning2"); + + List warnings = underTest.getWarnings(caseDocument, documentBytes, caseDetails); + + assertThat(warnings).hasSize(testCase == 1 ? 1 : 2).contains("Warning1"); + + if (testCase == 0) { + assertThat(warnings).hasSize(2).contains("Warning1", "Warning2"); + } else if (testCase == 1) { + assertThat(warnings).hasSize(1).contains("Warning1"); + } else { + fail("Unexpected number of warnings: " + warnings.size()); + } + } + + @Test + void testGetWarnings_whenGivenFileCannotBeRead() { + CaseDocument caseDocument = new CaseDocument(); + caseDocument.setDocumentFilename("test.docx"); + FinremCaseDetails caseDetails = new FinremCaseDetails(); + byte[] documentBytes = "Invalid content".getBytes(); + + assertThatThrownBy(() -> underTest.getWarnings(caseDocument, documentBytes, caseDetails)) + .isInstanceOf(DocumentContentCheckerException.class); + } + } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java index f7e7919943..4a12a3ecc0 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java @@ -8,6 +8,8 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.document.Document; import uk.gov.hmcts.reform.finrem.caseorchestration.model.evidence.FileUploadResponse; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Collections; import java.util.List; @@ -79,4 +81,8 @@ public static CaseDocument buildCaseDocument(String url, String binaryUrl, Strin document.setCategoryId(categoryId); return document; } + + public static Path getPathFromResources(String fileName) { + return Paths.get("src/test/resources/" + fileName); + } } From 34e8e9ef53889fc97aec5107cec7e3ea1260a1c6 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 17 Jun 2024 11:45:43 +0100 Subject: [PATCH 39/96] Test cases for CaseNumberDocumentContentChecker --- .../CaseNumberDocumentContentChecker.java | 7 ++- .../DocxDocumentCheckerTest.java | 7 +-- ...plicantNameDocumentContentCheckerTest.java | 3 +- .../CaseNumberDocumentContentCheckerTest.java | 45 +++++++++++++++++++ ...pondentNameDocumentContentCheckerTest.java | 3 +- 5 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java index 719224e875..8418c42435 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java @@ -6,6 +6,8 @@ import java.util.stream.Stream; +import static java.util.Optional.ofNullable; + @Component public class CaseNumberDocumentContentChecker implements DocumentContentChecker { @@ -26,7 +28,10 @@ private boolean containsCaseNumber(String text) { private boolean contentCaseNumberNotEqualsCaseNumber(FinremCaseDetails caseDetails, String content) { long caseNumberFromContent = getCaseNumberFromContent(content); - return caseNumberFromContent != caseDetails.getId(); + if (caseDetails.getId() == null) { + return false; + } + return caseNumberFromContent != ofNullable(caseDetails.getId()).orElse(0L); } private long getCaseNumberFromContent(String text) { diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java index 8c89e61988..e3d185a17b 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java @@ -46,10 +46,11 @@ public void setUp() { underTest = new DocxDocumentChecker(documentContentCheckers); } - @Test - void testCanCheck_withDocxExtension() { + @ParameterizedTest + @ValueSource(strings = {"test.docx", "test.DOCX", "test.DOCx"}) + void testCanCheck_withDocxExtension(String filename) { CaseDocument caseDocument = new CaseDocument(); - caseDocument.setDocumentFilename("test.docx"); + caseDocument.setDocumentFilename(filename); assertThat(underTest.canCheck(caseDocument)).isTrue(); } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java index 996aefe436..a0e164e1a1 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java @@ -18,7 +18,8 @@ class ApplicantNameDocumentContentCheckerTest { "The applicant is Joe Bloggs", "The applicant is Joe Bloggs ", " The applicant is Joe Blogg", - " The applicant is Joe Bloggs "}) + " The applicant is Joe Bloggs ", + "whatever"}) void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndLastName(String validContent) { assertThat(underTest.getWarning( getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java new file mode 100644 index 0000000000..8d5766f487 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java @@ -0,0 +1,45 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; + +import static org.assertj.core.api.Assertions.assertThat; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getConsentedFinremCaseDetailsBuilder; + +class CaseNumberDocumentContentCheckerTest { + + private final CaseNumberDocumentContentChecker underTest = new CaseNumberDocumentContentChecker(); + + @ParameterizedTest + @ValueSource(strings = { + "Case number 1234567890", + "Case number 1234567890 ", + " Case number 1234567890", + " Case number 1234567890 ", + "whatever"}) + void givenCaseData_whenContentContainCaseNumber(String validContent) { + assertThat(underTest.getWarning(getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder()).build(), + new String[] {validContent})).isNull(); + } + + @Test + void givenCaseData_whenContentDoesNotMatchCaseNumber() { + assertThat(underTest.getWarning(getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder()).build(), + new String[] {"Case number 1234567891"})).isEqualTo("Case numbers may not match"); + } + + @ParameterizedTest + @ValueSource(strings = { + "Case number 1234567890", + "Case number 1234567890 ", + " Case number 1234567890", + " Case number 1234567890 ", + "whatever"}) + void givenCaseDataWithoutId_whenContentDoesNotMatchCaseNumber(String content) { + assertThat(underTest.getWarning(FinremCaseDetails.builder().build(), new String[] {content})).isNull(); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java index c879259c7a..230902db3d 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java @@ -18,7 +18,8 @@ class RespondentNameDocumentContentCheckerTest { "The respondent is Joe Bloggs", "The respondent is Joe Bloggs ", " The respondent is Joe Bloggs", - " The respondent is Joe Bloggs "}) + " The respondent is Joe Bloggs ", + "whatever"}) void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName(String validContent) { assertThat(underTest.getWarning( getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() From f1e3b2920c6e5aea4ef5c35bffd99d84109875bf Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 17 Jun 2024 14:24:32 +0100 Subject: [PATCH 40/96] Test case for DuplicateFilenameDocumentChecker --- .../DuplicateFilenameDocumentChecker.java | 4 +- .../DuplicateFilenameDocumentCheckerTest.java | 154 +++++++++++++----- 2 files changed, 116 insertions(+), 42 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index a0d73aa4b6..a171e87733 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -9,6 +9,8 @@ import java.util.List; import java.util.function.Supplier; +import static org.apache.commons.lang3.ObjectUtils.isNotEmpty; + @Component public class DuplicateFilenameDocumentChecker implements DocumentChecker { @@ -24,7 +26,7 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC throws DocumentContentCheckerException { FinremCaseData caseData = caseDetails.getData(); - if (isDuplicateFilename(caseDocument, caseData::getAdditionalDocument)) { + if (isNotEmpty(caseData.getAdditionalDocument()) && isDuplicateFilename(caseDocument, caseData::getAdditionalDocument)) { return List.of(WARNING); } if (isDuplicateFilename(caseDocument, caseData.getGeneralOrderWrapper()::getGeneralOrderLatestDocument)) { diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index 6f5ce95f5a..ef20a31d51 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -1,46 +1,118 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralOrderWrapper; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) class DuplicateFilenameDocumentCheckerTest { -// @Test -// void givenFilenameExistsOnGeneralOrderLatestDocument_whenChecksFailCalled_thenReturnsTrue() throws DocumentContentCheckerException { -// String filename = "generalOrder-123.pd"; -// CaseDocument caseDocument = CaseDocument.builder() -// .documentFilename(filename) -// .build(); -// FinremCaseData caseData = FinremCaseData.builder() -// .generalOrderWrapper(GeneralOrderWrapper.builder() -// .generalOrderLatestDocument(caseDocument) -// .build()) -// .build(); -// -// CaseDocument caseDocumentToCheck = CaseDocument.builder() -// .documentFilename(filename) -// .build(); -// -// DuplicateFilenameDocumentChecker checker = new DuplicateFilenameDocumentChecker(); -// -// assertThat(checker.checksFail(caseDocumentToCheck, new byte[0], caseData)).isTrue(); -// } -// -// @Test -// void givenFilenameNotExistsOnGeneralOrderLatestDocument_whenChecksFailCalled_thenReturnsFalse() throws DocumentContentCheckerException { -// String filename = "generalOrder-123.pdf"; -// CaseDocument caseDocument = CaseDocument.builder() -// .documentFilename(filename) -// .build(); -// FinremCaseData caseData = FinremCaseData.builder() -// .generalOrderWrapper(GeneralOrderWrapper.builder() -// .generalOrderLatestDocument(caseDocument) -// .build()) -// .build(); -// -// CaseDocument caseDocumentToCheck = CaseDocument.builder() -// .documentFilename("generalOrder-456.pdf") -// .build(); -// -// DuplicateFilenameDocumentChecker checker = new DuplicateFilenameDocumentChecker(); -// -// assertThat(checker.getWarnings(caseDocumentToCheck, new byte[0], caseData)).isFalse(); -// } + private static final String WARNING = "A document with this filename already exists on the case"; + + @Mock + private CaseDocument inptuCaseDocument; + @Mock + private FinremCaseDetails caseDetails; + @Mock + private FinremCaseData caseData; + @Mock + private CaseDocument additionalDocument; + @Mock + private GeneralOrderWrapper generalOrderWrapper; + @Mock + private CaseDocument generalOrderDocument; + + @InjectMocks + private DuplicateFilenameDocumentChecker underTest; + + @BeforeEach + public void setUp() { + underTest = new DuplicateFilenameDocumentChecker(); + when(inptuCaseDocument.getDocumentFilename()).thenReturn("inputFilename"); + } + + @Test + void testCanCheck_alwaysReturnsTrue() { + assertThat(underTest.canCheck(new CaseDocument())).isTrue(); + assertThat(underTest.canCheck(null)).isTrue(); + assertThat(underTest.canCheck(inptuCaseDocument)).isTrue(); + } + + @Test + void testGetWarnings_NoDuplicate() throws DocumentContentCheckerException { + when(caseDetails.getData()).thenReturn(caseData); + when(caseData.getAdditionalDocument()).thenReturn(additionalDocument); + when(caseData.getGeneralOrderWrapper()).thenReturn(generalOrderWrapper); + when(generalOrderDocument.getDocumentFilename()).thenReturn("generalOrderDocumentFilename"); + + when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); + when(additionalDocument.getDocumentFilename()).thenReturn("additionalDocumentFilename"); + + List warnings = underTest.getWarnings(inptuCaseDocument, new byte[0], caseDetails); + + assertThat(warnings).isEmpty(); + } + + @Test + void testGetWarnings_NoDuplicateWhenAdditionalDocumentIsNull() throws DocumentContentCheckerException { + when(caseDetails.getData()).thenReturn(caseData); + when(caseData.getAdditionalDocument()).thenReturn(null); + when(caseData.getGeneralOrderWrapper()).thenReturn(generalOrderWrapper); + when(generalOrderDocument.getDocumentFilename()).thenReturn("generalOrderDocumentFilename"); + + when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); + + List warnings = underTest.getWarnings(inptuCaseDocument, new byte[0], caseDetails); + + assertThat(warnings).isEmpty(); + } + + @Test + void testGetWarnings_DuplicateInAdditionalDocument() throws DocumentContentCheckerException { + when(caseDetails.getData()).thenReturn(caseData); + when(caseData.getAdditionalDocument()).thenReturn(additionalDocument); + when(additionalDocument.getDocumentFilename()).thenReturn("inputFilename"); + + List warnings = underTest.getWarnings(inptuCaseDocument, new byte[0], caseDetails); + + assertThat(warnings).hasSize(1).containsExactly(WARNING); + } + + @Test + void testGetWarnings_DuplicateInGeneralOrderDocument() throws DocumentContentCheckerException { + when(caseDetails.getData()).thenReturn(caseData); + when(caseData.getAdditionalDocument()).thenReturn(additionalDocument); + when(additionalDocument.getDocumentFilename()).thenReturn("additionalDocumentFilename"); + when(generalOrderDocument.getDocumentFilename()).thenReturn("inputFilename"); + when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); + when(caseData.getGeneralOrderWrapper()).thenReturn(generalOrderWrapper); + + List warnings = underTest.getWarnings(inptuCaseDocument, new byte[0], caseDetails); + + assertThat(warnings).hasSize(1).containsExactly(WARNING); + } + + @Test + void testGetWarnings_NoCaseData() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(inptuCaseDocument, new byte[0], FinremCaseDetails.builder() + .data(FinremCaseData.builder().build()) + .build()); + + assertThat(warnings).isEmpty(); + } } From 5ddab6891913bdb91b818e6e89eb07119a9b3f73 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 17 Jun 2024 14:42:47 +0100 Subject: [PATCH 41/96] Unit tests for PdfDocumentChecker --- .../documentchecker/PdfDocumentChecker.java | 2 + .../PdfDocumentCheckerTest.java | 160 +++++++++++------- 2 files changed, 100 insertions(+), 62 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java index 9904305bba..f4948de614 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.util.List; +import java.util.Objects; @Component public class PdfDocumentChecker implements DocumentChecker { @@ -33,6 +34,7 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC return documentContentCheckers.stream() .map(dcc -> dcc.getWarning(caseDetails, content)) + .filter(Objects::nonNull) .toList(); } catch (IOException e) { throw new DocumentContentCheckerException(e); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java index 15154b0376..f0a1a1a676 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java @@ -1,67 +1,103 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.CaseNumberDocumentContentChecker; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.DocumentContentChecker; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.RespondentNameDocumentContentChecker; + +import java.io.IOException; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getPathFromResources; + +@ExtendWith(MockitoExtension.class) class PdfDocumentCheckerTest { -} -//package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; -// -//import com.google.common.net.MediaType; -//import org.junit.jupiter.api.Test; -//import org.junit.jupiter.params.ParameterizedTest; -//import org.junit.jupiter.params.provider.Arguments; -//import org.junit.jupiter.params.provider.MethodSource; -//import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; -//import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; -//import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.ApplicantNameDocumentContentChecker; -// -//import java.io.IOException; -//import java.net.URISyntaxException; -//import java.nio.file.Files; -//import java.nio.file.Paths; -//import java.util.Objects; -//import java.util.stream.Stream; -// -//import static org.assertj.core.api.Assertions.assertThat; -// -//class PdfAppRespValidatorTest { -// -// @Test -// void testDoesNotHandleWordDoc() throws DocumentContentCheckerException { -// FinremCaseData caseData = new FinremCaseData(); -// MediaType mediaType = MediaType.MICROSOFT_WORD; -// byte[] document = new byte[100]; -// -// ApplicantNameDocumentContentChecker validator = new ApplicantNameDocumentContentChecker(); -// assertThat(validator.isContentInvalid(caseData, mediaType, document)).isFalse(); -// } -// @ParameterizedTest -// @MethodSource -// void testApplicantNameValidation(String applicantFirstName, String applicantLastName, boolean expectedIsInvalid) -// throws IOException, DocumentContentCheckerException, URISyntaxException { -// FinremCaseData caseData = FinremCaseData.builder() -// .contactDetailsWrapper(ContactDetailsWrapper.builder() -// .build() -// ) -// .build(); -// byte[] document = loadTestFile("fixtures/documentcontentvalidation/generalOrder.pdf"); -// -// ApplicantNameDocumentContentChecker validator = new ApplicantNameDocumentContentChecker(); -// -// assertThat(validator.isContentInvalid(caseData, MediaType.PDF, document)).isEqualTo(expectedIsInvalid); -// } -// -// private static Stream testApplicantNameValidation() { -// return Stream.of( -// Arguments.of("Doris", "Duck", false), -// Arguments.of("Davey", "Duck", false), -// Arguments.of("Donald", "Duck", true), -// Arguments.of("Bella", "Smith", true) -// ); -// } -// -// private byte[] loadTestFile(String filename) throws IOException, URISyntaxException { -// return Files.readAllBytes(Paths.get(Objects.requireNonNull(Thread.currentThread() -// .getContextClassLoader().getResource(filename)).toURI())); -// } -//} + @InjectMocks + private PdfDocumentChecker underTest; + + @Mock + private RespondentNameDocumentContentChecker respondentNameDocumentContentChecker; + + @Mock + private CaseNumberDocumentContentChecker caseNumberDocumentContentChecker; + + @BeforeEach + public void setUp() { + List documentContentCheckers = Arrays.asList(respondentNameDocumentContentChecker, + caseNumberDocumentContentChecker); + underTest = new PdfDocumentChecker(documentContentCheckers); + } + + @ParameterizedTest + @ValueSource(strings = {"test.pdf", "test.PDF", "test.PdF"}) + void testCanCheck_withPdfExtension(String filename) { + CaseDocument caseDocument = new CaseDocument(); + caseDocument.setDocumentFilename(filename); + + assertThat(underTest.canCheck(caseDocument)).isTrue(); + } + + @Test + void testCanCheck_withNonPdfExtension() { + CaseDocument caseDocument = new CaseDocument(); + caseDocument.setDocumentFilename("test.docx"); + assertThat(underTest.canCheck(caseDocument)).isFalse(); + } + + @ParameterizedTest + @ValueSource(ints = {0, 1}) + void testGetWarnings_withValidContent(int testCase) throws DocumentContentCheckerException, IOException { + CaseDocument caseDocument = new CaseDocument(); + caseDocument.setDocumentFilename("generalOrder.pdf"); + FinremCaseDetails caseDetails = new FinremCaseDetails(); + + byte[] documentBytes = Files.readAllBytes(getPathFromResources("fixtures/documentcontentvalidation/generalOrder.pdf")); + + when(respondentNameDocumentContentChecker.getWarning(eq(caseDetails), any(String[].class))) + .thenReturn("Warning1"); + when(caseNumberDocumentContentChecker.getWarning(eq(caseDetails), any(String[].class))) + .thenReturn(testCase == 1 ? null : "Warning2"); + + List warnings = underTest.getWarnings(caseDocument, documentBytes, caseDetails); + + assertThat(warnings).hasSize(testCase == 1 ? 1 : 2).contains("Warning1"); + + if (testCase == 0) { + assertThat(warnings).hasSize(2).contains("Warning1", "Warning2"); + } else if (testCase == 1) { + assertThat(warnings).hasSize(1).contains("Warning1"); + } else { + fail("Unexpected number of warnings: " + warnings.size()); + } + } + + @Test + void testGetWarnings_whenGivenFileCannotBeRead() { + CaseDocument caseDocument = new CaseDocument(); + caseDocument.setDocumentFilename("test.pdf"); + FinremCaseDetails caseDetails = new FinremCaseDetails(); + byte[] documentBytes = "Invalid content".getBytes(); + + assertThatThrownBy(() -> underTest.getWarnings(caseDocument, documentBytes, caseDetails)) + .isInstanceOf(DocumentContentCheckerException.class); + } +} From 2e586fb977d636e33660a92f88c5c52489c88278 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 17 Jun 2024 15:29:16 +0100 Subject: [PATCH 42/96] Introducing PdfDocumentReader and DocxDocumentReader --- .../documentchecker/DocxDocumentChecker.java | 18 ++++---- .../documentchecker/PdfDocumentChecker.java | 15 ++++--- .../documentreader/DocxDocumentReader.java | 21 ++++++++++ .../documentreader/PdfDocumentReader.java | 19 +++++++++ .../DocxDocumentCheckerTest.java | 10 ++++- .../PdfDocumentCheckerTest.java | 10 ++++- .../WordDocXValidatorTest.java | 37 ---------------- .../DocxDocumentReaderTest.java | 42 +++++++++++++++++++ .../documentreader/PdfDocumentReaderTest.java | 41 ++++++++++++++++++ 9 files changed, 153 insertions(+), 60 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReader.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/PdfDocumentReader.java delete mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/WordDocXValidatorTest.java create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReaderTest.java create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/PdfDocumentReaderTest.java diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java index c4809bd8e9..3027b013ff 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java @@ -1,24 +1,24 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; import org.apache.commons.io.FilenameUtils; -import org.apache.poi.xwpf.extractor.XWPFWordExtractor; -import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.DocumentContentChecker; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentreader.DocxDocumentReader; -import java.io.ByteArrayInputStream; -import java.io.InputStream; import java.util.List; import java.util.Objects; @Component public class DocxDocumentChecker implements DocumentChecker { + private final DocxDocumentReader docxDocumentReader; + private final List documentContentCheckers; - public DocxDocumentChecker(List documentContentCheckers) { + public DocxDocumentChecker(DocxDocumentReader docxDocumentReader, List documentContentCheckers) { + this.docxDocumentReader = docxDocumentReader; this.documentContentCheckers = documentContentCheckers; } @@ -39,12 +39,8 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC } private String[] getContent(byte[] caseDocument) throws DocumentContentCheckerException { - InputStream is = new ByteArrayInputStream(caseDocument); - try (XWPFDocument wordDoc = new XWPFDocument(is)) { - XWPFWordExtractor extractor = new XWPFWordExtractor(wordDoc); - String content = extractor.getText(); - return content.split(System.lineSeparator()); - + try { + return docxDocumentReader.getContent(caseDocument); } catch (Exception e) { throw new DocumentContentCheckerException(e); } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java index f4948de614..a34a2ccb9f 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java @@ -1,12 +1,11 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; import org.apache.commons.io.FilenameUtils; -import org.apache.pdfbox.pdmodel.PDDocument; -import org.apache.pdfbox.text.PDFTextStripper; import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.DocumentContentChecker; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentreader.PdfDocumentReader; import java.io.IOException; import java.util.List; @@ -17,7 +16,11 @@ public class PdfDocumentChecker implements DocumentChecker { private final List documentContentCheckers; - public PdfDocumentChecker(List documentContentCheckers) { + private final PdfDocumentReader pdfDocumentReader; + + public PdfDocumentChecker(PdfDocumentReader pdfDocumentReader, + List documentContentCheckers) { + this.pdfDocumentReader = pdfDocumentReader; this.documentContentCheckers = documentContentCheckers; } @@ -42,10 +45,6 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC } private String[] getContent(byte[] bytes) throws IOException { - try (PDDocument document = PDDocument.load(bytes)) { - PDFTextStripper stripper = new PDFTextStripper(); - String content = stripper.getText(document); - return content.split(System.lineSeparator()); - } + return pdfDocumentReader.getContent(bytes); } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReader.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReader.java new file mode 100644 index 0000000000..2ddc3b23bd --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReader.java @@ -0,0 +1,21 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentreader; + +import org.apache.poi.xwpf.extractor.XWPFWordExtractor; +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.springframework.stereotype.Component; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +@Component +public class DocxDocumentReader { + + public String[] getContent(byte[] bytes) throws IOException { + InputStream is = new ByteArrayInputStream(bytes); + XWPFDocument wordDoc = new XWPFDocument(is); + XWPFWordExtractor extractor = new XWPFWordExtractor(wordDoc); + String content = extractor.getText(); + return content.split(System.lineSeparator()); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/PdfDocumentReader.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/PdfDocumentReader.java new file mode 100644 index 0000000000..1c0ff35c17 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/PdfDocumentReader.java @@ -0,0 +1,19 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentreader; + +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.text.PDFTextStripper; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +@Component +public class PdfDocumentReader { + + public String[] getContent(byte[] bytes) throws IOException { + try (PDDocument document = PDDocument.load(bytes)) { + PDFTextStripper stripper = new PDFTextStripper(); + String content = stripper.getText(document); + return content.split(System.lineSeparator()); + } + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java index e3d185a17b..29732d7884 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java @@ -13,6 +13,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.CaseNumberDocumentContentChecker; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.DocumentContentChecker; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.RespondentNameDocumentContentChecker; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentreader.DocxDocumentReader; import java.io.IOException; import java.nio.file.Files; @@ -39,11 +40,14 @@ class DocxDocumentCheckerTest { @Mock private CaseNumberDocumentContentChecker caseNumberDocumentContentChecker; + @Mock + private DocxDocumentReader docxDocumentReader; + @BeforeEach public void setUp() { List documentContentCheckers = Arrays.asList(respondentNameDocumentContentChecker, caseNumberDocumentContentChecker); - underTest = new DocxDocumentChecker(documentContentCheckers); + underTest = new DocxDocumentChecker(docxDocumentReader, documentContentCheckers); } @ParameterizedTest @@ -66,6 +70,7 @@ void testCanCheck_withNonDocxExtension() { @ParameterizedTest @ValueSource(ints = {0, 1}) void testGetWarnings_withValidContent(int testCase) throws DocumentContentCheckerException, IOException { + when(docxDocumentReader.getContent(any())).thenReturn(new String[0]); CaseDocument caseDocument = new CaseDocument(); caseDocument.setDocumentFilename("generalOrder.docx"); FinremCaseDetails caseDetails = new FinremCaseDetails(); @@ -91,7 +96,8 @@ void testGetWarnings_withValidContent(int testCase) throws DocumentContentChecke } @Test - void testGetWarnings_whenGivenFileCannotBeRead() { + void testGetWarnings_whenGivenFileCannotBeRead() throws IOException { + when(docxDocumentReader.getContent(any())).thenThrow(new IOException("test")); CaseDocument caseDocument = new CaseDocument(); caseDocument.setDocumentFilename("test.docx"); FinremCaseDetails caseDetails = new FinremCaseDetails(); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java index f0a1a1a676..48c2034bf8 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java @@ -13,6 +13,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.CaseNumberDocumentContentChecker; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.DocumentContentChecker; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.RespondentNameDocumentContentChecker; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentreader.PdfDocumentReader; import java.io.IOException; import java.nio.file.Files; @@ -39,11 +40,14 @@ class PdfDocumentCheckerTest { @Mock private CaseNumberDocumentContentChecker caseNumberDocumentContentChecker; + @Mock + private PdfDocumentReader pdfDocumentReader; + @BeforeEach public void setUp() { List documentContentCheckers = Arrays.asList(respondentNameDocumentContentChecker, caseNumberDocumentContentChecker); - underTest = new PdfDocumentChecker(documentContentCheckers); + underTest = new PdfDocumentChecker(pdfDocumentReader, documentContentCheckers); } @ParameterizedTest @@ -66,6 +70,7 @@ void testCanCheck_withNonPdfExtension() { @ParameterizedTest @ValueSource(ints = {0, 1}) void testGetWarnings_withValidContent(int testCase) throws DocumentContentCheckerException, IOException { + when(pdfDocumentReader.getContent(any())).thenReturn(new String[0]); CaseDocument caseDocument = new CaseDocument(); caseDocument.setDocumentFilename("generalOrder.pdf"); FinremCaseDetails caseDetails = new FinremCaseDetails(); @@ -91,7 +96,8 @@ void testGetWarnings_withValidContent(int testCase) throws DocumentContentChecke } @Test - void testGetWarnings_whenGivenFileCannotBeRead() { + void testGetWarnings_whenGivenFileCannotBeRead() throws IOException { + when(pdfDocumentReader.getContent(any())).thenThrow(new IOException("test")); CaseDocument caseDocument = new CaseDocument(); caseDocument.setDocumentFilename("test.pdf"); FinremCaseDetails caseDetails = new FinremCaseDetails(); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/WordDocXValidatorTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/WordDocXValidatorTest.java deleted file mode 100644 index 0037839307..0000000000 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/WordDocXValidatorTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; - -class WordDocXValidatorTest { -// @ParameterizedTest -// @MethodSource -// void testApplicantNameValidation(String applicantFmName, String applicantLastName, boolean expectedIsInvalid) -// throws IOException, DocumentContentCheckerException, URISyntaxException { -// FinremCaseData caseData = FinremCaseData.builder() -// .contactDetailsWrapper(ContactDetailsWrapper.builder() -// .applicantFmName(applicantFmName) -// .applicantLname(applicantLastName) -// .respondentFmName("Davey") -// .respondentLname("Duck") -// .build() -// ) -// .build(); -// byte[] document = loadTestFile("fixtures/documentcontentvalidation/generalOrder.docx"); -// -// DocxDocumentChecker validator = new DocxDocumentChecker(); -// -// assertThat(validator.isContentInvalid(caseData, MediaType.MICROSOFT_WORD, document)).isEqualTo(expectedIsInvalid); -// } -// -// private static Stream testApplicantNameValidation() { -// return Stream.of( -// Arguments.of("Doris", "Duck", false), -// Arguments.of("Davey", "Duck", false), -// Arguments.of("Donald", "Duck", true), -// Arguments.of("Bella", "Smith", true) -// ); -// } -// -// private byte[] loadTestFile(String filename) throws IOException, URISyntaxException { -// return Files.readAllBytes(Paths.get(Objects.requireNonNull(Thread.currentThread() -// .getContextClassLoader().getResource(filename)).toURI())); -// } -} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReaderTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReaderTest.java new file mode 100644 index 0000000000..0cab8f8da8 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReaderTest.java @@ -0,0 +1,42 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentreader; + +import org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.io.IOException; +import java.nio.file.Files; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getPathFromResources; + +@ExtendWith(MockitoExtension.class) +class DocxDocumentReaderTest { + + @InjectMocks + private DocxDocumentReader underTest; + + @BeforeEach + public void setUp() { + underTest = new DocxDocumentReader(); + } + + @Test + void testGetContentFromADocxFile() throws IOException { + byte[] document = Files.readAllBytes(getPathFromResources("fixtures/documentcontentvalidation/generalOrder.docx")); + + assertThat(underTest.getContent(document)).containsAnyOf("1. The applicant is Doris Duck The respondent is Davey Duck ", + "Case No: 1708940824018030 "); + } + + @Test + void testGetContent_withError() throws IOException { + byte[] document = Files.readAllBytes(getPathFromResources("fixtures/documentcontentvalidation/generalOrder.pdf")); + + assertThatThrownBy(() -> underTest.getContent(document)).isInstanceOf(NotOfficeXmlFileException.class); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/PdfDocumentReaderTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/PdfDocumentReaderTest.java new file mode 100644 index 0000000000..5e3f0c1fff --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/PdfDocumentReaderTest.java @@ -0,0 +1,41 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentreader; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.io.IOException; +import java.nio.file.Files; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getPathFromResources; + +@ExtendWith(MockitoExtension.class) +class PdfDocumentReaderTest { + + @InjectMocks + private PdfDocumentReader underTest; + + @BeforeEach + public void setUp() { + underTest = new PdfDocumentReader(); + } + + @Test + void testGetContentFromADocxFile() throws IOException { + byte[] document = Files.readAllBytes(getPathFromResources("fixtures/documentcontentvalidation/generalOrder.pdf")); + + assertThat(underTest.getContent(document)).containsAnyOf("1. The applicant is Doris Duck", + "In the Family Court Case No: 1708940824018030"); + } + + @Test + void testGetContent_withError() throws IOException { + byte[] document = Files.readAllBytes(getPathFromResources("fixtures/documentcontentvalidation/generalOrder.docx")); + + assertThatThrownBy(() -> underTest.getContent(document)).isInstanceOf(IOException.class); + } +} From 383ca06f9548abfd277f36e57cf5cc856db2c297 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 17 Jun 2024 15:30:26 +0100 Subject: [PATCH 43/96] checkstyle --- .../service/documentreader/DocxDocumentReader.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReader.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReader.java index 2ddc3b23bd..0ce05f4d99 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReader.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReader.java @@ -14,8 +14,8 @@ public class DocxDocumentReader { public String[] getContent(byte[] bytes) throws IOException { InputStream is = new ByteArrayInputStream(bytes); XWPFDocument wordDoc = new XWPFDocument(is); - XWPFWordExtractor extractor = new XWPFWordExtractor(wordDoc); - String content = extractor.getText(); - return content.split(System.lineSeparator()); + XWPFWordExtractor extractor = new XWPFWordExtractor(wordDoc); + String content = extractor.getText(); + return content.split(System.lineSeparator()); } } From adc2dbecd0607a00d3ec03fab08c2577cb4260bb Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 17 Jun 2024 15:40:55 +0100 Subject: [PATCH 44/96] remove an extra space. --- .../contentchecker/ApplicantNameDocumentContentChecker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java index 76a936c4ae..ff4bed630a 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java @@ -39,7 +39,7 @@ private boolean contentNameNotEqualsCaseName(FinremCaseData caseData, String con } private String getApplicantNameFromContent(String text) { - return text.replace("1. The applicant is ", "").trim(); + return text.replace("1. The applicant is", "").trim(); } private String getApplicantNameFromCase(FinremCaseData caseData) { From 7de99c027614a902d19d41507f6dce96674735cc Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 17 Jun 2024 15:58:32 +0100 Subject: [PATCH 45/96] Fix parameters --- .../ApplicantNameDocumentContentCheckerTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java index a0e164e1a1..4a6b874b7c 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java @@ -15,10 +15,10 @@ class ApplicantNameDocumentContentCheckerTest { @ParameterizedTest @ValueSource(strings = { - "The applicant is Joe Bloggs", - "The applicant is Joe Bloggs ", - " The applicant is Joe Blogg", - " The applicant is Joe Bloggs ", + "1. The applicant is Joe Bloggs", + "1. The applicant is Joe Bloggs ", + " 1. The applicant is Joe Bloggs", + " 1. The applicant is Joe Bloggs ", "whatever"}) void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndLastName(String validContent) { assertThat(underTest.getWarning( From e7d739fafa1bb331fc1c5b37869e1d0a7a8209c4 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 18 Jun 2024 12:06:36 +0100 Subject: [PATCH 46/96] missing newline at the end of file. --- .../caseorchestration/model/ccd/CaseDocumentCollection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java index 8490823730..c0f26d0ce5 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java @@ -2,4 +2,4 @@ public interface CaseDocumentCollection { T getValue(); -} \ No newline at end of file +} From ad3b23b35e02499dd45ea030e6fcb76cea90be20 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 18 Jun 2024 15:14:54 +0100 Subject: [PATCH 47/96] Simplified the test case. --- .../service/DocumentUploadServiceV2Test.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java index 3ad39bde59..7a4696558c 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java @@ -1,12 +1,8 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import uk.gov.hmcts.reform.finrem.caseorchestration.BaseServiceTest; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocument; @@ -21,11 +17,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -@ExtendWith(SpringExtension.class) -class DocumentUploadServiceV2Test extends BaseServiceTest { +class DocumentUploadServiceV2Test { - @Autowired - private DocumentUploadServiceV2 documentUploadService; + private DocumentUploadServiceV2 documentUploadService = new DocumentUploadServiceV2(); private static Stream provideArguments() { final List existingUploadGeneralDocument = List.of( From f52bf7fdf1afca5492988fbbe305778a6a382e46 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 18 Jun 2024 18:25:26 +0100 Subject: [PATCH 48/96] Update DocumentContentChecker and its test cases --- .../ApplicantNameDocumentContentChecker.java | 7 +-- .../DocumentContentChecker.java | 2 - .../RespondentNameDocumentContentChecker.java | 7 +-- ...plicantNameDocumentContentCheckerTest.java | 50 ++++++++++++++----- ...pondentNameDocumentContentCheckerTest.java | 50 ++++++++++++++----- .../utils/StringDecorator.java | 32 ++++++++++++ 6 files changed, 114 insertions(+), 34 deletions(-) create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/StringDecorator.java diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java index ff4bed630a..d8e9e5d207 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java @@ -9,6 +9,7 @@ import java.util.stream.Stream; import static java.util.Optional.ofNullable; +import static org.apache.commons.lang3.StringUtils.SPACE; import static org.apache.commons.lang3.StringUtils.isEmpty; import static org.apache.commons.lang3.StringUtils.trim; @@ -32,7 +33,7 @@ private boolean containsTheApplicantIs(String text) { private boolean contentNameNotEqualsCaseName(FinremCaseData caseData, String content) { String applicantName = getApplicantNameFromCase(caseData); - if (isEmpty(trim(applicantName))) { + if (isEmpty(applicantName)) { return false; } return !applicantName.equals(getApplicantNameFromContent(content.trim())); @@ -44,7 +45,7 @@ private String getApplicantNameFromContent(String text) { private String getApplicantNameFromCase(FinremCaseData caseData) { ContactDetailsWrapper contactDetails = caseData.getContactDetailsWrapper(); - return ofNullable(contactDetails.getApplicantFmName()).orElse(StringUtils.EMPTY) + SPACE - + ofNullable(contactDetails.getApplicantLname()).orElse(StringUtils.EMPTY); + return trim(trim(ofNullable(contactDetails.getApplicantFmName()).orElse(StringUtils.EMPTY)) + SPACE + + trim(ofNullable(contactDetails.getApplicantLname()).orElse(StringUtils.EMPTY))); } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/DocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/DocumentContentChecker.java index 200226f8a2..d04df55b44 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/DocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/DocumentContentChecker.java @@ -3,7 +3,5 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; public interface DocumentContentChecker { - - public static String SPACE = " "; String getWarning(FinremCaseDetails caseDetails, String[] content); } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java index 54e574eb41..763ef6f03e 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java @@ -9,6 +9,7 @@ import java.util.stream.Stream; import static java.util.Optional.ofNullable; +import static org.apache.commons.lang3.StringUtils.SPACE; import static org.apache.commons.lang3.StringUtils.isEmpty; import static org.apache.commons.lang3.StringUtils.trim; @@ -32,7 +33,7 @@ private boolean containsTheRespondentIs(String text) { private boolean contentNameNotEqualsCaseName(FinremCaseData caseData, String content) { String respondentName = getRespondentNameFromCase(caseData); - if (isEmpty(trim(respondentName))) { + if (isEmpty(respondentName)) { return false; } return !respondentName.equals(getRespondentNameFromContent(content.trim())); @@ -44,7 +45,7 @@ private String getRespondentNameFromContent(String text) { private String getRespondentNameFromCase(FinremCaseData caseData) { ContactDetailsWrapper contactDetails = caseData.getContactDetailsWrapper(); - return ofNullable(contactDetails.getRespondentFmName()).orElse(StringUtils.EMPTY) + SPACE - + ofNullable(contactDetails.getRespondentLname()).orElse(StringUtils.EMPTY); + return trim(trim(ofNullable(contactDetails.getRespondentFmName()).orElse(StringUtils.EMPTY)) + SPACE + + trim(ofNullable(contactDetails.getRespondentLname()).orElse(StringUtils.EMPTY))); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java index 4a6b874b7c..d82971b984 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java @@ -5,6 +5,9 @@ import org.junit.jupiter.params.provider.ValueSource; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.utils.StringDecorator; + +import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getConsentedFinremCaseDetailsBuilder; @@ -16,19 +19,40 @@ class ApplicantNameDocumentContentCheckerTest { @ParameterizedTest @ValueSource(strings = { "1. The applicant is Joe Bloggs", - "1. The applicant is Joe Bloggs ", - " 1. The applicant is Joe Bloggs", - " 1. The applicant is Joe Bloggs ", "whatever"}) void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndLastName(String validContent) { - assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .applicantFmName("Joe") - .applicantLname("Bloggs") - .build())).build(), - new String[] {validContent})) - .isNull(); + Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> + Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> + Arrays.stream(StringDecorator.values()).forEach(lnameDecorator -> + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .applicantFmName(fmNameDecorator.decorate("Joe")) + .applicantLname(lnameDecorator.decorate("Bloggs")) + .build())).build(), + new String[]{validContentDecorator.decorate(validContent)})) + .isNull() + ) + ) + ); + } + + @ParameterizedTest + @ValueSource(strings = { + "1. The applicant is Joe", + "whatever"}) + void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndEmptyLastName(String validContent) { + Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> + Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .applicantFmName(fmNameDecorator.decorate("Joe")) + .build())).build(), + new String[]{validContentDecorator.decorate(validContent)})) + .isNull() + ) + ); } @Test @@ -36,10 +60,10 @@ void givenCaseData_whenContentContainsNameDoesNotMatchApplicantFirstNameAndLastN assertThat(underTest.getWarning( getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() - .applicantFmName("Joey") + .applicantFmName("Joe") .applicantLname("Bloggs") .build())).build(), - new String[] {"1. The applicant is Joe Bloggs"})) + new String[] {"1. The applicant is Amy Clarks"})) .isEqualTo("Applicant name may not match"); } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java index 230902db3d..7d8be759dd 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java @@ -5,6 +5,9 @@ import org.junit.jupiter.params.provider.ValueSource; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.utils.StringDecorator; + +import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getConsentedFinremCaseDetailsBuilder; @@ -16,19 +19,40 @@ class RespondentNameDocumentContentCheckerTest { @ParameterizedTest @ValueSource(strings = { "The respondent is Joe Bloggs", - "The respondent is Joe Bloggs ", - " The respondent is Joe Bloggs", - " The respondent is Joe Bloggs ", "whatever"}) void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName(String validContent) { - assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .respondentFmName("Joe") - .respondentLname("Bloggs") - .build())).build(), - new String[] {validContent})) - .isNull(); + Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> + Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> + Arrays.stream(StringDecorator.values()).forEach(lnameDecorator -> + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .respondentFmName(fmNameDecorator.decorate("Joe")) + .respondentLname(lnameDecorator.decorate("Bloggs")) + .build())).build(), + new String[]{validContentDecorator.decorate(validContent)})) + .isNull() + ) + ) + ); + } + + @ParameterizedTest + @ValueSource(strings = { + "The respondent is Joe", + "whatever"}) + void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndEmptyLastName(String validContent) { + Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> + Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> + assertThat(underTest.getWarning( + getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .respondentFmName(fmNameDecorator.decorate("Joe")) + .build())).build(), + new String[]{validContentDecorator.decorate(validContent)})) + .isNull() + ) + ); } @Test @@ -36,10 +60,10 @@ void givenCaseData_whenContentContainsNameDoesNotMatchRespondentFirstNameAndLast assertThat(underTest.getWarning( getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() - .respondentFmName("Joey") + .respondentFmName("Joe") .respondentLname("Bloggs") .build())).build(), - new String[] {"The respondent is Joe Bloggs"})) + new String[] {"The respondent is Amy Clarks"})) .isEqualTo("Respondent name may not match"); } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/StringDecorator.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/StringDecorator.java new file mode 100644 index 0000000000..61bd840914 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/StringDecorator.java @@ -0,0 +1,32 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.utils; + +import static org.apache.commons.lang3.StringUtils.SPACE; + +public enum StringDecorator { + NO_SPACE { + @Override + public String decorate(String str) { + return str; + } + }, + TRAILING_SPACE { + @Override + public String decorate(String str) { + return str + SPACE; + } + }, + LEADING_SPACE { + @Override + public String decorate(String str) { + return SPACE + str; + } + }, + ENCLOSED_WITH_SPACES { + @Override + public String decorate(String str) { + return SPACE + str + SPACE; + } + }; + + public abstract String decorate(String str); +} From 34958b704d150e9941922e94172a643d67612275 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 18 Jun 2024 18:36:10 +0100 Subject: [PATCH 49/96] typo --- .../DuplicateFilenameDocumentCheckerTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index ef20a31d51..c82e1e32ba 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -25,7 +25,7 @@ class DuplicateFilenameDocumentCheckerTest { private static final String WARNING = "A document with this filename already exists on the case"; @Mock - private CaseDocument inptuCaseDocument; + private CaseDocument caseDocument; @Mock private FinremCaseDetails caseDetails; @Mock @@ -43,14 +43,14 @@ class DuplicateFilenameDocumentCheckerTest { @BeforeEach public void setUp() { underTest = new DuplicateFilenameDocumentChecker(); - when(inptuCaseDocument.getDocumentFilename()).thenReturn("inputFilename"); + when(caseDocument.getDocumentFilename()).thenReturn("inputFilename"); } @Test void testCanCheck_alwaysReturnsTrue() { assertThat(underTest.canCheck(new CaseDocument())).isTrue(); assertThat(underTest.canCheck(null)).isTrue(); - assertThat(underTest.canCheck(inptuCaseDocument)).isTrue(); + assertThat(underTest.canCheck(caseDocument)).isTrue(); } @Test @@ -63,7 +63,7 @@ void testGetWarnings_NoDuplicate() throws DocumentContentCheckerException { when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); when(additionalDocument.getDocumentFilename()).thenReturn("additionalDocumentFilename"); - List warnings = underTest.getWarnings(inptuCaseDocument, new byte[0], caseDetails); + List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails); assertThat(warnings).isEmpty(); } @@ -77,7 +77,7 @@ void testGetWarnings_NoDuplicateWhenAdditionalDocumentIsNull() throws DocumentCo when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); - List warnings = underTest.getWarnings(inptuCaseDocument, new byte[0], caseDetails); + List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails); assertThat(warnings).isEmpty(); } @@ -88,7 +88,7 @@ void testGetWarnings_DuplicateInAdditionalDocument() throws DocumentContentCheck when(caseData.getAdditionalDocument()).thenReturn(additionalDocument); when(additionalDocument.getDocumentFilename()).thenReturn("inputFilename"); - List warnings = underTest.getWarnings(inptuCaseDocument, new byte[0], caseDetails); + List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails); assertThat(warnings).hasSize(1).containsExactly(WARNING); } @@ -102,14 +102,14 @@ void testGetWarnings_DuplicateInGeneralOrderDocument() throws DocumentContentChe when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); when(caseData.getGeneralOrderWrapper()).thenReturn(generalOrderWrapper); - List warnings = underTest.getWarnings(inptuCaseDocument, new byte[0], caseDetails); + List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails); assertThat(warnings).hasSize(1).containsExactly(WARNING); } @Test void testGetWarnings_NoCaseData() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(inptuCaseDocument, new byte[0], FinremCaseDetails.builder() + List warnings = underTest.getWarnings(caseDocument, new byte[0], FinremCaseDetails.builder() .data(FinremCaseData.builder().build()) .build()); From 4e5bb5901d2121ceeac7a2404d088beef1b24ad3 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 18 Jun 2024 19:02:16 +0100 Subject: [PATCH 50/96] added comment on DocumentUploadServiceV2 --- .../caseorchestration/service/DocumentUploadServiceV2.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java index 9cfcd9f6f0..a4434932d5 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java @@ -1,6 +1,5 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service; - import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; @@ -12,6 +11,11 @@ import static org.apache.commons.lang3.ObjectUtils.isEmpty; +/** + * Service class for managing any document uploads in Financial Remedy Service. + * Unlike the abstract class uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadService + * which is designed to handle generic uk.gov.hmcts.reform.finrem.caseorchestration.model.CaseDocumentTabData. + */ @Service public class DocumentUploadServiceV2 { From 41e3f2bb6b939ee22310c819ee7e06cb6b1b1ea6 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 19 Jun 2024 10:09:53 +0100 Subject: [PATCH 51/96] Renaming service to NewUploadedDocumentsService --- .../UploadDocumentConsentedAboutToSubmitHandler.java | 10 +++++----- .../UploadDocumentContestedAboutToSubmitHandler.java | 12 ++++++------ ...rviceV2.java => NewUploadedDocumentsService.java} | 7 +------ ...oadDocumentConsentedAboutToSubmitHandlerTest.java | 8 ++++---- ...oadDocumentContestedAboutToSubmitHandlerTest.java | 8 ++++---- ...est.java => NewUploadedDocumentsServiceTest.java} | 6 +++--- 6 files changed, 23 insertions(+), 28 deletions(-) rename src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/{DocumentUploadServiceV2.java => NewUploadedDocumentsService.java} (80%) rename src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/{DocumentUploadServiceV2Test.java => NewUploadedDocumentsServiceTest.java} (97%) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java index 2ca79d80ea..06c96adca5 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java @@ -10,7 +10,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; -import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadServiceV2; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.NewUploadedDocumentsService; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; import java.util.List; @@ -20,14 +20,14 @@ public class UploadDocumentConsentedAboutToSubmitHandler extends FinremCallbackHandler { private final DocumentCheckerService documentCheckerService; - private final DocumentUploadServiceV2 documentUploadService; + private final NewUploadedDocumentsService newUploadedDocumentsService; public UploadDocumentConsentedAboutToSubmitHandler(FinremCaseDetailsMapper mapper, DocumentCheckerService documentCheckerService, - DocumentUploadServiceV2 documentUploadService) { + NewUploadedDocumentsService newUploadedDocumentsService) { super(mapper); this.documentCheckerService = documentCheckerService; - this.documentUploadService = documentUploadService; + this.newUploadedDocumentsService = newUploadedDocumentsService; } @Override @@ -45,7 +45,7 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); - final List warnings = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, FinremCaseData::getUploadDocuments) + final List warnings = newUploadedDocumentsService.getNewUploadDocuments(caseData, caseDataBefore, FinremCaseData::getUploadDocuments) .stream() .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) .flatMap(List::stream) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java index dd0fc75635..d45d200ab2 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java @@ -12,7 +12,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; -import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadServiceV2; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.NewUploadedDocumentsService; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentcatergory.UploadGeneralDocumentsCategoriser; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; @@ -29,16 +29,16 @@ public class UploadDocumentContestedAboutToSubmitHandler extends FinremCallbackHandler { private final DocumentCheckerService documentCheckerService; - private final DocumentUploadServiceV2 documentUploadService; + private final NewUploadedDocumentsService newUploadedDocumentsService; private final UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser; public UploadDocumentContestedAboutToSubmitHandler(FinremCaseDetailsMapper mapper, DocumentCheckerService documentCheckerService, - DocumentUploadServiceV2 documentUploadService, + NewUploadedDocumentsService newUploadedDocumentsService, UploadGeneralDocumentsCategoriser uploadGeneralDocumentsCategoriser) { super(mapper); this.documentCheckerService = documentCheckerService; - this.documentUploadService = documentUploadService; + this.newUploadedDocumentsService = newUploadedDocumentsService; this.uploadGeneralDocumentsCategoriser = uploadGeneralDocumentsCategoriser; } @@ -57,8 +57,8 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); - final List warnings = documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, FinremCaseData::getUploadGeneralDocuments) - .stream() + final List warnings = newUploadedDocumentsService.getNewUploadDocuments(caseData, caseDataBefore, + FinremCaseData::getUploadGeneralDocuments).stream() .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) .flatMap(List::stream) .filter(ObjectUtils::isNotEmpty) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsService.java similarity index 80% rename from src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java rename to src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsService.java index a4434932d5..2f0e7030e6 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsService.java @@ -11,13 +11,8 @@ import static org.apache.commons.lang3.ObjectUtils.isEmpty; -/** - * Service class for managing any document uploads in Financial Remedy Service. - * Unlike the abstract class uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadService - * which is designed to handle generic uk.gov.hmcts.reform.finrem.caseorchestration.model.CaseDocumentTabData. - */ @Service -public class DocumentUploadServiceV2 { +public class NewUploadedDocumentsService { public > List getNewUploadDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore, Function> accessor) { diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java index d7950f0a7b..2aee1935e8 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java @@ -20,7 +20,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocumentType; -import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadServiceV2; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.NewUploadedDocumentsService; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogger; import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogs; @@ -48,14 +48,14 @@ class UploadDocumentConsentedAboutToSubmitHandlerTest { private DocumentCheckerService documentCheckerService; @Mock - private DocumentUploadServiceV2 documentUploadService; + private NewUploadedDocumentsService newUploadedDocumentsService; private UploadDocumentConsentedAboutToSubmitHandler underTest; @BeforeEach public void setUpTest() { FinremCaseDetailsMapper finremCaseDetailsMapper = new FinremCaseDetailsMapper(new ObjectMapper().registerModule(new JavaTimeModule())); - underTest = new UploadDocumentConsentedAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, documentUploadService); + underTest = new UploadDocumentConsentedAboutToSubmitHandler(finremCaseDetailsMapper, documentCheckerService, newUploadedDocumentsService); } @Test @@ -67,7 +67,7 @@ void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadDocumentConsen @ValueSource(booleans = {true, false}) void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasWarnings) { List expectedWarnings = hasWarnings ? List.of("warnings") : List.of(); - when(documentUploadService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( + when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( UploadDocumentCollection.builder() .value(UploadDocument.builder().build()) .build() diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java index 670df3e783..112c95187b 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java @@ -20,7 +20,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentType; -import uk.gov.hmcts.reform.finrem.caseorchestration.service.DocumentUploadServiceV2; +import uk.gov.hmcts.reform.finrem.caseorchestration.service.NewUploadedDocumentsService; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentcatergory.UploadGeneralDocumentsCategoriser; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestLogger; @@ -48,7 +48,7 @@ class UploadDocumentContestedAboutToSubmitHandlerTest { private final TestLogger logs = new TestLogger(UploadDocumentContestedAboutToSubmitHandler.class); @Mock - private DocumentUploadServiceV2 documentUploadService; + private NewUploadedDocumentsService newUploadedDocumentsService; @Mock private DocumentCheckerService documentCheckerService; @Mock @@ -60,7 +60,7 @@ class UploadDocumentContestedAboutToSubmitHandlerTest { public void setUpTest() { underTest = new UploadDocumentContestedAboutToSubmitHandler( new FinremCaseDetailsMapper(new ObjectMapper().registerModule(new JavaTimeModule())), - documentCheckerService, documentUploadService, uploadGeneralDocumentsCategoriser); + documentCheckerService, newUploadedDocumentsService, uploadGeneralDocumentsCategoriser); } @Test @@ -72,7 +72,7 @@ void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadDocumentContes @ValueSource(booleans = {true, false}) void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasWarnings) { List expectedWarnings = hasWarnings ? List.of("warnings") : List.of(); - when(documentUploadService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( + when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder().build()) .build() diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java similarity index 97% rename from src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java rename to src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java index 7a4696558c..6949a3140e 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/DocumentUploadServiceV2Test.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java @@ -17,9 +17,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -class DocumentUploadServiceV2Test { +class NewUploadedDocumentsServiceTest { - private DocumentUploadServiceV2 documentUploadService = new DocumentUploadServiceV2(); + private NewUploadedDocumentsService underTest = new NewUploadedDocumentsService(); private static Stream provideArguments() { final List existingUploadGeneralDocument = List.of( @@ -174,6 +174,6 @@ void givenCaseWithExistingDocument_whenDocumentUploadedOrNot_thenReturnExpectedD List> expectedReturn) { FinremCaseData caseDataBefore = caseDataBeforeModifier.apply(FinremCaseData.builder()).build(); FinremCaseData caseData = caseDataModifier.apply(FinremCaseData.builder()).build(); - assertEquals(expectedReturn, documentUploadService.getNewUploadDocuments(caseData, caseDataBefore, accessor)); + assertEquals(expectedReturn, underTest.getNewUploadDocuments(caseData, caseDataBefore, accessor)); } } From 4335d62434ff2647575e31002abb5fbf189c809d Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 19 Jun 2024 11:44:32 +0100 Subject: [PATCH 52/96] Resolve code review conversation. --- .../caseorchestration/BaseServiceTest.java | 8 +-- .../FinremCallbackRequestFactory.java | 29 ++++++++--- .../FinremCaseDetailsBuilderFactory.java | 50 +++++++++++++++++++ .../caseorchestration/TestConstants.java | 1 + ...mentConsentedAboutToSubmitHandlerTest.java | 15 +++--- ...mentContestedAboutToSubmitHandlerTest.java | 34 +++++++------ .../NewUploadedDocumentsServiceTest.java | 26 +++++----- .../DocumentCheckerServiceTest.java | 11 ++-- ...plicantNameDocumentContentCheckerTest.java | 17 +++---- .../CaseNumberDocumentContentCheckerTest.java | 32 ++++++------ ...pondentNameDocumentContentCheckerTest.java | 21 +++----- .../caseorchestration/util/TestResource.java | 41 --------------- 12 files changed, 149 insertions(+), 136 deletions(-) create mode 100644 src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/FinremCaseDetailsBuilderFactory.java diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/BaseServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/BaseServiceTest.java index b606899bc3..97f0c4eb28 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/BaseServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/BaseServiceTest.java @@ -27,7 +27,6 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.NatureApplicationWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.notifications.service.EmailService; -import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource; import java.io.File; import java.io.IOException; @@ -49,6 +48,7 @@ import static uk.gov.hmcts.reform.finrem.caseorchestration.TestConstants.TEST_SOLICITOR_EMAIL; import static uk.gov.hmcts.reform.finrem.caseorchestration.TestConstants.TEST_SOLICITOR_NAME; import static uk.gov.hmcts.reform.finrem.caseorchestration.TestConstants.TEST_SOLICITOR_REFERENCE; +import static uk.gov.hmcts.reform.finrem.caseorchestration.TestSetUpUtils.caseDocument; import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.APPLICANT_FIRST_MIDDLE_NAME; import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.APPLICANT_LAST_NAME; import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.BULK_PRINT_LETTER_ID_RES; @@ -409,12 +409,8 @@ protected Map convertCaseDataToStringRepresentation(Map response = underTest.handle( FinremCallbackRequest.builder() diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java index 112c95187b..b2f2e2298b 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java @@ -9,6 +9,7 @@ import org.junit.jupiter.params.provider.ValueSource; import org.mockito.Mock; import org.springframework.test.context.junit.jupiter.SpringExtension; +import uk.gov.hmcts.reform.finrem.caseorchestration.FinremCaseDetailsBuilderFactory; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; @@ -35,11 +36,10 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.finrem.caseorchestration.TestConstants.AUTH_TOKEN; +import static uk.gov.hmcts.reform.finrem.caseorchestration.TestConstants.CASE_ID; +import static uk.gov.hmcts.reform.finrem.caseorchestration.TestSetUpUtils.caseDocument; import static uk.gov.hmcts.reform.finrem.caseorchestration.test.Assertions.assertCanHandle; -import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.AUTH_TOKEN; -import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.CASE_ID; -import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.buildCaseDocument; -import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getContestedFinremCaseDetailsBuilder; @ExtendWith(SpringExtension.class) class UploadDocumentContestedAboutToSubmitHandlerTest { @@ -79,15 +79,17 @@ void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasW )); when(documentCheckerService.getWarnings(any(), any(), any())).thenReturn(expectedWarnings); - FinremCaseDetails finremCaseDetails = getContestedFinremCaseDetailsBuilder(FinremCaseData.builder() - .uploadGeneralDocuments(List.of( - createGeneralUploadDocumentItem( - UploadGeneralDocumentType.LETTER_EMAIL_FROM_RESPONDENT, "New email content", - createCaseDocument(), LocalDate.now(), "New Example", "newDocument.filename") - ))) + FinremCaseDetails finremCaseDetails = FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONTESTED, FinremCaseData.builder() + .uploadGeneralDocuments(List.of( + createGeneralUploadDocumentItem( + UploadGeneralDocumentType.LETTER_EMAIL_FROM_RESPONDENT, "New email content", + createCaseDocument(), LocalDate.now(), "New Example", "newDocument.filename") + )) + ) + .build(); + FinremCaseDetails finremCaseDetailsBefore = FinremCaseDetailsBuilderFactory + .from(Long.valueOf(CASE_ID), CaseType.CONTESTED, FinremCaseData.builder()) .build(); - - FinremCaseDetails finremCaseDetailsBefore = getContestedFinremCaseDetailsBuilder(FinremCaseData.builder()).build(); GenericAboutToStartOrSubmitCallbackResponse response = underTest.handle( FinremCallbackRequest.builder() @@ -113,11 +115,11 @@ void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectionByDate UploadGeneralDocumentType.LETTER_EMAIL_FROM_RESPONDENT, "New email content", createCaseDocument(), LocalDate.now(), "New Example", "newDocument.filename"); - FinremCaseDetails finremCaseDetails = getContestedFinremCaseDetailsBuilder(FinremCaseData.builder() + FinremCaseDetails finremCaseDetails = FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONTESTED, FinremCaseData.builder() .uploadGeneralDocuments(List.of(newDoc, oldDoc))) .build(); - FinremCaseDetails finremCaseDetailsBefore = getContestedFinremCaseDetailsBuilder(FinremCaseData.builder() - .uploadGeneralDocuments(List.of(oldDoc))) + FinremCaseDetails finremCaseDetailsBefore = FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONTESTED, + FinremCaseData.builder().uploadGeneralDocuments(List.of(oldDoc))) .build(); List expectedDocumentIdList = new ArrayList<>(); @@ -134,7 +136,7 @@ void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectionByDate } private CaseDocument createCaseDocument() { - return buildCaseDocument("/fileUrl", "/binaryUrl","document.extension"); + return caseDocument("/fileUrl", "/binaryUrl","document.extension"); } private UploadGeneralDocumentCollection createGeneralUploadDocumentItem(UploadGeneralDocumentType type, String emailContent, diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java index 6949a3140e..48d1f28984 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java @@ -9,13 +9,13 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; -import uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource; import java.util.List; import java.util.function.Function; import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.assertEquals; +import static uk.gov.hmcts.reform.finrem.caseorchestration.TestSetUpUtils.caseDocument; class NewUploadedDocumentsServiceTest { @@ -25,14 +25,14 @@ private static Stream provideArguments() { final List existingUploadGeneralDocument = List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(TestResource.buildCaseDocument("url1", "binaryUrl1", "filename1")) + .documentLink(caseDocument("url1", "binaryUrl1", "filename1")) .build()) .build() ); final List existingUploadDocument = List.of( UploadDocumentCollection.builder() .value(UploadDocument.builder() - .documentLink(TestResource.buildCaseDocument("url1", "binaryUrl1", "filename1")) + .documentLink(caseDocument("url1", "binaryUrl1", "filename1")) .build()) .build() ); @@ -48,7 +48,7 @@ private static Stream provideArguments() { finremCaseDataBuilder.uploadGeneralDocuments(Stream.concat(existingUploadGeneralDocument.stream(), Stream.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(TestResource.buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .documentLink(caseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) .build()) .build() )).toList()); @@ -57,7 +57,7 @@ private static Stream provideArguments() { (Function) FinremCaseData::getUploadGeneralDocuments, List.of(UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(TestResource.buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .documentLink(caseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) .build()) .build()) ), @@ -82,13 +82,13 @@ private static Stream provideArguments() { finremCaseDataBuilder.uploadGeneralDocuments(Stream.concat(existingUploadGeneralDocument.stream(), Stream.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(TestResource.buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .documentLink(caseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) .build()) .build(), UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(TestResource.buildCaseDocument("newUrl2", "newBinaryUrl2", "newFilename2")) + .documentLink(caseDocument("newUrl2", "newBinaryUrl2", "newFilename2")) .build()) .build() )).toList()); @@ -97,12 +97,12 @@ private static Stream provideArguments() { (Function) FinremCaseData::getUploadGeneralDocuments, List.of(UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(TestResource.buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .documentLink(caseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) .build()) .build(), UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(TestResource.buildCaseDocument("newUrl2", "newBinaryUrl2", "newFilename2")) + .documentLink(caseDocument("newUrl2", "newBinaryUrl2", "newFilename2")) .build()) .build()) ), @@ -113,7 +113,7 @@ private static Stream provideArguments() { finremCaseDataBuilder.uploadGeneralDocuments(List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(TestResource.buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .documentLink(caseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) .build()) .build() )); @@ -123,7 +123,7 @@ private static Stream provideArguments() { List.of( UploadGeneralDocumentCollection.builder() .value(UploadGeneralDocument.builder() - .documentLink(TestResource.buildCaseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .documentLink(caseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) .build()) .build() ) @@ -149,7 +149,7 @@ private static Stream provideArguments() { finremCaseDataBuilder.uploadDocuments(Stream.concat(existingUploadDocument.stream(), Stream.of( UploadDocumentCollection.builder() .value(UploadDocument.builder() - .documentLink(TestResource.buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) + .documentLink(caseDocument("newUrl", "newBinaryUrl1", "newFilename")) .build()) .build() )).toList()); @@ -158,7 +158,7 @@ private static Stream provideArguments() { (Function) FinremCaseData::getUploadDocuments, List.of(UploadDocumentCollection.builder() .value(UploadDocument.builder() - .documentLink(TestResource.buildCaseDocument("newUrl", "newBinaryUrl1", "newFilename")) + .documentLink(caseDocument("newUrl", "newBinaryUrl1", "newFilename")) .build()) .build()) ) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java index dc3cec4ca5..952f95c1c2 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java @@ -20,7 +20,8 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; -import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.AUTH_TOKEN; +import static uk.gov.hmcts.reform.finrem.caseorchestration.TestConstants.AUTH_TOKEN; +import static uk.gov.hmcts.reform.finrem.caseorchestration.TestSetUpUtils.caseDocument; @ExtendWith(MockitoExtension.class) class DocumentCheckerServiceTest extends BaseServiceTest { @@ -48,7 +49,7 @@ public void setUp() { @Test void testSingleWarningReturnedByDocxDocumentChecker() throws DocumentContentCheckerException { - final CaseDocument caseDocument = buildCaseDocument(); + final CaseDocument caseDocument = caseDocument(); when(downloadService.download(any(), eq(AUTH_TOKEN))).thenReturn(new byte[]{}); when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); @@ -60,7 +61,7 @@ void testSingleWarningReturnedByDocxDocumentChecker() throws DocumentContentChec @Test void testMultipleWarningsReturnedCheckers() throws DocumentContentCheckerException { - final CaseDocument caseDocument = buildCaseDocument(); + final CaseDocument caseDocument = caseDocument(); when(downloadService.download(any(), eq(AUTH_TOKEN))).thenReturn(new byte[]{}); when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); @@ -74,7 +75,7 @@ void testMultipleWarningsReturnedCheckers() throws DocumentContentCheckerExcepti @Test void testIfDocxCheckerThrowDocumentContentCheckerException() throws DocumentContentCheckerException { - final CaseDocument caseDocument = buildCaseDocument(); + final CaseDocument caseDocument = caseDocument(); when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any())) .thenThrow(new DocumentContentCheckerException(new RuntimeException("test"))); @@ -85,7 +86,7 @@ void testIfDocxCheckerThrowDocumentContentCheckerException() throws DocumentCont @Test void testNoDocumentCheckerCanCheck() { - final CaseDocument caseDocument = buildCaseDocument(); + final CaseDocument caseDocument = caseDocument(); when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(false); when(duplicateFilenameDocumentChecker.canCheck(caseDocument)).thenReturn(false); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java index d82971b984..3e2f180cfd 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java @@ -3,6 +3,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +import uk.gov.hmcts.reform.finrem.caseorchestration.FinremCaseDetailsBuilderFactory; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.utils.StringDecorator; @@ -10,7 +11,6 @@ import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; -import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getConsentedFinremCaseDetailsBuilder; class ApplicantNameDocumentContentCheckerTest { @@ -25,7 +25,7 @@ void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndLastName(S Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> Arrays.stream(StringDecorator.values()).forEach(lnameDecorator -> assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .applicantFmName(fmNameDecorator.decorate("Joe")) .applicantLname(lnameDecorator.decorate("Bloggs")) @@ -45,7 +45,7 @@ void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndEmptyLastN Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .applicantFmName(fmNameDecorator.decorate("Joe")) .build())).build(), @@ -58,7 +58,7 @@ void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndEmptyLastN @Test void givenCaseData_whenContentContainsNameDoesNotMatchApplicantFirstNameAndLastName() { assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .applicantFmName("Joe") .applicantLname("Bloggs") @@ -70,7 +70,7 @@ void givenCaseData_whenContentContainsNameDoesNotMatchApplicantFirstNameAndLastN @Test void givenCaseData_whenOneOfTheContentsContainsNameDoesNotMatchApplicantFirstNameAndLastName() { assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .applicantFmName("Joey") .applicantLname("Bloggs") @@ -82,7 +82,7 @@ void givenCaseData_whenOneOfTheContentsContainsNameDoesNotMatchApplicantFirstNam @Test void givenCaseData_whenEmptyContentProvided() { assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .applicantFmName("Joey") .applicantLname("Bloggs") @@ -93,9 +93,6 @@ void givenCaseData_whenEmptyContentProvided() { @Test void givenCaseDataWithoutContactDetailsWrapper_whenContentProvided() { - assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder()).build(), - new String[] {"1. The applicant is Joe Bloggs"})) - .isNull(); + assertThat(underTest.getWarning(FinremCaseDetailsBuilderFactory.from().build(), new String[] {"1. The applicant is Joe Bloggs"})).isNull(); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java index 8d5766f487..ef470526f1 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java @@ -3,43 +3,39 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.FinremCaseDetailsBuilderFactory; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.utils.StringDecorator; + +import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; -import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getConsentedFinremCaseDetailsBuilder; +import static uk.gov.hmcts.reform.finrem.caseorchestration.TestConstants.CASE_ID; class CaseNumberDocumentContentCheckerTest { private final CaseNumberDocumentContentChecker underTest = new CaseNumberDocumentContentChecker(); @ParameterizedTest - @ValueSource(strings = { - "Case number 1234567890", - "Case number 1234567890 ", - " Case number 1234567890", - " Case number 1234567890 ", - "whatever"}) + @ValueSource(strings = {"Case number 1234567890", "whatever"}) void givenCaseData_whenContentContainCaseNumber(String validContent) { - assertThat(underTest.getWarning(getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder()).build(), - new String[] {validContent})).isNull(); + Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> + assertThat(underTest.getWarning(FinremCaseDetailsBuilderFactory.from().build(), + new String[]{validContentDecorator.decorate(validContent)})).isNull()); } @Test void givenCaseData_whenContentDoesNotMatchCaseNumber() { - assertThat(underTest.getWarning(getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder()).build(), + assertThat(underTest.getWarning(FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID)).build(), new String[] {"Case number 1234567891"})).isEqualTo("Case numbers may not match"); } @ParameterizedTest - @ValueSource(strings = { - "Case number 1234567890", - "Case number 1234567890 ", - " Case number 1234567890", - " Case number 1234567890 ", - "whatever"}) + @ValueSource(strings = {"Case number 1234567890", "whatever"}) void givenCaseDataWithoutId_whenContentDoesNotMatchCaseNumber(String content) { - assertThat(underTest.getWarning(FinremCaseDetails.builder().build(), new String[] {content})).isNull(); + Arrays.stream(StringDecorator.values()).forEach(contentDecorator -> + assertThat(underTest.getWarning(FinremCaseDetails.builder().build(), new String[] {contentDecorator.decorate(content)})).isNull() + ); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java index 7d8be759dd..8a6beac43f 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java @@ -3,6 +3,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +import uk.gov.hmcts.reform.finrem.caseorchestration.FinremCaseDetailsBuilderFactory; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.utils.StringDecorator; @@ -10,7 +11,6 @@ import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; -import static uk.gov.hmcts.reform.finrem.caseorchestration.util.TestResource.getConsentedFinremCaseDetailsBuilder; class RespondentNameDocumentContentCheckerTest { @@ -25,7 +25,7 @@ void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName( Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> Arrays.stream(StringDecorator.values()).forEach(lnameDecorator -> assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .respondentFmName(fmNameDecorator.decorate("Joe")) .respondentLname(lnameDecorator.decorate("Bloggs")) @@ -38,14 +38,12 @@ void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName( } @ParameterizedTest - @ValueSource(strings = { - "The respondent is Joe", - "whatever"}) + @ValueSource(strings = {"The respondent is Joe", "whatever"}) void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndEmptyLastName(String validContent) { Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .respondentFmName(fmNameDecorator.decorate("Joe")) .build())).build(), @@ -58,7 +56,7 @@ void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndEmptyLast @Test void givenCaseData_whenContentContainsNameDoesNotMatchRespondentFirstNameAndLastName() { assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .respondentFmName("Joe") .respondentLname("Bloggs") @@ -70,7 +68,7 @@ void givenCaseData_whenContentContainsNameDoesNotMatchRespondentFirstNameAndLast @Test void givenCaseData_whenOneOfTheContentsContainsNameDoesNotMatchRespondentFirstNameAndLastName() { assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .respondentFmName("Joey") .respondentLname("Bloggs") @@ -82,7 +80,7 @@ void givenCaseData_whenOneOfTheContentsContainsNameDoesNotMatchRespondentFirstNa @Test void givenCaseData_whenEmptyContentProvided() { assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder() + FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .respondentFmName("Joey") .respondentLname("Bloggs") @@ -93,9 +91,6 @@ void givenCaseData_whenEmptyContentProvided() { @Test void givenCaseDataWithoutContactDetailsWrapper_whenContentProvided() { - assertThat(underTest.getWarning( - getConsentedFinremCaseDetailsBuilder(FinremCaseData.builder()).build(), - new String[] {"The respondent is Joe Bloggs"})) - .isNull(); + assertThat(underTest.getWarning(FinremCaseDetailsBuilderFactory.from().build(), new String[] {"The respondent is Joe Bloggs"})).isNull(); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java index 4a12a3ecc0..5eaba28a32 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/util/TestResource.java @@ -1,10 +1,6 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.util; import org.springframework.http.HttpStatus; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.model.document.Document; import uk.gov.hmcts.reform.finrem.caseorchestration.model.evidence.FileUploadResponse; @@ -23,8 +19,6 @@ public class TestResource { public static final String CREATED_ON = "20th October 2018"; public static final String MIME_TYPE = "app/pdf"; public static final String CREATED_BY = "user"; - public static final String CASE_ID = "1234567890"; - public static final String AUTH_TOKEN = "token:)"; public static List fileUploadResponse() { FileUploadResponse response = new FileUploadResponse(); @@ -47,41 +41,6 @@ public static Document testDocument() { .build(); } - public static FinremCaseDetails.FinremCaseDetailsBuilder getContestedFinremCaseDetailsBuilder( - FinremCaseData.FinremCaseDataBuilder finremCaseDataBuilder) { - return getFinremCaseDetailsBuilder(finremCaseDataBuilder, CaseType.CONTESTED); - } - - public static FinremCaseDetails.FinremCaseDetailsBuilder getConsentedFinremCaseDetailsBuilder( - FinremCaseData.FinremCaseDataBuilder finremCaseDataBuilder) { - return getFinremCaseDetailsBuilder(finremCaseDataBuilder, CaseType.CONSENTED); - } - - private static FinremCaseDetails.FinremCaseDetailsBuilder getFinremCaseDetailsBuilder(FinremCaseData.FinremCaseDataBuilder finremCaseDataBuilder, - CaseType caseType) { - FinremCaseData finremCaseData = finremCaseDataBuilder.build(); - return FinremCaseDetails.builder().id(Long.valueOf(CASE_ID)) - .caseType(caseType) - .data(finremCaseData); - } - - public static CaseDocument buildCaseDocument() { - return buildCaseDocument("url", "binaryUrl", "filename"); - } - - public static CaseDocument buildCaseDocument(String url, String binaryUrl, String filename) { - return buildCaseDocument(url, binaryUrl, filename, null); - } - - public static CaseDocument buildCaseDocument(String url, String binaryUrl, String filename, String categoryId) { - CaseDocument document = new CaseDocument(); - document.setDocumentUrl(url); - document.setDocumentBinaryUrl(binaryUrl); - document.setDocumentFilename(filename); - document.setCategoryId(categoryId); - return document; - } - public static Path getPathFromResources(String fileName) { return Paths.get("src/test/resources/" + fileName); } From 2e7ef273d879b00091b0e6e446b476440668085a Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 19 Jun 2024 11:56:03 +0100 Subject: [PATCH 53/96] remove unnecessary line of code. --- .../contentchecker/CaseNumberDocumentContentChecker.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java index 8418c42435..26f3823c20 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java @@ -6,8 +6,6 @@ import java.util.stream.Stream; -import static java.util.Optional.ofNullable; - @Component public class CaseNumberDocumentContentChecker implements DocumentContentChecker { @@ -31,7 +29,7 @@ private boolean contentCaseNumberNotEqualsCaseNumber(FinremCaseDetails caseDetai if (caseDetails.getId() == null) { return false; } - return caseNumberFromContent != ofNullable(caseDetails.getId()).orElse(0L); + return caseNumberFromContent != caseDetails.getId(); } private long getCaseNumberFromContent(String text) { From 419c9dcee57cbeff272279de042c314af1f85142 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 19 Jun 2024 12:09:03 +0100 Subject: [PATCH 54/96] null checking --- .../ApplicantNameDocumentContentChecker.java | 3 ++- .../CaseNumberDocumentContentChecker.java | 5 +++-- .../RespondentNameDocumentContentChecker.java | 3 ++- .../ApplicantNameDocumentContentCheckerTest.java | 11 +++++------ .../CaseNumberDocumentContentCheckerTest.java | 7 +++++-- .../RespondentNameDocumentContentCheckerTest.java | 7 +++++-- .../caseorchestration/utils/StringDecorator.java | 7 ++++--- 7 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java index d8e9e5d207..2497873d39 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentChecker.java @@ -10,6 +10,7 @@ import static java.util.Optional.ofNullable; import static org.apache.commons.lang3.StringUtils.SPACE; +import static org.apache.commons.lang3.StringUtils.defaultString; import static org.apache.commons.lang3.StringUtils.isEmpty; import static org.apache.commons.lang3.StringUtils.trim; @@ -28,7 +29,7 @@ public String getWarning(FinremCaseDetails caseDetails, String[] content) { } private boolean containsTheApplicantIs(String text) { - return text.contains("1. The applicant is"); + return defaultString(text).contains("1. The applicant is"); } private boolean contentNameNotEqualsCaseName(FinremCaseData caseData, String content) { diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java index 26f3823c20..46ec6cdf5c 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java @@ -6,6 +6,8 @@ import java.util.stream.Stream; +import static org.apache.commons.lang3.StringUtils.defaultString; + @Component public class CaseNumberDocumentContentChecker implements DocumentContentChecker { @@ -21,7 +23,7 @@ public String getWarning(FinremCaseDetails caseDetails, String[] content) { } private boolean containsCaseNumber(String text) { - return text.contains("Case number"); + return defaultString(text).contains("Case number"); } private boolean contentCaseNumberNotEqualsCaseNumber(FinremCaseDetails caseDetails, String content) { @@ -36,5 +38,4 @@ private long getCaseNumberFromContent(String text) { return Long.parseLong(CharMatcher.inRange('0', '9').retainFrom(text)); } - } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java index 763ef6f03e..cf56512550 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java @@ -10,6 +10,7 @@ import static java.util.Optional.ofNullable; import static org.apache.commons.lang3.StringUtils.SPACE; +import static org.apache.commons.lang3.StringUtils.defaultString; import static org.apache.commons.lang3.StringUtils.isEmpty; import static org.apache.commons.lang3.StringUtils.trim; @@ -28,7 +29,7 @@ public String getWarning(FinremCaseDetails caseDetails, String[] content) { } private boolean containsTheRespondentIs(String text) { - return text.contains("The respondent is"); + return defaultString(text).contains("The respondent is"); } private boolean contentNameNotEqualsCaseName(FinremCaseData caseData, String content) { diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java index 3e2f180cfd..48f89a27f8 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/ApplicantNameDocumentContentCheckerTest.java @@ -2,6 +2,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.NullSource; import org.junit.jupiter.params.provider.ValueSource; import uk.gov.hmcts.reform.finrem.caseorchestration.FinremCaseDetailsBuilderFactory; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; @@ -17,9 +18,8 @@ class ApplicantNameDocumentContentCheckerTest { private final ApplicantNameDocumentContentChecker underTest = new ApplicantNameDocumentContentChecker(); @ParameterizedTest - @ValueSource(strings = { - "1. The applicant is Joe Bloggs", - "whatever"}) + @ValueSource(strings = {"1. The applicant is Joe Bloggs", "whatever", ""}) + @NullSource void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndLastName(String validContent) { Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> @@ -38,9 +38,8 @@ void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndLastName(S } @ParameterizedTest - @ValueSource(strings = { - "1. The applicant is Joe", - "whatever"}) + @ValueSource(strings = {"1. The applicant is Joe","whatever", ""}) + @NullSource void givenCaseData_whenContentContainsNameMatchesApplicantFirstNameAndEmptyLastName(String validContent) { Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java index ef470526f1..debfd57c6c 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java @@ -2,6 +2,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.NullSource; import org.junit.jupiter.params.provider.ValueSource; import uk.gov.hmcts.reform.finrem.caseorchestration.FinremCaseDetailsBuilderFactory; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; @@ -17,7 +18,8 @@ class CaseNumberDocumentContentCheckerTest { private final CaseNumberDocumentContentChecker underTest = new CaseNumberDocumentContentChecker(); @ParameterizedTest - @ValueSource(strings = {"Case number 1234567890", "whatever"}) + @ValueSource(strings = {"Case number 1234567890", "whatever", ""}) + @NullSource void givenCaseData_whenContentContainCaseNumber(String validContent) { Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> assertThat(underTest.getWarning(FinremCaseDetailsBuilderFactory.from().build(), @@ -31,7 +33,8 @@ void givenCaseData_whenContentDoesNotMatchCaseNumber() { } @ParameterizedTest - @ValueSource(strings = {"Case number 1234567890", "whatever"}) + @ValueSource(strings = {"Case number 1234567890", "whatever", ""}) + @NullSource void givenCaseDataWithoutId_whenContentDoesNotMatchCaseNumber(String content) { Arrays.stream(StringDecorator.values()).forEach(contentDecorator -> assertThat(underTest.getWarning(FinremCaseDetails.builder().build(), new String[] {contentDecorator.decorate(content)})).isNull() diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java index 8a6beac43f..d82769e36c 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java @@ -2,6 +2,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.NullSource; import org.junit.jupiter.params.provider.ValueSource; import uk.gov.hmcts.reform.finrem.caseorchestration.FinremCaseDetailsBuilderFactory; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; @@ -19,7 +20,8 @@ class RespondentNameDocumentContentCheckerTest { @ParameterizedTest @ValueSource(strings = { "The respondent is Joe Bloggs", - "whatever"}) + "whatever", ""}) + @NullSource void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName(String validContent) { Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> @@ -38,7 +40,8 @@ void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName( } @ParameterizedTest - @ValueSource(strings = {"The respondent is Joe", "whatever"}) + @ValueSource(strings = {"The respondent is Joe", "whatever", ""}) + @NullSource void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndEmptyLastName(String validContent) { Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/StringDecorator.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/StringDecorator.java index 61bd840914..c12f9fdb99 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/StringDecorator.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/utils/StringDecorator.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.utils; import static org.apache.commons.lang3.StringUtils.SPACE; +import static org.apache.commons.lang3.StringUtils.defaultString; public enum StringDecorator { NO_SPACE { @@ -12,19 +13,19 @@ public String decorate(String str) { TRAILING_SPACE { @Override public String decorate(String str) { - return str + SPACE; + return defaultString(str) + SPACE; } }, LEADING_SPACE { @Override public String decorate(String str) { - return SPACE + str; + return SPACE + defaultString(str); } }, ENCLOSED_WITH_SPACES { @Override public String decorate(String str) { - return SPACE + str + SPACE; + return SPACE + defaultString(str) + SPACE; } }; From f25f5adf0d33cdb40c5b9906ceef7ca79068b2ad Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 19 Jun 2024 12:10:34 +0100 Subject: [PATCH 55/96] Fix missing test case --- .../contentchecker/CaseNumberDocumentContentCheckerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java index debfd57c6c..896d36a2bb 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java @@ -22,7 +22,7 @@ class CaseNumberDocumentContentCheckerTest { @NullSource void givenCaseData_whenContentContainCaseNumber(String validContent) { Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> - assertThat(underTest.getWarning(FinremCaseDetailsBuilderFactory.from().build(), + assertThat(underTest.getWarning(FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID)).build(), new String[]{validContentDecorator.decorate(validContent)})).isNull()); } From 50dbfee3300e6bd8e828e8337267f6358303b7f4 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 25 Jun 2024 11:07:24 +0100 Subject: [PATCH 56/96] Fix consented flow as respondent name stored in other fields --- .../RespondentNameDocumentContentChecker.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java index cf56512550..f4676d225d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java @@ -1,18 +1,13 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; import java.util.stream.Stream; -import static java.util.Optional.ofNullable; -import static org.apache.commons.lang3.StringUtils.SPACE; import static org.apache.commons.lang3.StringUtils.defaultString; import static org.apache.commons.lang3.StringUtils.isEmpty; -import static org.apache.commons.lang3.StringUtils.trim; @Component public class RespondentNameDocumentContentChecker implements DocumentContentChecker { @@ -45,8 +40,7 @@ private String getRespondentNameFromContent(String text) { } private String getRespondentNameFromCase(FinremCaseData caseData) { - ContactDetailsWrapper contactDetails = caseData.getContactDetailsWrapper(); - return trim(trim(ofNullable(contactDetails.getRespondentFmName()).orElse(StringUtils.EMPTY)) + SPACE - + trim(ofNullable(contactDetails.getRespondentLname()).orElse(StringUtils.EMPTY))); + return caseData.getRespondentFullName(); + } } From 293e4caa287f368065d921f5333624124c00ef4a Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 25 Jun 2024 11:07:45 +0100 Subject: [PATCH 57/96] remove blank new --- .../contentchecker/RespondentNameDocumentContentChecker.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java index f4676d225d..933a0dcd38 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentChecker.java @@ -41,6 +41,5 @@ private String getRespondentNameFromContent(String text) { private String getRespondentNameFromCase(FinremCaseData caseData) { return caseData.getRespondentFullName(); - } } From d95b92341b47a21ab8271ef613bb762305fa123a Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 25 Jun 2024 12:11:34 +0100 Subject: [PATCH 58/96] Unit tests for the latest fix --- .../FinremCaseDetailsBuilderFactory.java | 6 +- ...pondentNameDocumentContentCheckerTest.java | 206 ++++++++++++------ 2 files changed, 149 insertions(+), 63 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/FinremCaseDetailsBuilderFactory.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/FinremCaseDetailsBuilderFactory.java index 2db5ddb83f..6790a016ae 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/FinremCaseDetailsBuilderFactory.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/FinremCaseDetailsBuilderFactory.java @@ -29,7 +29,8 @@ public static FinremCaseDetailsBuilder from(Long id, CaseType caseType) { } public static FinremCaseDetailsBuilder from(Long id, CaseType caseType, FinremCaseDataBuilder caseDataBuilder) { - return from(id, caseType, caseDataBuilder == null ? FinremCaseData.builder().build() : caseDataBuilder.build()); + return from(id, caseType, caseDataBuilder == null ? FinremCaseData.builder().ccdCaseType(caseType).build() + : caseDataBuilder.ccdCaseType(caseType).build()); } public static FinremCaseDetailsBuilder from(Long id, FinremCaseDataBuilder caseDataBuilder) { @@ -37,7 +38,8 @@ public static FinremCaseDetailsBuilder from(Long id, FinremCaseDataBuilder caseD } public static FinremCaseDetailsBuilder from(CaseType caseType, FinremCaseDataBuilder caseDataBuilder) { - return from(null, caseType, caseDataBuilder.build()); + return from(null, caseType, (caseDataBuilder == null ? FinremCaseData.builder() : caseDataBuilder) + .ccdCaseType(caseType).build()); } public static FinremCaseDetailsBuilder from(FinremCaseDataBuilder caseDataBuilder) { diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java index d82769e36c..9d14476e05 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java @@ -1,5 +1,6 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.NullSource; @@ -12,84 +13,167 @@ import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; +import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType.CONSENTED; +import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType.CONTESTED; class RespondentNameDocumentContentCheckerTest { private final RespondentNameDocumentContentChecker underTest = new RespondentNameDocumentContentChecker(); - @ParameterizedTest - @ValueSource(strings = { - "The respondent is Joe Bloggs", - "whatever", ""}) - @NullSource - void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName(String validContent) { - Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> - Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> - Arrays.stream(StringDecorator.values()).forEach(lnameDecorator -> + @Nested + class Contested { + @ParameterizedTest + @ValueSource(strings = { + "The respondent is Joe Bloggs", + "whatever", ""}) + @NullSource + void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName(String validContent) { + Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> + Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> + Arrays.stream(StringDecorator.values()).forEach(lnameDecorator -> + assertThat(underTest.getWarning( + FinremCaseDetailsBuilderFactory.from(CONTESTED, FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .respondentFmName(fmNameDecorator.decorate("Joe")) + .respondentLname(lnameDecorator.decorate("Bloggs")) + .build())).build(), + new String[]{validContentDecorator.decorate(validContent)})) + .isNull() + ) + ) + ); + } + + @ParameterizedTest + @ValueSource(strings = {"The respondent is Joe", "whatever", ""}) + @NullSource + void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndEmptyLastName(String validContent) { + Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> + Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() + FinremCaseDetailsBuilderFactory.from(CONTESTED, FinremCaseData.builder() .contactDetailsWrapper(ContactDetailsWrapper.builder() .respondentFmName(fmNameDecorator.decorate("Joe")) - .respondentLname(lnameDecorator.decorate("Bloggs")) .build())).build(), new String[]{validContentDecorator.decorate(validContent)})) .isNull() ) - ) - ); - } + ); + } - @ParameterizedTest - @ValueSource(strings = {"The respondent is Joe", "whatever", ""}) - @NullSource - void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndEmptyLastName(String validContent) { - Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> - Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> - assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .respondentFmName(fmNameDecorator.decorate("Joe")) - .build())).build(), - new String[]{validContentDecorator.decorate(validContent)})) - .isNull() - ) - ); - } + @Test + void givenCaseData_whenContentContainsNameDoesNotMatchRespondentFirstNameAndLastName() { + assertThat(underTest.getWarning( + FinremCaseDetailsBuilderFactory.from(CONTESTED, FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .respondentFmName("Joe") + .respondentLname("Bloggs") + .build())).build(), + new String[]{"The respondent is Amy Clarks"})) + .isEqualTo("Respondent name may not match"); + } - @Test - void givenCaseData_whenContentContainsNameDoesNotMatchRespondentFirstNameAndLastName() { - assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .respondentFmName("Joe") - .respondentLname("Bloggs") - .build())).build(), - new String[] {"The respondent is Amy Clarks"})) - .isEqualTo("Respondent name may not match"); - } + @Test + void givenCaseData_whenOneOfTheContentsContainsNameDoesNotMatchRespondentFirstNameAndLastName() { + assertThat(underTest.getWarning( + FinremCaseDetailsBuilderFactory.from(CONTESTED, FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .respondentFmName("Joey") + .respondentLname("Bloggs") + .build())).build(), + new String[]{"The respondent is Joe Bloggs", "Whatever", "Whenever"})) + .isEqualTo("Respondent name may not match"); + } - @Test - void givenCaseData_whenOneOfTheContentsContainsNameDoesNotMatchRespondentFirstNameAndLastName() { - assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .respondentFmName("Joey") - .respondentLname("Bloggs") - .build())).build(), - new String[] {"The respondent is Joe Bloggs", "Whatever", "Whenever"})) - .isEqualTo("Respondent name may not match"); + @Test + void givenCaseData_whenEmptyContentProvided() { + assertThat(underTest.getWarning( + FinremCaseDetailsBuilderFactory.from(CONTESTED, FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .respondentFmName("Joey") + .respondentLname("Bloggs") + .build())).build(), + new String[]{})) + .isNull(); + } } - @Test - void givenCaseData_whenEmptyContentProvided() { - assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .respondentFmName("Joey") - .respondentLname("Bloggs") - .build())).build(), - new String[] {})) - .isNull(); + @Nested + class Consented { + @ParameterizedTest + @ValueSource(strings = { + "The respondent is Joe Bloggs", + "whatever", ""}) + @NullSource + void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName(String validContent) { + Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> + Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> + Arrays.stream(StringDecorator.values()).forEach(lnameDecorator -> + assertThat(underTest.getWarning( + FinremCaseDetailsBuilderFactory.from(CONSENTED, FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .appRespondentFmName(fmNameDecorator.decorate("Joe")) + .appRespondentLName(lnameDecorator.decorate("Bloggs")) + .build())).build(), + new String[]{validContentDecorator.decorate(validContent)})) + .isNull() + ) + ) + ); + } + + @ParameterizedTest + @ValueSource(strings = {"The respondent is Joe", "whatever", ""}) + @NullSource + void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndEmptyLastName(String validContent) { + Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> + Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> + assertThat(underTest.getWarning( + FinremCaseDetailsBuilderFactory.from(CONSENTED, FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .appRespondentFmName(fmNameDecorator.decorate("Joe")) + .build())).build(), + new String[]{validContentDecorator.decorate(validContent)})) + .isNull() + ) + ); + } + + @Test + void givenCaseData_whenContentContainsNameDoesNotMatchRespondentFirstNameAndLastName() { + assertThat(underTest.getWarning( + FinremCaseDetailsBuilderFactory.from(CONSENTED, FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .appRespondentFmName("Joe") + .appRespondentLName("Bloggs") + .build())).build(), + new String[]{"The respondent is Amy Clarks"})) + .isEqualTo("Respondent name may not match"); + } + + @Test + void givenCaseData_whenOneOfTheContentsContainsNameDoesNotMatchRespondentFirstNameAndLastName() { + assertThat(underTest.getWarning( + FinremCaseDetailsBuilderFactory.from(CONSENTED, FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .appRespondentFmName("Joey") + .appRespondentLName("Bloggs") + .build())).build(), + new String[]{"The respondent is Joe Bloggs", "Whatever", "Whenever"})) + .isEqualTo("Respondent name may not match"); + } + + @Test + void givenCaseData_whenEmptyContentProvided() { + assertThat(underTest.getWarning( + FinremCaseDetailsBuilderFactory.from(CONSENTED, FinremCaseData.builder() + .contactDetailsWrapper(ContactDetailsWrapper.builder() + .appRespondentFmName("Joey") + .appRespondentLName("Bloggs") + .build())).build(), + new String[]{})) + .isNull(); + } } @Test From f73b62c29b2c99ee543ac870af925b1c8b5ccd75 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 25 Jun 2024 12:29:22 +0100 Subject: [PATCH 59/96] Remove duplicated codes in the test case --- .../ccd/wrapper/ContactDetailsWrapper.java | 5 + ...pondentNameDocumentContentCheckerTest.java | 198 +++++++----------- 2 files changed, 80 insertions(+), 123 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/ContactDetailsWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/ContactDetailsWrapper.java index c9d07856f9..2a6bcf473f 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/ContactDetailsWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/ContactDetailsWrapper.java @@ -7,6 +7,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.Setter; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.Address; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.NoticeOfChangeParty; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.YesOrNo; @@ -41,8 +42,10 @@ public class ContactDetailsWrapper { @JsonProperty("applicantAddressConfidential") private YesOrNo applicantAddressHiddenFromRespondent; @JsonProperty("respondentFMName") + @Setter private String respondentFmName; @JsonProperty("respondentLName") + @Setter private String respondentLname; @JsonProperty("respondentRepresented") private YesOrNo contestedRespondentRepresented; @@ -75,7 +78,9 @@ public class ContactDetailsWrapper { private String solicitorDxNumber; private YesOrNo solicitorAgreeToReceiveEmails; @JsonProperty("appRespondentFMName") + @Setter private String appRespondentFmName; + @Setter private String appRespondentLName; @JsonProperty("appRespondentRep") private YesOrNo consentedRespondentRepresented; diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java index 9d14476e05..df5d9a9285 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/RespondentNameDocumentContentCheckerTest.java @@ -3,14 +3,19 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.NullSource; -import org.junit.jupiter.params.provider.ValueSource; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import uk.gov.hmcts.reform.finrem.caseorchestration.FinremCaseDetailsBuilderFactory; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ContactDetailsWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.utils.StringDecorator; +import java.lang.reflect.Field; import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType.CONSENTED; @@ -21,100 +26,43 @@ class RespondentNameDocumentContentCheckerTest { private final RespondentNameDocumentContentChecker underTest = new RespondentNameDocumentContentChecker(); @Nested - class Contested { - @ParameterizedTest - @ValueSource(strings = { - "The respondent is Joe Bloggs", - "whatever", ""}) - @NullSource - void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName(String validContent) { - Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> - Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> - Arrays.stream(StringDecorator.values()).forEach(lnameDecorator -> - assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(CONTESTED, FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .respondentFmName(fmNameDecorator.decorate("Joe")) - .respondentLname(lnameDecorator.decorate("Bloggs")) - .build())).build(), - new String[]{validContentDecorator.decorate(validContent)})) - .isNull() - ) - ) + class ContestedAndConsentedTests { + private static Stream contestedAndConsentedCases() { + return Stream.of( + Arguments.of(CONTESTED, "respondentFmName", "respondentLname"), + Arguments.of(CONSENTED, "appRespondentFmName", "appRespondentLName") ); } @ParameterizedTest - @ValueSource(strings = {"The respondent is Joe", "whatever", ""}) - @NullSource - void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndEmptyLastName(String validContent) { - Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> - Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> - assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(CONTESTED, FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .respondentFmName(fmNameDecorator.decorate("Joe")) - .build())).build(), - new String[]{validContentDecorator.decorate(validContent)})) - .isNull() + @MethodSource("contestedAndConsentedCases") + void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName( + CaseType caseType, String firstNameField, String lastNameField) { + List testContents = List.of("The respondent is Joe Bloggs", "whatever", ""); + testContents.forEach(validContent -> + Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> + Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> + Arrays.stream(StringDecorator.values()).forEach(lnameDecorator -> + assertThat(underTest.getWarning( + createCaseDetails(caseType, firstNameField, fmNameDecorator.decorate("Joe"), lastNameField, + lnameDecorator.decorate("Bloggs")), new String[]{validContentDecorator.decorate(validContent)})) + .isNull() + ) + ) ) ); } - @Test - void givenCaseData_whenContentContainsNameDoesNotMatchRespondentFirstNameAndLastName() { - assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(CONTESTED, FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .respondentFmName("Joe") - .respondentLname("Bloggs") - .build())).build(), - new String[]{"The respondent is Amy Clarks"})) - .isEqualTo("Respondent name may not match"); - } - - @Test - void givenCaseData_whenOneOfTheContentsContainsNameDoesNotMatchRespondentFirstNameAndLastName() { - assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(CONTESTED, FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .respondentFmName("Joey") - .respondentLname("Bloggs") - .build())).build(), - new String[]{"The respondent is Joe Bloggs", "Whatever", "Whenever"})) - .isEqualTo("Respondent name may not match"); - } - - @Test - void givenCaseData_whenEmptyContentProvided() { - assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(CONTESTED, FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .respondentFmName("Joey") - .respondentLname("Bloggs") - .build())).build(), - new String[]{})) - .isNull(); - } - } - - @Nested - class Consented { @ParameterizedTest - @ValueSource(strings = { - "The respondent is Joe Bloggs", - "whatever", ""}) - @NullSource - void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName(String validContent) { - Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> - Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> - Arrays.stream(StringDecorator.values()).forEach(lnameDecorator -> + @MethodSource("contestedAndConsentedCases") + void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndEmptyLastName( + CaseType caseType, String firstNameField, String lastNameField) { + List testContents = List.of("The respondent is Joe", "whatever", ""); + testContents.forEach(validContent -> + Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> + Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(CONSENTED, FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .appRespondentFmName(fmNameDecorator.decorate("Joe")) - .appRespondentLName(lnameDecorator.decorate("Bloggs")) - .build())).build(), + createCaseDetails(caseType, firstNameField, fmNameDecorator.decorate("Joe"), lastNameField, null), new String[]{validContentDecorator.decorate(validContent)})) .isNull() ) @@ -123,57 +71,61 @@ void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndLastName( } @ParameterizedTest - @ValueSource(strings = {"The respondent is Joe", "whatever", ""}) - @NullSource - void givenCaseData_whenContentContainsNameMatchesRespondentFirstNameAndEmptyLastName(String validContent) { - Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> - Arrays.stream(StringDecorator.values()).forEach(fmNameDecorator -> - assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(CONSENTED, FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .appRespondentFmName(fmNameDecorator.decorate("Joe")) - .build())).build(), - new String[]{validContentDecorator.decorate(validContent)})) - .isNull() - ) - ); - } - - @Test - void givenCaseData_whenContentContainsNameDoesNotMatchRespondentFirstNameAndLastName() { + @MethodSource("contestedAndConsentedCases") + void givenCaseData_whenContentContainsNameDoesNotMatchRespondentFirstNameAndLastName( + CaseType caseType, String firstNameField, String lastNameField) { assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(CONSENTED, FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .appRespondentFmName("Joe") - .appRespondentLName("Bloggs") - .build())).build(), + createCaseDetails(caseType, firstNameField, "Joe", lastNameField, "Bloggs"), new String[]{"The respondent is Amy Clarks"})) .isEqualTo("Respondent name may not match"); } - @Test - void givenCaseData_whenOneOfTheContentsContainsNameDoesNotMatchRespondentFirstNameAndLastName() { + @ParameterizedTest + @MethodSource("contestedAndConsentedCases") + void givenCaseData_whenOneOfTheContentsContainsNameDoesNotMatchRespondentFirstNameAndLastName( + CaseType caseType, String firstNameField, String lastNameField) { assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(CONSENTED, FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .appRespondentFmName("Joey") - .appRespondentLName("Bloggs") - .build())).build(), + createCaseDetails(caseType, firstNameField, "Joey", lastNameField, "Bloggs"), new String[]{"The respondent is Joe Bloggs", "Whatever", "Whenever"})) .isEqualTo("Respondent name may not match"); } - @Test - void givenCaseData_whenEmptyContentProvided() { + @ParameterizedTest + @MethodSource("contestedAndConsentedCases") + void givenCaseData_whenEmptyContentProvided( + CaseType caseType, String firstNameField, String lastNameField) { assertThat(underTest.getWarning( - FinremCaseDetailsBuilderFactory.from(CONSENTED, FinremCaseData.builder() - .contactDetailsWrapper(ContactDetailsWrapper.builder() - .appRespondentFmName("Joey") - .appRespondentLName("Bloggs") - .build())).build(), + createCaseDetails(caseType, firstNameField, "Joey", lastNameField, "Bloggs"), new String[]{})) .isNull(); } + + private FinremCaseDetails createCaseDetails(CaseType caseType, String firstNameField, String firstName, String lastNameField, + String lastName) { + ContactDetailsWrapper.ContactDetailsWrapperBuilder contactDetailsWrapperBuilder = ContactDetailsWrapper.builder(); + ContactDetailsWrapper wrapper = contactDetailsWrapperBuilder.build(); + + try { + if (firstNameField != null) { + Field fmNameField = ContactDetailsWrapper.class.getDeclaredField(firstNameField); + fmNameField.setAccessible(true); + fmNameField.set(wrapper, firstName); + } + + if (lastNameField != null) { + Field lnameField = ContactDetailsWrapper.class.getDeclaredField(lastNameField); + lnameField.setAccessible(true); + lnameField.set(wrapper, lastName); + } + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } + + FinremCaseData.FinremCaseDataBuilder caseDataBuilder = FinremCaseData.builder() + .contactDetailsWrapper(wrapper); + + return FinremCaseDetailsBuilderFactory.from(caseType, caseDataBuilder).build(); + } } @Test From 3698a1d61e7aec65878cf0c45685b33a8c29a7a5 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 25 Jun 2024 15:32:16 +0100 Subject: [PATCH 60/96] eliminate duplicated warning messages --- ...DocumentConsentedAboutToSubmitHandler.java | 8 ++-- ...DocumentContestedAboutToSubmitHandler.java | 8 ++-- ...mentConsentedAboutToSubmitHandlerTest.java | 39 ++++++++++++++++++- ...mentContestedAboutToSubmitHandlerTest.java | 39 ++++++++++++++++++- 4 files changed, 86 insertions(+), 8 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java index 06c96adca5..276f60352d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java @@ -14,6 +14,8 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; @Slf4j @Service @@ -45,19 +47,19 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); - final List warnings = newUploadedDocumentsService.getNewUploadDocuments(caseData, caseDataBefore, FinremCaseData::getUploadDocuments) + final Set warnings = newUploadedDocumentsService.getNewUploadDocuments(caseData, caseDataBefore, FinremCaseData::getUploadDocuments) .stream() .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) .flatMap(List::stream) .filter(ObjectUtils::isNotEmpty) - .toList(); + .collect(Collectors.toSet()); if (!warnings.isEmpty()) { log.info("Number of warnings encountered when uploading document for a case {}: {}", finremCaseDetails.getId(), warnings.size()); } return GenericAboutToStartOrSubmitCallbackResponse.builder() - .warnings(warnings) + .warnings((warnings.stream().sorted().toList())) .data(caseData).build(); } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java index d45d200ab2..4796320788 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java @@ -19,6 +19,8 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; import static java.util.Comparator.comparing; import static java.util.Comparator.nullsLast; @@ -57,12 +59,12 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); - final List warnings = newUploadedDocumentsService.getNewUploadDocuments(caseData, caseDataBefore, + final Set warnings = newUploadedDocumentsService.getNewUploadDocuments(caseData, caseDataBefore, FinremCaseData::getUploadGeneralDocuments).stream() .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) .flatMap(List::stream) .filter(ObjectUtils::isNotEmpty) - .toList(); + .collect(Collectors.toSet()); if (!warnings.isEmpty()) { log.info("Number of warnings encountered when uploading general document for a case {}: {}", finremCaseDetails.getId(), warnings.size()); @@ -79,7 +81,7 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem uploadGeneralDocumentsCategoriser.categorise(caseData); return GenericAboutToStartOrSubmitCallbackResponse.builder() - .warnings(warnings) + .warnings(warnings.stream().sorted().toList()) .data(caseData).build(); } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java index 08f8120ebe..0f1a8c9d10 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java @@ -65,7 +65,7 @@ void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadDocumentConsen @ParameterizedTest @ValueSource(booleans = {true, false}) - void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasWarnings) { + void givenValidCaseData_whenWarningIsDetected_thenPopulateWarning(boolean hasWarnings) { List expectedWarnings = hasWarnings ? List.of("warnings") : List.of(); when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( UploadDocumentCollection.builder() @@ -100,6 +100,43 @@ void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasW } } + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void givenValidCaseData_whenWarningsAreDetected_thenPopulateSortedWarnings(boolean hasWarnings) { + when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( + UploadDocumentCollection.builder() + .value(UploadDocument.builder().build()) + .build() + )); + when(documentCheckerService.getWarnings(any(), any(), any())).thenReturn(hasWarnings ? List.of("2warnings", "1warnings","1warnings") + : List.of()); + + FinremCaseDetails finremCaseDetails = FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONSENTED, FinremCaseData.builder() + .uploadDocuments(List.of( + createUploadDocumentCollection( + UploadDocumentType.APPLICATION, "New email content", + caseDocument("/fileUrl", "/binaryUrl","document.extension"), LocalDate.now(), "New Example", + "newDocument.filename") + ))) + .build(); + + FinremCaseDetails finremCaseDetailsBefore = FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONTESTED, + FinremCaseData.builder()).build(); + + GenericAboutToStartOrSubmitCallbackResponse response = underTest.handle( + FinremCallbackRequest.builder() + .caseDetails(finremCaseDetails) + .caseDetailsBefore(finremCaseDetailsBefore).build(), + AUTH_TOKEN); + assertThat(response.getWarnings()).isEqualTo(hasWarnings ? List.of("1warnings", "2warnings") : List.of()); + if (hasWarnings) { + assertThat(logs.getInfos()).containsExactly(format( + "Number of warnings encountered when uploading document for a case %s: %s", CASE_ID, 2)); + } else { + assertThat(logs.getInfos()).isEmpty(); + } + } + private UploadDocumentCollection createUploadDocumentCollection(UploadDocumentType type, String emailContent, CaseDocument link, LocalDate dateAdded, String comment, String fileName) { diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java index b2f2e2298b..ad7550e8f2 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java @@ -70,7 +70,7 @@ void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadDocumentContes @ParameterizedTest @ValueSource(booleans = {true, false}) - void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasWarnings) { + void givenValidCaseData_whenWarningIsDetected_thenPopulateWarning(boolean hasWarnings) { List expectedWarnings = hasWarnings ? List.of("warnings") : List.of(); when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( UploadGeneralDocumentCollection.builder() @@ -105,6 +105,43 @@ void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasW } } + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasWarnings) { + when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder().build()) + .build() + )); + when(documentCheckerService.getWarnings(any(), any(), any())).thenReturn(hasWarnings ? List.of("2warnings", "2warnings", "1warnings") + : List.of()); + + FinremCaseDetails finremCaseDetails = FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONTESTED, FinremCaseData.builder() + .uploadGeneralDocuments(List.of( + createGeneralUploadDocumentItem( + UploadGeneralDocumentType.LETTER_EMAIL_FROM_RESPONDENT, "New email content", + createCaseDocument(), LocalDate.now(), "New Example", "newDocument.filename") + )) + ) + .build(); + FinremCaseDetails finremCaseDetailsBefore = FinremCaseDetailsBuilderFactory + .from(Long.valueOf(CASE_ID), CaseType.CONTESTED, FinremCaseData.builder()) + .build(); + + GenericAboutToStartOrSubmitCallbackResponse response = underTest.handle( + FinremCallbackRequest.builder() + .caseDetails(finremCaseDetails) + .caseDetailsBefore(finremCaseDetailsBefore).build(), + AUTH_TOKEN); + assertThat(response.getWarnings()).isEqualTo(hasWarnings ? List.of("1warnings", "2warnings") : List.of()); + if (hasWarnings) { + assertThat(logs.getInfos()).containsExactly(format( + "Number of warnings encountered when uploading general document for a case %s: %s", CASE_ID, 2)); + } else { + assertThat(logs.getInfos()).isEmpty(); + } + } + @Test void givenValidCaseData_whenHandleUploadGeneralDocument_thenSortCollectionByDateAndCategoriserInvoked() { UploadGeneralDocumentCollection oldDoc = createGeneralUploadDocumentItem( From 967138f5c5407159a019b0c166cf39d3e7f98638 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Tue, 25 Jun 2024 19:09:00 +0100 Subject: [PATCH 61/96] (Half Done) update the logic in duplicated filename checker --- ...DocumentConsentedAboutToSubmitHandler.java | 4 +- ...DocumentContestedAboutToSubmitHandler.java | 4 +- .../documentchecker/DocumentChecker.java | 2 +- .../DocumentCheckerService.java | 4 +- .../documentchecker/DocxDocumentChecker.java | 2 +- .../DuplicateFilenameDocumentChecker.java | 278 +++++++++++++++++- .../documentchecker/PdfDocumentChecker.java | 2 +- ...mentConsentedAboutToSubmitHandlerTest.java | 4 +- ...mentContestedAboutToSubmitHandlerTest.java | 4 +- .../DocumentCheckerServiceTest.java | 19 +- .../DocxDocumentCheckerTest.java | 4 +- .../DuplicateFilenameDocumentCheckerTest.java | 34 ++- .../PdfDocumentCheckerTest.java | 4 +- 13 files changed, 315 insertions(+), 50 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java index 276f60352d..5b3432ffaf 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java @@ -43,13 +43,15 @@ public boolean canHandle(CallbackType callbackType, CaseType caseType, EventType @SuppressWarnings("squid:CallToDeprecatedMethod") public GenericAboutToStartOrSubmitCallbackResponse handle(FinremCallbackRequest callbackRequest, String userAuthorisation) { + FinremCaseDetails beforeFinremCaseDetails = callbackRequest.getCaseDetailsBefore(); FinremCaseDetails finremCaseDetails = callbackRequest.getCaseDetails(); FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); final Set warnings = newUploadedDocumentsService.getNewUploadDocuments(caseData, caseDataBefore, FinremCaseData::getUploadDocuments) .stream() - .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) + .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), beforeFinremCaseDetails, finremCaseDetails, + userAuthorisation)) .flatMap(List::stream) .filter(ObjectUtils::isNotEmpty) .collect(Collectors.toSet()); diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java index 4796320788..55690e4401 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java @@ -55,13 +55,15 @@ public boolean canHandle(CallbackType callbackType, CaseType caseType, EventType @SuppressWarnings("squid:CallToDeprecatedMethod") public GenericAboutToStartOrSubmitCallbackResponse handle(FinremCallbackRequest callbackRequest, String userAuthorisation) { + FinremCaseDetails beforeFinremCaseDetails = callbackRequest.getCaseDetailsBefore(); FinremCaseDetails finremCaseDetails = callbackRequest.getCaseDetails(); FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); final Set warnings = newUploadedDocumentsService.getNewUploadDocuments(caseData, caseDataBefore, FinremCaseData::getUploadGeneralDocuments).stream() - .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), finremCaseDetails, userAuthorisation)) + .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), beforeFinremCaseDetails, finremCaseDetails, + userAuthorisation)) .flatMap(List::stream) .filter(ObjectUtils::isNotEmpty) .collect(Collectors.toSet()); diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentChecker.java index 252d15202b..d865fc8934 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentChecker.java @@ -9,6 +9,6 @@ public interface DocumentChecker { boolean canCheck(CaseDocument caseDocument); - List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails caseDetails) + List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails) throws DocumentContentCheckerException; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java index f780b2693f..fbd35f53c7 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java @@ -26,7 +26,7 @@ public DocumentCheckerService(EvidenceManagementDownloadService downloadService, this.documentCheckers = documentCheckers; } - public List getWarnings(CaseDocument caseDocument, FinremCaseDetails caseDetails, String authToken) { + public List getWarnings(CaseDocument caseDocument, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails, String authToken) { List documentCheckersForDocument = documentCheckers.stream() .filter(dc -> dc.canCheck(caseDocument)) .toList(); @@ -40,7 +40,7 @@ public List getWarnings(CaseDocument caseDocument, FinremCaseDetails cas List warnings = new ArrayList<>(); documentCheckersForDocument.forEach(dc -> { try { - warnings.addAll(dc.getWarnings(caseDocument, bytes, caseDetails)); + warnings.addAll(dc.getWarnings(caseDocument, bytes, beforeCaseDetails, caseDetails)); } catch (DocumentContentCheckerException e) { log.error(format("Unexpected error when getting warnings from %s", dc.getClass().getName()), e); } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java index 3027b013ff..d598487194 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java @@ -28,7 +28,7 @@ public boolean canCheck(CaseDocument caseDocument) { } @Override - public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails caseDetails) + public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails) throws DocumentContentCheckerException { String[] content = getContent(bytes); diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index a171e87733..0419936782 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -1,17 +1,44 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanWrapperImpl; import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AdditionalHearingDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AmendedConsentOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApprovedOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DirectionOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.IntervenerHearingNotice; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ManageScannedDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OrderRefusalHolder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OtherDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.PaymentDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.PensionType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.RefusalOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.RespondToOrderDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ScannedDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.SendOrderDocuments; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.SolUploadDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadAdditionalDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadCaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConfidentialDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConsentOrderDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadOrder; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.function.Supplier; +import java.util.stream.Stream; -import static org.apache.commons.lang3.ObjectUtils.isNotEmpty; +import static java.util.Optional.ofNullable; @Component +@Slf4j public class DuplicateFilenameDocumentChecker implements DocumentChecker { private static final String WARNING = "A document with this filename already exists on the case"; @@ -21,22 +48,251 @@ public boolean canCheck(CaseDocument caseDocument) { return true; } + private boolean isDuplicateFilename(CaseDocument caseDocument, Supplier caseDocumentSupplier) { + return ofNullable(caseDocumentSupplier.get()).orElse(CaseDocument.builder().documentFilename("").build()) + .getDocumentFilename().equals(caseDocument.getDocumentFilename()); + } + + private boolean isDuplicatedFilenameInFinremCaseData(CaseDocument caseDocument, FinremCaseData caseData) { + return Arrays.stream(new BeanWrapperImpl(caseData.getClass()).getPropertyDescriptors()) + .filter(d -> CaseDocument.class.equals(d.getPropertyType())) + .anyMatch(pd -> + isDuplicateFilename(caseDocument, () -> { + try { + return (CaseDocument) pd.getReadMethod().invoke(caseData); + } catch (Exception e) { + log.error("Fail to invoke:" + pd.getReadMethod().getName()); + return null; + } + }) + ); + } + @Override - public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails caseDetails) + public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails) throws DocumentContentCheckerException { + final List duplicatedWarning = List.of(WARNING); - FinremCaseData caseData = caseDetails.getData(); - if (isNotEmpty(caseData.getAdditionalDocument()) && isDuplicateFilename(caseDocument, caseData::getAdditionalDocument)) { - return List.of(WARNING); + FinremCaseData caseData = beforeCaseDetails.getData(); + if (isDuplicatedFilenameInFinremCaseData(caseDocument, caseData)) { + return duplicatedWarning; + } + + // pensionCollection, consentPensionCollection + if (Stream.of(ofNullable(caseData.getPensionCollection()).orElse(List.of()), + ofNullable(caseData.getConsentPensionCollection()).orElse(List.of())) + .flatMap(List::stream) + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getTypedCaseDocument()).orElse(PensionType.builder().build()) + .getPensionDocument()))) { + return duplicatedWarning; + } + // copyOfPaperFormA + if (ofNullable(caseData.getCopyOfPaperFormA()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(PaymentDocument.builder().build()) + .getUploadedDocument()))) { + return duplicatedWarning; + } + // otherDocumentsCollection + if (ofNullable(caseData.getOtherDocumentsCollection()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(OtherDocument.builder().build()) + .getUploadedDocument()))) { + return duplicatedWarning; + } + // additionalCicDocuments + if (ofNullable(caseData.getAdditionalCicDocuments()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { + return duplicatedWarning; + } + // orderRefusalCollection, orderRefusalCollectionNew + if (Stream.of(ofNullable(caseData.getOrderRefusalCollection()).orElse(List.of()), + ofNullable(caseData.getOrderRefusalCollectionNew()).orElse(List.of())) + .flatMap(List::stream) + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(OrderRefusalHolder.builder().build()) + .getOrderRefusalDocs()))) { + return duplicatedWarning; + } + // uploadConsentOrderDocuments + if (ofNullable(caseData.getUploadConsentOrderDocuments()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadConsentOrderDocument.builder().build()) + .getDocumentLink()))) { + return duplicatedWarning; + } + // uploadOrder + if (ofNullable(caseData.getUploadOrder()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadOrder.builder().build()) + .getDocumentLink()))) { + return duplicatedWarning; + } + // uploadDocuments + if (ofNullable(caseData.getUploadDocuments()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadDocument.builder().build()) + .getDocumentLink()))) { + return duplicatedWarning; + } + // solUploadDocuments + if (ofNullable(caseData.getSolUploadDocuments()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(SolUploadDocument.builder().build()) + .getDocumentLink()))) { + return duplicatedWarning; + } + // respondToOrderDocuments + if (ofNullable(caseData.getRespondToOrderDocuments()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(RespondToOrderDocument.builder().build()) + .getDocumentLink()))) { + return duplicatedWarning; + } + // amendedConsentOrderCollection + if (ofNullable(caseData.getAmendedConsentOrderCollection()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(AmendedConsentOrder.builder().build()) + .getAmendedConsentOrder()))) { + return duplicatedWarning; + } + // scannedDocuments + if (ofNullable(caseData.getScannedDocuments()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(ScannedDocument.builder().build()) + .getUrl()))) { + return duplicatedWarning; + } + // approvedOrderCollection + if (ofNullable(caseData.getApprovedOrderCollection()).orElse(List.of()) + .stream() + .anyMatch(d -> + isDuplicateFilename(caseDocument, () -> ofNullable(d.getApprovedOrder()).orElse(ApprovedOrder.builder().build()) + .getConsentOrder()) + || isDuplicateFilename(caseDocument, () -> ofNullable(d.getApprovedOrder()).orElse(ApprovedOrder.builder().build()) + .getOrderLetter()) + || ofNullable(ofNullable(d.getApprovedOrder()).orElse(ApprovedOrder.builder().build()).getPensionDocuments()).orElse(List.of()) + .stream() + .anyMatch(e -> isDuplicateFilename(caseDocument, () -> ofNullable(e.getTypedCaseDocument()).orElse(PensionType.builder().build()) + .getPensionDocument())) + ) + ) { + return duplicatedWarning; } - if (isDuplicateFilename(caseDocument, caseData.getGeneralOrderWrapper()::getGeneralOrderLatestDocument)) { - return List.of(WARNING); + // scannedD81s + if (ofNullable(caseData.getScannedD81s()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { + return duplicatedWarning; + } + // additionalHearingDocuments + if (ofNullable(caseData.getAdditionalHearingDocuments()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(AdditionalHearingDocument.builder().build()) + .getDocument()))) { + return duplicatedWarning; + } + // hearingNoticeDocumentPack + if (ofNullable(caseData.getHearingNoticeDocumentPack()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { + return duplicatedWarning; + } + // hearingNoticesDocumentCollection + if (ofNullable(caseData.getHearingNoticesDocumentCollection()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { + return duplicatedWarning; + } + // uploadGeneralDocuments + if (ofNullable(caseData.getUploadGeneralDocuments()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadGeneralDocument.builder().build()) + .getDocumentLink()))) { + return duplicatedWarning; + } + // uploadHearingOrder + if (ofNullable(caseData.getUploadHearingOrder()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(DirectionOrder.builder().build()) + .getUploadDraftDocument()))) { + return duplicatedWarning; + } + // hearingOrderOtherDocuments + if (ofNullable(caseData.getHearingOrderOtherDocuments()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { + return duplicatedWarning; + } + // finalOrderCollection + if (ofNullable(caseData.getFinalOrderCollection()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(DirectionOrder.builder().build()) + .getUploadDraftDocument()))) { + return duplicatedWarning; + } + // intv1HearingNoticesCollection, intv2HearingNoticesCollection, intv3HearingNoticesCollection, intv4HearingNoticesCollection + if (Stream.of(ofNullable(caseData.getIntv1HearingNoticesCollection()).orElse(List.of()), + ofNullable(caseData.getIntv2HearingNoticesCollection()).orElse(List.of()), + ofNullable(caseData.getIntv3HearingNoticesCollection()).orElse(List.of()), + ofNullable(caseData.getIntv4HearingNoticesCollection()).orElse(List.of())) + .flatMap(List::stream) + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(IntervenerHearingNotice.builder().build()) + .getCaseDocument()))) { + return duplicatedWarning; + } + // refusalOrderCollection + if (ofNullable(caseData.getRefusalOrderCollection()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(RefusalOrder.builder().build()) + .getRefusalOrderAdditionalDocument()))) { + return duplicatedWarning; + } + // uploadAdditionalDocument + if (ofNullable(caseData.getUploadAdditionalDocument()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadAdditionalDocument.builder().build()) + .getAdditionalDocuments()))) { + return duplicatedWarning; + } + // confidentialDocumentsUploaded + if (ofNullable(caseData.getConfidentialDocumentsUploaded()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadConfidentialDocument.builder().build()) + .getDocumentLink()))) { + return duplicatedWarning; + } + // manageCaseDocumentCollection + if (ofNullable(caseData.getManageCaseDocumentCollection()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getUploadCaseDocument()).orElse(UploadCaseDocument.builder().build()) + .getCaseDocuments()))) { + return duplicatedWarning; + } + // applicantScanDocuments, respondentScanDocuments + if (Stream.of(ofNullable(caseData.getApplicantScanDocuments()).orElse(List.of()), + ofNullable(caseData.getRespondentScanDocuments()).orElse(List.of())) + .flatMap(List::stream) + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(ScannedDocument.builder().build()) + .getUrl()))) { + return duplicatedWarning; + } + // manageScannedDocumentCollection + if (ofNullable(caseData.getManageScannedDocumentCollection()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getManageScannedDocument()).orElse(ManageScannedDocument.builder() + .uploadCaseDocument(UploadCaseDocument.builder().build()) + .build()).getUploadCaseDocument().getCaseDocuments()))) { + return duplicatedWarning; + } + // ordersSentToPartiesCollection + if (ofNullable(caseData.getOrdersSentToPartiesCollection()).orElse(List.of()) + .stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(SendOrderDocuments.builder().build()) + .getCaseDocument()))) { + return duplicatedWarning; } return Collections.emptyList(); } - - private boolean isDuplicateFilename(CaseDocument caseDocument, Supplier caseDocumentSupplier) { - return caseDocumentSupplier.get() != null && caseDocumentSupplier.get().getDocumentFilename().equals(caseDocument.getDocumentFilename()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java index a34a2ccb9f..0289b5a8e1 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java @@ -30,7 +30,7 @@ public boolean canCheck(CaseDocument caseDocument) { } @Override - public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails caseDetails) + public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails) throws DocumentContentCheckerException { try { String[] content = getContent(bytes); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java index 0f1a8c9d10..5964026cbc 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java @@ -72,7 +72,7 @@ void givenValidCaseData_whenWarningIsDetected_thenPopulateWarning(boolean hasWar .value(UploadDocument.builder().build()) .build() )); - when(documentCheckerService.getWarnings(any(), any(), any())).thenReturn(expectedWarnings); + when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenReturn(expectedWarnings); FinremCaseDetails finremCaseDetails = FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONSENTED, FinremCaseData.builder() .uploadDocuments(List.of( @@ -108,7 +108,7 @@ void givenValidCaseData_whenWarningsAreDetected_thenPopulateSortedWarnings(boole .value(UploadDocument.builder().build()) .build() )); - when(documentCheckerService.getWarnings(any(), any(), any())).thenReturn(hasWarnings ? List.of("2warnings", "1warnings","1warnings") + when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenReturn(hasWarnings ? List.of("2warnings", "1warnings","1warnings") : List.of()); FinremCaseDetails finremCaseDetails = FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONSENTED, FinremCaseData.builder() diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java index ad7550e8f2..dd723e2c8b 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java @@ -77,7 +77,7 @@ void givenValidCaseData_whenWarningIsDetected_thenPopulateWarning(boolean hasWar .value(UploadGeneralDocument.builder().build()) .build() )); - when(documentCheckerService.getWarnings(any(), any(), any())).thenReturn(expectedWarnings); + when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenReturn(expectedWarnings); FinremCaseDetails finremCaseDetails = FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONTESTED, FinremCaseData.builder() .uploadGeneralDocuments(List.of( @@ -113,7 +113,7 @@ void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasW .value(UploadGeneralDocument.builder().build()) .build() )); - when(documentCheckerService.getWarnings(any(), any(), any())).thenReturn(hasWarnings ? List.of("2warnings", "2warnings", "1warnings") + when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenReturn(hasWarnings ? List.of("2warnings", "2warnings", "1warnings") : List.of()); FinremCaseDetails finremCaseDetails = FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONTESTED, FinremCaseData.builder() diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java index 952f95c1c2..1f4408fba7 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java @@ -53,9 +53,10 @@ void testSingleWarningReturnedByDocxDocumentChecker() throws DocumentContentChec when(downloadService.download(any(), eq(AUTH_TOKEN))).thenReturn(new byte[]{}); when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); - when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any())).thenReturn(List.of("docx warning")); + when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any(), any())).thenReturn(List.of("docx warning")); - List actual = underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN); + List actual = underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), FinremCaseDetails.builder().build(), + AUTH_TOKEN); assertThat(actual).containsExactly("docx warning"); } @@ -65,11 +66,12 @@ void testMultipleWarningsReturnedCheckers() throws DocumentContentCheckerExcepti when(downloadService.download(any(), eq(AUTH_TOKEN))).thenReturn(new byte[]{}); when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); - when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any())).thenReturn(List.of("docx warning")); + when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any(), any())).thenReturn(List.of("docx warning")); when(duplicateFilenameDocumentChecker.canCheck(caseDocument)).thenReturn(true); - when(duplicateFilenameDocumentChecker.getWarnings(eq(caseDocument), any(), any())).thenReturn(List.of("duplicate warning")); + when(duplicateFilenameDocumentChecker.getWarnings(eq(caseDocument), any(), any(), any())).thenReturn(List.of("duplicate warning")); - List actual = underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN); + List actual = underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), FinremCaseDetails.builder().build(), + AUTH_TOKEN); assertThat(actual).contains("docx warning", "duplicate warning"); } @@ -77,10 +79,10 @@ void testMultipleWarningsReturnedCheckers() throws DocumentContentCheckerExcepti void testIfDocxCheckerThrowDocumentContentCheckerException() throws DocumentContentCheckerException { final CaseDocument caseDocument = caseDocument(); when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); - when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any())) + when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any(), any())) .thenThrow(new DocumentContentCheckerException(new RuntimeException("test"))); - underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN); + underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), FinremCaseDetails.builder().build(), AUTH_TOKEN); assertThat(logs.getErrors()).isNotEmpty().contains("Unexpected error when getting warnings from " + DocxDocumentChecker.class.getName()); } @@ -90,6 +92,7 @@ void testNoDocumentCheckerCanCheck() { when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(false); when(duplicateFilenameDocumentChecker.canCheck(caseDocument)).thenReturn(false); - assertThat(underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), AUTH_TOKEN)).isEmpty(); + assertThat(underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), FinremCaseDetails.builder().build(), AUTH_TOKEN)) + .isEmpty(); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java index 29732d7884..3181da953a 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java @@ -82,7 +82,7 @@ void testGetWarnings_withValidContent(int testCase) throws DocumentContentChecke when(caseNumberDocumentContentChecker.getWarning(eq(caseDetails), any(String[].class))) .thenReturn(testCase == 1 ? null : "Warning2"); - List warnings = underTest.getWarnings(caseDocument, documentBytes, caseDetails); + List warnings = underTest.getWarnings(caseDocument, documentBytes, caseDetails, caseDetails); assertThat(warnings).hasSize(testCase == 1 ? 1 : 2).contains("Warning1"); @@ -103,7 +103,7 @@ void testGetWarnings_whenGivenFileCannotBeRead() throws IOException { FinremCaseDetails caseDetails = new FinremCaseDetails(); byte[] documentBytes = "Invalid content".getBytes(); - assertThatThrownBy(() -> underTest.getWarnings(caseDocument, documentBytes, caseDetails)) + assertThatThrownBy(() -> underTest.getWarnings(caseDocument, documentBytes, caseDetails, caseDetails)) .isInstanceOf(DocumentContentCheckerException.class); } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index c82e1e32ba..e175526e57 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -63,7 +63,7 @@ void testGetWarnings_NoDuplicate() throws DocumentContentCheckerException { when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); when(additionalDocument.getDocumentFilename()).thenReturn("additionalDocumentFilename"); - List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails); + List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails, caseDetails); assertThat(warnings).isEmpty(); } @@ -77,7 +77,7 @@ void testGetWarnings_NoDuplicateWhenAdditionalDocumentIsNull() throws DocumentCo when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); - List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails); + List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails, caseDetails); assertThat(warnings).isEmpty(); } @@ -88,28 +88,30 @@ void testGetWarnings_DuplicateInAdditionalDocument() throws DocumentContentCheck when(caseData.getAdditionalDocument()).thenReturn(additionalDocument); when(additionalDocument.getDocumentFilename()).thenReturn("inputFilename"); - List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails); + List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails, caseDetails); assertThat(warnings).hasSize(1).containsExactly(WARNING); } - @Test - void testGetWarnings_DuplicateInGeneralOrderDocument() throws DocumentContentCheckerException { - when(caseDetails.getData()).thenReturn(caseData); - when(caseData.getAdditionalDocument()).thenReturn(additionalDocument); - when(additionalDocument.getDocumentFilename()).thenReturn("additionalDocumentFilename"); - when(generalOrderDocument.getDocumentFilename()).thenReturn("inputFilename"); - when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); - when(caseData.getGeneralOrderWrapper()).thenReturn(generalOrderWrapper); - - List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails); - - assertThat(warnings).hasSize(1).containsExactly(WARNING); - } +// @Test +// void testGetWarnings_DuplicateInGeneralOrderDocument() throws DocumentContentCheckerException { +// when(caseDetails.getData()).thenReturn(caseData); +// when(caseData.getAdditionalDocument()).thenReturn(additionalDocument); +// when(additionalDocument.getDocumentFilename()).thenReturn("additionalDocumentFilename"); +// when(generalOrderDocument.getDocumentFilename()).thenReturn("inputFilename"); +// when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); +// when(caseData.getGeneralOrderWrapper()).thenReturn(generalOrderWrapper); +// +// List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails, caseDetails); +// +// assertThat(warnings).hasSize(1).containsExactly(WARNING); +// } @Test void testGetWarnings_NoCaseData() throws DocumentContentCheckerException { List warnings = underTest.getWarnings(caseDocument, new byte[0], FinremCaseDetails.builder() + .data(FinremCaseData.builder().build()) + .build(), FinremCaseDetails.builder() .data(FinremCaseData.builder().build()) .build()); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java index 48c2034bf8..e53aa7e0fc 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java @@ -82,7 +82,7 @@ void testGetWarnings_withValidContent(int testCase) throws DocumentContentChecke when(caseNumberDocumentContentChecker.getWarning(eq(caseDetails), any(String[].class))) .thenReturn(testCase == 1 ? null : "Warning2"); - List warnings = underTest.getWarnings(caseDocument, documentBytes, caseDetails); + List warnings = underTest.getWarnings(caseDocument, documentBytes, caseDetails, caseDetails); assertThat(warnings).hasSize(testCase == 1 ? 1 : 2).contains("Warning1"); @@ -103,7 +103,7 @@ void testGetWarnings_whenGivenFileCannotBeRead() throws IOException { FinremCaseDetails caseDetails = new FinremCaseDetails(); byte[] documentBytes = "Invalid content".getBytes(); - assertThatThrownBy(() -> underTest.getWarnings(caseDocument, documentBytes, caseDetails)) + assertThatThrownBy(() -> underTest.getWarnings(caseDocument, documentBytes, caseDetails, caseDetails)) .isInstanceOf(DocumentContentCheckerException.class); } } From 368cd34001ea353cefad24852a5c00d5cdf68c54 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 27 Jun 2024 14:21:06 +0100 Subject: [PATCH 62/96] Introduced interface CaseDocumentsDiscovery --- .../model/ccd/CaseDocumentsDiscovery.java | 7 + .../model/ccd/OtherDocumentCollection.java | 14 +- .../model/ccd/PaymentDocumentCollection.java | 14 +- .../model/ccd/PensionTypeCollection.java | 14 +- .../ccd/wrapper/GeneralOrderWrapper.java | 25 +- .../DuplicateFilenameDocumentChecker.java | 524 ++++++++++-------- .../DuplicateFilenameDocumentCheckerTest.java | 195 ++++--- 7 files changed, 483 insertions(+), 310 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentsDiscovery.java diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentsDiscovery.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentsDiscovery.java new file mode 100644 index 0000000000..6105616048 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentsDiscovery.java @@ -0,0 +1,7 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd; + +import java.util.List; + +public interface CaseDocumentsDiscovery { + List discover(); +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OtherDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OtherDocumentCollection.java index 45326ab7fa..1138996db2 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OtherDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OtherDocumentCollection.java @@ -6,11 +6,23 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class OtherDocumentCollection { +public class OtherDocumentCollection implements CaseDocumentsDiscovery { private OtherDocument value; + + @Override + public List discover() { + return ofNullable(value) + .map(OtherDocument::getUploadedDocument) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocumentCollection.java index 275fa7d8fa..0a14c4dcee 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocumentCollection.java @@ -6,11 +6,23 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class PaymentDocumentCollection { +public class PaymentDocumentCollection implements CaseDocumentsDiscovery { private PaymentDocument value; + + @Override + public List discover() { + return ofNullable(value) + .map(PaymentDocument::getUploadedDocument) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PensionTypeCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PensionTypeCollection.java index cd204ecb07..29ec02d0d0 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PensionTypeCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PensionTypeCollection.java @@ -7,14 +7,26 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class PensionTypeCollection { +public class PensionTypeCollection implements CaseDocumentsDiscovery { @JsonProperty("id") private String id; @JsonProperty("value") private PensionType typedCaseDocument; + + @Override + public List discover() { + return ofNullable(typedCaseDocument) + .map(PensionType::getPensionDocument) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralOrderWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralOrderWrapper.java index b1891baf9b..a467614e6a 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralOrderWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralOrderWrapper.java @@ -10,13 +10,20 @@ import lombok.Data; import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrderCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrderAddressTo; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrderCollectionItem; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.JudgeType; import java.time.LocalDate; import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; + +import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -24,7 +31,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class GeneralOrderWrapper { +public class GeneralOrderWrapper implements CaseDocumentsDiscovery { private GeneralOrderAddressTo generalOrderAddressTo; @JsonSerialize(using = LocalDateSerializer.class) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") @@ -39,4 +46,20 @@ public class GeneralOrderWrapper { private List generalOrders; private List generalOrdersConsent; private List generalOrderCollection; + + @Override + public List discover() { + return Stream.of( + Stream.of(generalOrderLatestDocument, generalOrderPreviewDocument), + ofNullable(generalOrders).orElse(List.of()).stream() + .map(d -> ofNullable(d.getValue()).orElse(ContestedGeneralOrder.builder().build()).getAdditionalDocument()), + ofNullable(generalOrdersConsent).orElse(List.of()).stream() + .map(d -> ofNullable(d.getValue()).orElse(ContestedGeneralOrder.builder().build()).getAdditionalDocument()), + ofNullable(generalOrderCollection).orElse(List.of()).stream() + .map(d -> ofNullable(d.getGeneralOrder()).orElse(GeneralOrder.builder().build()).getGeneralOrderDocumentUpload()) + ) + .flatMap(s -> s) + .filter(Objects::nonNull) + .toList(); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index 0419936782..674024db30 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -3,37 +3,20 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanWrapperImpl; import org.springframework.stereotype.Component; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AdditionalHearingDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AmendedConsentOrder; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApprovedOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DirectionOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.IntervenerHearingNotice; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ManageScannedDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OrderRefusalHolder; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OtherDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.PaymentDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.PensionType; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.RefusalOrder; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.RespondToOrderDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ScannedDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.SendOrderDocuments; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.SolUploadDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadAdditionalDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadCaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConfidentialDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConsentOrderDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadOrder; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.function.Supplier; -import java.util.stream.Stream; import static java.util.Optional.ofNullable; @@ -48,251 +31,304 @@ public boolean canCheck(CaseDocument caseDocument) { return true; } - private boolean isDuplicateFilename(CaseDocument caseDocument, Supplier caseDocumentSupplier) { - return ofNullable(caseDocumentSupplier.get()).orElse(CaseDocument.builder().documentFilename("").build()) - .getDocumentFilename().equals(caseDocument.getDocumentFilename()); + private boolean isDuplicateFilename(CaseDocument caseDocument, Supplier> caseDocumentSupplier) { + return ofNullable(caseDocumentSupplier.get()).orElse(List.of(CaseDocument.builder().documentFilename("").build())) + .stream().anyMatch(d -> d.getDocumentFilename().equals(caseDocument.getDocumentFilename())); } private boolean isDuplicatedFilenameInFinremCaseData(CaseDocument caseDocument, FinremCaseData caseData) { return Arrays.stream(new BeanWrapperImpl(caseData.getClass()).getPropertyDescriptors()) - .filter(d -> CaseDocument.class.equals(d.getPropertyType())) + .filter(d -> CaseDocument.class.isAssignableFrom(d.getPropertyType())) .anyMatch(pd -> isDuplicateFilename(caseDocument, () -> { try { - return (CaseDocument) pd.getReadMethod().invoke(caseData); + return List.of((CaseDocument) pd.getReadMethod().invoke(caseData)); } catch (Exception e) { log.error("Fail to invoke:" + pd.getReadMethod().getName()); return null; } }) - ); + ) || Arrays.stream(new BeanWrapperImpl(caseData.getClass()).getPropertyDescriptors()) + .filter(d -> CaseDocumentsDiscovery.class.isAssignableFrom(d.getPropertyType())) + .anyMatch(pd -> + isDuplicateFilename(caseDocument, () -> { + try { + return ((CaseDocumentsDiscovery) pd.getReadMethod().invoke(caseData)).discover(); + } catch (Exception e) { + log.error("Fail to invoke:" + pd.getReadMethod().getName()); + return null; + } + }) + ); + } + + private static void processList(List list, List allDocuments) { + final String METHOD_NAME = "discover"; + if (list != null) { + for (Object item : list) { + try { + // Invoke the 'discover' method on each item in the list + Method discoverMethod = item.getClass().getMethod(METHOD_NAME); + @SuppressWarnings("unchecked") + List documents = (List) discoverMethod.invoke(item); + allDocuments.addAll(documents); + } catch (Exception e) { + log.error("Fail to invoke " + METHOD_NAME + "()", e); + } + } + } } @Override public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails) throws DocumentContentCheckerException { - final List duplicatedWarning = List.of(WARNING); FinremCaseData caseData = beforeCaseDetails.getData(); if (isDuplicatedFilenameInFinremCaseData(caseDocument, caseData)) { - return duplicatedWarning; + return List.of(WARNING); } - // pensionCollection, consentPensionCollection - if (Stream.of(ofNullable(caseData.getPensionCollection()).orElse(List.of()), - ofNullable(caseData.getConsentPensionCollection()).orElse(List.of())) - .flatMap(List::stream) - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getTypedCaseDocument()).orElse(PensionType.builder().build()) - .getPensionDocument()))) { - return duplicatedWarning; - } - // copyOfPaperFormA - if (ofNullable(caseData.getCopyOfPaperFormA()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(PaymentDocument.builder().build()) - .getUploadedDocument()))) { - return duplicatedWarning; - } - // otherDocumentsCollection - if (ofNullable(caseData.getOtherDocumentsCollection()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(OtherDocument.builder().build()) - .getUploadedDocument()))) { - return duplicatedWarning; - } - // additionalCicDocuments - if (ofNullable(caseData.getAdditionalCicDocuments()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { - return duplicatedWarning; - } - // orderRefusalCollection, orderRefusalCollectionNew - if (Stream.of(ofNullable(caseData.getOrderRefusalCollection()).orElse(List.of()), - ofNullable(caseData.getOrderRefusalCollectionNew()).orElse(List.of())) - .flatMap(List::stream) - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(OrderRefusalHolder.builder().build()) - .getOrderRefusalDocs()))) { - return duplicatedWarning; - } - // uploadConsentOrderDocuments - if (ofNullable(caseData.getUploadConsentOrderDocuments()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadConsentOrderDocument.builder().build()) - .getDocumentLink()))) { - return duplicatedWarning; - } - // uploadOrder - if (ofNullable(caseData.getUploadOrder()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadOrder.builder().build()) - .getDocumentLink()))) { - return duplicatedWarning; - } - // uploadDocuments - if (ofNullable(caseData.getUploadDocuments()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadDocument.builder().build()) - .getDocumentLink()))) { - return duplicatedWarning; - } - // solUploadDocuments - if (ofNullable(caseData.getSolUploadDocuments()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(SolUploadDocument.builder().build()) - .getDocumentLink()))) { - return duplicatedWarning; - } - // respondToOrderDocuments - if (ofNullable(caseData.getRespondToOrderDocuments()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(RespondToOrderDocument.builder().build()) - .getDocumentLink()))) { - return duplicatedWarning; - } - // amendedConsentOrderCollection - if (ofNullable(caseData.getAmendedConsentOrderCollection()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(AmendedConsentOrder.builder().build()) - .getAmendedConsentOrder()))) { - return duplicatedWarning; - } - // scannedDocuments - if (ofNullable(caseData.getScannedDocuments()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(ScannedDocument.builder().build()) - .getUrl()))) { - return duplicatedWarning; - } - // approvedOrderCollection - if (ofNullable(caseData.getApprovedOrderCollection()).orElse(List.of()) - .stream() - .anyMatch(d -> - isDuplicateFilename(caseDocument, () -> ofNullable(d.getApprovedOrder()).orElse(ApprovedOrder.builder().build()) - .getConsentOrder()) - || isDuplicateFilename(caseDocument, () -> ofNullable(d.getApprovedOrder()).orElse(ApprovedOrder.builder().build()) - .getOrderLetter()) - || ofNullable(ofNullable(d.getApprovedOrder()).orElse(ApprovedOrder.builder().build()).getPensionDocuments()).orElse(List.of()) - .stream() - .anyMatch(e -> isDuplicateFilename(caseDocument, () -> ofNullable(e.getTypedCaseDocument()).orElse(PensionType.builder().build()) - .getPensionDocument())) - ) - ) { - return duplicatedWarning; - } - // scannedD81s - if (ofNullable(caseData.getScannedD81s()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { - return duplicatedWarning; - } - // additionalHearingDocuments - if (ofNullable(caseData.getAdditionalHearingDocuments()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(AdditionalHearingDocument.builder().build()) - .getDocument()))) { - return duplicatedWarning; - } - // hearingNoticeDocumentPack - if (ofNullable(caseData.getHearingNoticeDocumentPack()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { - return duplicatedWarning; - } - // hearingNoticesDocumentCollection - if (ofNullable(caseData.getHearingNoticesDocumentCollection()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { - return duplicatedWarning; - } - // uploadGeneralDocuments - if (ofNullable(caseData.getUploadGeneralDocuments()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadGeneralDocument.builder().build()) - .getDocumentLink()))) { - return duplicatedWarning; - } - // uploadHearingOrder - if (ofNullable(caseData.getUploadHearingOrder()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(DirectionOrder.builder().build()) - .getUploadDraftDocument()))) { - return duplicatedWarning; - } - // hearingOrderOtherDocuments - if (ofNullable(caseData.getHearingOrderOtherDocuments()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { - return duplicatedWarning; - } - // finalOrderCollection - if (ofNullable(caseData.getFinalOrderCollection()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(DirectionOrder.builder().build()) - .getUploadDraftDocument()))) { - return duplicatedWarning; - } - // intv1HearingNoticesCollection, intv2HearingNoticesCollection, intv3HearingNoticesCollection, intv4HearingNoticesCollection - if (Stream.of(ofNullable(caseData.getIntv1HearingNoticesCollection()).orElse(List.of()), - ofNullable(caseData.getIntv2HearingNoticesCollection()).orElse(List.of()), - ofNullable(caseData.getIntv3HearingNoticesCollection()).orElse(List.of()), - ofNullable(caseData.getIntv4HearingNoticesCollection()).orElse(List.of())) - .flatMap(List::stream) - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(IntervenerHearingNotice.builder().build()) - .getCaseDocument()))) { - return duplicatedWarning; - } - // refusalOrderCollection - if (ofNullable(caseData.getRefusalOrderCollection()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(RefusalOrder.builder().build()) - .getRefusalOrderAdditionalDocument()))) { - return duplicatedWarning; - } - // uploadAdditionalDocument - if (ofNullable(caseData.getUploadAdditionalDocument()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadAdditionalDocument.builder().build()) - .getAdditionalDocuments()))) { - return duplicatedWarning; - } - // confidentialDocumentsUploaded - if (ofNullable(caseData.getConfidentialDocumentsUploaded()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadConfidentialDocument.builder().build()) - .getDocumentLink()))) { - return duplicatedWarning; - } - // manageCaseDocumentCollection - if (ofNullable(caseData.getManageCaseDocumentCollection()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getUploadCaseDocument()).orElse(UploadCaseDocument.builder().build()) - .getCaseDocuments()))) { - return duplicatedWarning; - } - // applicantScanDocuments, respondentScanDocuments - if (Stream.of(ofNullable(caseData.getApplicantScanDocuments()).orElse(List.of()), - ofNullable(caseData.getRespondentScanDocuments()).orElse(List.of())) - .flatMap(List::stream) - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(ScannedDocument.builder().build()) - .getUrl()))) { - return duplicatedWarning; - } - // manageScannedDocumentCollection - if (ofNullable(caseData.getManageScannedDocumentCollection()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getManageScannedDocument()).orElse(ManageScannedDocument.builder() - .uploadCaseDocument(UploadCaseDocument.builder().build()) - .build()).getUploadCaseDocument().getCaseDocuments()))) { - return duplicatedWarning; - } - // ordersSentToPartiesCollection - if (ofNullable(caseData.getOrdersSentToPartiesCollection()).orElse(List.of()) - .stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(SendOrderDocuments.builder().build()) - .getCaseDocument()))) { - return duplicatedWarning; + try { + // Collect all fields from FinremCaseData class + Field[] fields = FinremCaseData.class.getDeclaredFields(); + + // List to collect all CaseDocument instances + List allDocuments = new ArrayList<>(); + + for (Field field : fields) { + field.setAccessible(true); + + // Check if the field is a List with a parameterized type + if (List.class.isAssignableFrom(field.getType())) { + ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType(); + Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); + + // Ensure the list has a single parameterized type argument + if (actualTypeArguments.length == 1 && + CaseDocumentsDiscovery.class.isAssignableFrom((Class) actualTypeArguments[0])) { + + // Get the value of the field and process the list + List list = (List) field.get(caseData); + processList(list, allDocuments); + } + } + } + + log.info("Iterating all CaseDocuments with interface CaseDocumentsDiscovery."); + + // Check for duplicate filenames in the collected documents + boolean hasDuplicates = allDocuments.stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d))); + + if (hasDuplicates) { + return List.of(WARNING); + } + } catch (Exception e) { + log.error("Failed to check for duplicate filenames and return warnings", e); } + + +// // otherDocumentsCollection +// if (ofNullable(caseData.getOtherDocumentsCollection()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(OtherDocument.builder().build()) +// .getUploadedDocument()))) { +// return duplicatedWarning; +// } +// // additionalCicDocuments +// if (ofNullable(caseData.getAdditionalCicDocuments()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { +// return duplicatedWarning; +// } +// // orderRefusalCollection, orderRefusalCollectionNew +// if (Stream.of(ofNullable(caseData.getOrderRefusalCollection()).orElse(List.of()), +// ofNullable(caseData.getOrderRefusalCollectionNew()).orElse(List.of())) +// .flatMap(List::stream) +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(OrderRefusalHolder.builder().build()) +// .getOrderRefusalDocs()))) { +// return duplicatedWarning; +// } +// // uploadConsentOrderDocuments +// if (ofNullable(caseData.getUploadConsentOrderDocuments()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadConsentOrderDocument.builder().build()) +// .getDocumentLink()))) { +// return duplicatedWarning; +// } +// // uploadOrder +// if (ofNullable(caseData.getUploadOrder()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadOrder.builder().build()) +// .getDocumentLink()))) { +// return duplicatedWarning; +// } +// // uploadDocuments +// if (ofNullable(caseData.getUploadDocuments()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadDocument.builder().build()) +// .getDocumentLink()))) { +// return duplicatedWarning; +// } +// // solUploadDocuments +// if (ofNullable(caseData.getSolUploadDocuments()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(SolUploadDocument.builder().build()) +// .getDocumentLink()))) { +// return duplicatedWarning; +// } +// // respondToOrderDocuments +// if (ofNullable(caseData.getRespondToOrderDocuments()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(RespondToOrderDocument.builder().build()) +// .getDocumentLink()))) { +// return duplicatedWarning; +// } +// // amendedConsentOrderCollection +// if (ofNullable(caseData.getAmendedConsentOrderCollection()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(AmendedConsentOrder.builder().build()) +// .getAmendedConsentOrder()))) { +// return duplicatedWarning; +// } +// // scannedDocuments +// if (ofNullable(caseData.getScannedDocuments()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(ScannedDocument.builder().build()) +// .getUrl()))) { +// return duplicatedWarning; +// } +// // approvedOrderCollection +// if (ofNullable(caseData.getApprovedOrderCollection()).orElse(List.of()) +// .stream() +// .anyMatch(d -> +// isDuplicateFilename(caseDocument, () -> ofNullable(d.getApprovedOrder()).orElse(ApprovedOrder.builder().build()) +// .getConsentOrder()) +// || isDuplicateFilename(caseDocument, () -> ofNullable(d.getApprovedOrder()).orElse(ApprovedOrder.builder().build()) +// .getOrderLetter()) +// || ofNullable(ofNullable(d.getApprovedOrder()).orElse(ApprovedOrder.builder().build()).getPensionDocuments()).orElse(List.of()) +// .stream() +// .anyMatch(e -> isDuplicateFilename(caseDocument, () -> ofNullable(e.getTypedCaseDocument()).orElse(PensionType.builder().build()) +// .getPensionDocument())) +// ) +// ) { +// return duplicatedWarning; +// } +// // scannedD81s +// if (ofNullable(caseData.getScannedD81s()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { +// return duplicatedWarning; +// } +// // additionalHearingDocuments +// if (ofNullable(caseData.getAdditionalHearingDocuments()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(AdditionalHearingDocument.builder().build()) +// .getDocument()))) { +// return duplicatedWarning; +// } +// // hearingNoticeDocumentPack +// if (ofNullable(caseData.getHearingNoticeDocumentPack()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { +// return duplicatedWarning; +// } +// // hearingNoticesDocumentCollection +// if (ofNullable(caseData.getHearingNoticesDocumentCollection()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { +// return duplicatedWarning; +// } +// // uploadGeneralDocuments +// if (ofNullable(caseData.getUploadGeneralDocuments()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadGeneralDocument.builder().build()) +// .getDocumentLink()))) { +// return duplicatedWarning; +// } +// // uploadHearingOrder +// if (ofNullable(caseData.getUploadHearingOrder()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(DirectionOrder.builder().build()) +// .getUploadDraftDocument()))) { +// return duplicatedWarning; +// } +// // hearingOrderOtherDocuments +// if (ofNullable(caseData.getHearingOrderOtherDocuments()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { +// return duplicatedWarning; +// } +// // finalOrderCollection +// if (ofNullable(caseData.getFinalOrderCollection()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(DirectionOrder.builder().build()) +// .getUploadDraftDocument()))) { +// return duplicatedWarning; +// } +// // intv1HearingNoticesCollection, intv2HearingNoticesCollection, intv3HearingNoticesCollection, intv4HearingNoticesCollection +// if (Stream.of(ofNullable(caseData.getIntv1HearingNoticesCollection()).orElse(List.of()), +// ofNullable(caseData.getIntv2HearingNoticesCollection()).orElse(List.of()), +// ofNullable(caseData.getIntv3HearingNoticesCollection()).orElse(List.of()), +// ofNullable(caseData.getIntv4HearingNoticesCollection()).orElse(List.of())) +// .flatMap(List::stream) +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(IntervenerHearingNotice.builder().build()) +// .getCaseDocument()))) { +// return duplicatedWarning; +// } +// // refusalOrderCollection +// if (ofNullable(caseData.getRefusalOrderCollection()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(RefusalOrder.builder().build()) +// .getRefusalOrderAdditionalDocument()))) { +// return duplicatedWarning; +// } +// // uploadAdditionalDocument +// if (ofNullable(caseData.getUploadAdditionalDocument()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadAdditionalDocument.builder().build()) +// .getAdditionalDocuments()))) { +// return duplicatedWarning; +// } +// // confidentialDocumentsUploaded +// if (ofNullable(caseData.getConfidentialDocumentsUploaded()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadConfidentialDocument.builder().build()) +// .getDocumentLink()))) { +// return duplicatedWarning; +// } +// // manageCaseDocumentCollection +// if (ofNullable(caseData.getManageCaseDocumentCollection()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getUploadCaseDocument()).orElse(UploadCaseDocument.builder().build()) +// .getCaseDocuments()))) { +// return duplicatedWarning; +// } +// // applicantScanDocuments, respondentScanDocuments +// if (Stream.of(ofNullable(caseData.getApplicantScanDocuments()).orElse(List.of()), +// ofNullable(caseData.getRespondentScanDocuments()).orElse(List.of())) +// .flatMap(List::stream) +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(ScannedDocument.builder().build()) +// .getUrl()))) { +// return duplicatedWarning; +// } +// // manageScannedDocumentCollection +// if (ofNullable(caseData.getManageScannedDocumentCollection()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getManageScannedDocument()).orElse(ManageScannedDocument.builder() +// .uploadCaseDocument(UploadCaseDocument.builder().build()) +// .build()).getUploadCaseDocument().getCaseDocuments()))) { +// return duplicatedWarning; +// } +// // ordersSentToPartiesCollection +// if (ofNullable(caseData.getOrdersSentToPartiesCollection()).orElse(List.of()) +// .stream() +// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(SendOrderDocuments.builder().build()) +// .getCaseDocument()))) { +// return duplicatedWarning; +// } + return Collections.emptyList(); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index e175526e57..c49c445014 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -4,19 +4,25 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; -import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrderCollectionItem; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OtherDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OtherDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.PensionType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.PensionTypeCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralOrderWrapper; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) @MockitoSettings(strictness = Strictness.LENIENT) @@ -24,97 +30,162 @@ class DuplicateFilenameDocumentCheckerTest { private static final String WARNING = "A document with this filename already exists on the case"; - @Mock - private CaseDocument caseDocument; - @Mock - private FinremCaseDetails caseDetails; - @Mock - private FinremCaseData caseData; - @Mock - private CaseDocument additionalDocument; - @Mock - private GeneralOrderWrapper generalOrderWrapper; - @Mock - private CaseDocument generalOrderDocument; + private static final String DUPLICATED_FILENAME = "newFilename.pdf"; + + private static final CaseDocument DUPLICATED_CASE_DOCUMENT = CaseDocument.builder().documentFilename(DUPLICATED_FILENAME).build(); @InjectMocks private DuplicateFilenameDocumentChecker underTest; + private static void assertDuplicateFilenameWarning(List warnings) { + assertThat(warnings).hasSize(1).containsExactly(WARNING); + } + @BeforeEach public void setUp() { underTest = new DuplicateFilenameDocumentChecker(); - when(caseDocument.getDocumentFilename()).thenReturn("inputFilename"); } @Test void testCanCheck_alwaysReturnsTrue() { assertThat(underTest.canCheck(new CaseDocument())).isTrue(); assertThat(underTest.canCheck(null)).isTrue(); - assertThat(underTest.canCheck(caseDocument)).isTrue(); + assertThat(underTest.canCheck(DUPLICATED_CASE_DOCUMENT)).isTrue(); } @Test void testGetWarnings_NoDuplicate() throws DocumentContentCheckerException { - when(caseDetails.getData()).thenReturn(caseData); - when(caseData.getAdditionalDocument()).thenReturn(additionalDocument); - when(caseData.getGeneralOrderWrapper()).thenReturn(generalOrderWrapper); - when(generalOrderDocument.getDocumentFilename()).thenReturn("generalOrderDocumentFilename"); - - when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); - when(additionalDocument.getDocumentFilename()).thenReturn("additionalDocumentFilename"); - - List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails, caseDetails); + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .additionalDocument(CaseDocument.builder().documentFilename("additionalDocument").build()) + .generalOrderWrapper(GeneralOrderWrapper.builder() + .generalOrderLatestDocument(CaseDocument.builder().documentFilename("generalOrderLatestDocument").build()) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); assertThat(warnings).isEmpty(); } @Test - void testGetWarnings_NoDuplicateWhenAdditionalDocumentIsNull() throws DocumentContentCheckerException { - when(caseDetails.getData()).thenReturn(caseData); - when(caseData.getAdditionalDocument()).thenReturn(null); - when(caseData.getGeneralOrderWrapper()).thenReturn(generalOrderWrapper); - when(generalOrderDocument.getDocumentFilename()).thenReturn("generalOrderDocumentFilename"); - - when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); - - List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails, caseDetails); - - assertThat(warnings).isEmpty(); + void testGetWarnings_duplicateInGeneralOrderWrapper_generalOrderLatestDocument() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalOrderWrapper(GeneralOrderWrapper.builder() + .generalOrderLatestDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + assertDuplicateFilenameWarning(warnings); } @Test - void testGetWarnings_DuplicateInAdditionalDocument() throws DocumentContentCheckerException { - when(caseDetails.getData()).thenReturn(caseData); - when(caseData.getAdditionalDocument()).thenReturn(additionalDocument); - when(additionalDocument.getDocumentFilename()).thenReturn("inputFilename"); + void testGetWarnings_duplicateInGeneralOrderWrapper_generalOrderPreviewDocument() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalOrderWrapper(GeneralOrderWrapper.builder() + .generalOrderPreviewDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } - List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails, caseDetails); + @Test + void testGetWarnings_duplicateInGeneralOrderWrapper_generalOrders() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalOrderWrapper(GeneralOrderWrapper.builder() + .generalOrders(List.of(ContestedGeneralOrderCollection.builder() + .value(ContestedGeneralOrder.builder() + .additionalDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } - assertThat(warnings).hasSize(1).containsExactly(WARNING); + @Test + void testGetWarnings_duplicateInGeneralOrderWrapper_generalOrdersConsent() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalOrderWrapper(GeneralOrderWrapper.builder() + .generalOrdersConsent(List.of(ContestedGeneralOrderCollection.builder() + .value(ContestedGeneralOrder.builder() + .additionalDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); } -// @Test -// void testGetWarnings_DuplicateInGeneralOrderDocument() throws DocumentContentCheckerException { -// when(caseDetails.getData()).thenReturn(caseData); -// when(caseData.getAdditionalDocument()).thenReturn(additionalDocument); -// when(additionalDocument.getDocumentFilename()).thenReturn("additionalDocumentFilename"); -// when(generalOrderDocument.getDocumentFilename()).thenReturn("inputFilename"); -// when(generalOrderWrapper.getGeneralOrderLatestDocument()).thenReturn(generalOrderDocument); -// when(caseData.getGeneralOrderWrapper()).thenReturn(generalOrderWrapper); -// -// List warnings = underTest.getWarnings(caseDocument, new byte[0], caseDetails, caseDetails); -// -// assertThat(warnings).hasSize(1).containsExactly(WARNING); -// } + @Test + void testGetWarnings_duplicateInGeneralOrderWrapper_generalOrderCollection() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalOrderWrapper(GeneralOrderWrapper.builder() + .generalOrderCollection(List.of(GeneralOrderCollectionItem.builder() + .generalOrder(GeneralOrder.builder() + .generalOrderDocumentUpload(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } @Test - void testGetWarnings_NoCaseData() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(caseDocument, new byte[0], FinremCaseDetails.builder() - .data(FinremCaseData.builder().build()) - .build(), FinremCaseDetails.builder() - .data(FinremCaseData.builder().build()) - .build()); + void testGetWarnings_duplicateInPensionCollection() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .pensionCollection(List.of(PensionTypeCollection.builder() + .typedCaseDocument(PensionType.builder() + .pensionDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } - assertThat(warnings).isEmpty(); + @Test + void testGetWarnings_duplicateInOtherDocumentsCollection() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .otherDocumentsCollection(List.of(OtherDocumentCollection.builder() + .value(OtherDocument.builder() + .uploadedDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); } } From e7b28cf609994980e92437209d9660698b8a392a Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 27 Jun 2024 14:26:45 +0100 Subject: [PATCH 63/96] Remove commented codes --- .../DuplicateFilenameDocumentChecker.java | 202 ------------------ 1 file changed, 202 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index 674024db30..a6b5f458c8 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -127,208 +127,6 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC log.error("Failed to check for duplicate filenames and return warnings", e); } - - -// // otherDocumentsCollection -// if (ofNullable(caseData.getOtherDocumentsCollection()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(OtherDocument.builder().build()) -// .getUploadedDocument()))) { -// return duplicatedWarning; -// } -// // additionalCicDocuments -// if (ofNullable(caseData.getAdditionalCicDocuments()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { -// return duplicatedWarning; -// } -// // orderRefusalCollection, orderRefusalCollectionNew -// if (Stream.of(ofNullable(caseData.getOrderRefusalCollection()).orElse(List.of()), -// ofNullable(caseData.getOrderRefusalCollectionNew()).orElse(List.of())) -// .flatMap(List::stream) -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(OrderRefusalHolder.builder().build()) -// .getOrderRefusalDocs()))) { -// return duplicatedWarning; -// } -// // uploadConsentOrderDocuments -// if (ofNullable(caseData.getUploadConsentOrderDocuments()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadConsentOrderDocument.builder().build()) -// .getDocumentLink()))) { -// return duplicatedWarning; -// } -// // uploadOrder -// if (ofNullable(caseData.getUploadOrder()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadOrder.builder().build()) -// .getDocumentLink()))) { -// return duplicatedWarning; -// } -// // uploadDocuments -// if (ofNullable(caseData.getUploadDocuments()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadDocument.builder().build()) -// .getDocumentLink()))) { -// return duplicatedWarning; -// } -// // solUploadDocuments -// if (ofNullable(caseData.getSolUploadDocuments()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(SolUploadDocument.builder().build()) -// .getDocumentLink()))) { -// return duplicatedWarning; -// } -// // respondToOrderDocuments -// if (ofNullable(caseData.getRespondToOrderDocuments()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(RespondToOrderDocument.builder().build()) -// .getDocumentLink()))) { -// return duplicatedWarning; -// } -// // amendedConsentOrderCollection -// if (ofNullable(caseData.getAmendedConsentOrderCollection()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(AmendedConsentOrder.builder().build()) -// .getAmendedConsentOrder()))) { -// return duplicatedWarning; -// } -// // scannedDocuments -// if (ofNullable(caseData.getScannedDocuments()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(ScannedDocument.builder().build()) -// .getUrl()))) { -// return duplicatedWarning; -// } -// // approvedOrderCollection -// if (ofNullable(caseData.getApprovedOrderCollection()).orElse(List.of()) -// .stream() -// .anyMatch(d -> -// isDuplicateFilename(caseDocument, () -> ofNullable(d.getApprovedOrder()).orElse(ApprovedOrder.builder().build()) -// .getConsentOrder()) -// || isDuplicateFilename(caseDocument, () -> ofNullable(d.getApprovedOrder()).orElse(ApprovedOrder.builder().build()) -// .getOrderLetter()) -// || ofNullable(ofNullable(d.getApprovedOrder()).orElse(ApprovedOrder.builder().build()).getPensionDocuments()).orElse(List.of()) -// .stream() -// .anyMatch(e -> isDuplicateFilename(caseDocument, () -> ofNullable(e.getTypedCaseDocument()).orElse(PensionType.builder().build()) -// .getPensionDocument())) -// ) -// ) { -// return duplicatedWarning; -// } -// // scannedD81s -// if (ofNullable(caseData.getScannedD81s()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { -// return duplicatedWarning; -// } -// // additionalHearingDocuments -// if (ofNullable(caseData.getAdditionalHearingDocuments()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(AdditionalHearingDocument.builder().build()) -// .getDocument()))) { -// return duplicatedWarning; -// } -// // hearingNoticeDocumentPack -// if (ofNullable(caseData.getHearingNoticeDocumentPack()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { -// return duplicatedWarning; -// } -// // hearingNoticesDocumentCollection -// if (ofNullable(caseData.getHearingNoticesDocumentCollection()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { -// return duplicatedWarning; -// } -// // uploadGeneralDocuments -// if (ofNullable(caseData.getUploadGeneralDocuments()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadGeneralDocument.builder().build()) -// .getDocumentLink()))) { -// return duplicatedWarning; -// } -// // uploadHearingOrder -// if (ofNullable(caseData.getUploadHearingOrder()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(DirectionOrder.builder().build()) -// .getUploadDraftDocument()))) { -// return duplicatedWarning; -// } -// // hearingOrderOtherDocuments -// if (ofNullable(caseData.getHearingOrderOtherDocuments()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(CaseDocument.builder().build())))) { -// return duplicatedWarning; -// } -// // finalOrderCollection -// if (ofNullable(caseData.getFinalOrderCollection()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(DirectionOrder.builder().build()) -// .getUploadDraftDocument()))) { -// return duplicatedWarning; -// } -// // intv1HearingNoticesCollection, intv2HearingNoticesCollection, intv3HearingNoticesCollection, intv4HearingNoticesCollection -// if (Stream.of(ofNullable(caseData.getIntv1HearingNoticesCollection()).orElse(List.of()), -// ofNullable(caseData.getIntv2HearingNoticesCollection()).orElse(List.of()), -// ofNullable(caseData.getIntv3HearingNoticesCollection()).orElse(List.of()), -// ofNullable(caseData.getIntv4HearingNoticesCollection()).orElse(List.of())) -// .flatMap(List::stream) -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(IntervenerHearingNotice.builder().build()) -// .getCaseDocument()))) { -// return duplicatedWarning; -// } -// // refusalOrderCollection -// if (ofNullable(caseData.getRefusalOrderCollection()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(RefusalOrder.builder().build()) -// .getRefusalOrderAdditionalDocument()))) { -// return duplicatedWarning; -// } -// // uploadAdditionalDocument -// if (ofNullable(caseData.getUploadAdditionalDocument()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadAdditionalDocument.builder().build()) -// .getAdditionalDocuments()))) { -// return duplicatedWarning; -// } -// // confidentialDocumentsUploaded -// if (ofNullable(caseData.getConfidentialDocumentsUploaded()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(UploadConfidentialDocument.builder().build()) -// .getDocumentLink()))) { -// return duplicatedWarning; -// } -// // manageCaseDocumentCollection -// if (ofNullable(caseData.getManageCaseDocumentCollection()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getUploadCaseDocument()).orElse(UploadCaseDocument.builder().build()) -// .getCaseDocuments()))) { -// return duplicatedWarning; -// } -// // applicantScanDocuments, respondentScanDocuments -// if (Stream.of(ofNullable(caseData.getApplicantScanDocuments()).orElse(List.of()), -// ofNullable(caseData.getRespondentScanDocuments()).orElse(List.of())) -// .flatMap(List::stream) -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(ScannedDocument.builder().build()) -// .getUrl()))) { -// return duplicatedWarning; -// } -// // manageScannedDocumentCollection -// if (ofNullable(caseData.getManageScannedDocumentCollection()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getManageScannedDocument()).orElse(ManageScannedDocument.builder() -// .uploadCaseDocument(UploadCaseDocument.builder().build()) -// .build()).getUploadCaseDocument().getCaseDocuments()))) { -// return duplicatedWarning; -// } -// // ordersSentToPartiesCollection -// if (ofNullable(caseData.getOrdersSentToPartiesCollection()).orElse(List.of()) -// .stream() -// .anyMatch(d -> isDuplicateFilename(caseDocument, () -> ofNullable(d.getValue()).orElse(SendOrderDocuments.builder().build()) -// .getCaseDocument()))) { -// return duplicatedWarning; -// } - return Collections.emptyList(); } } From ecc084cfa4d047b2c15678ecf0d002883425caae Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 27 Jun 2024 14:58:22 +0100 Subject: [PATCH 64/96] checkstyle fix --- .../DuplicateFilenameDocumentChecker.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index a6b5f458c8..bbea103093 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -63,17 +63,17 @@ private boolean isDuplicatedFilenameInFinremCaseData(CaseDocument caseDocument, } private static void processList(List list, List allDocuments) { - final String METHOD_NAME = "discover"; + String methodName = "discover"; if (list != null) { for (Object item : list) { try { // Invoke the 'discover' method on each item in the list - Method discoverMethod = item.getClass().getMethod(METHOD_NAME); + Method discoverMethod = item.getClass().getMethod(methodName); @SuppressWarnings("unchecked") List documents = (List) discoverMethod.invoke(item); allDocuments.addAll(documents); } catch (Exception e) { - log.error("Fail to invoke " + METHOD_NAME + "()", e); + log.error("Fail to invoke " + methodName + "()", e); } } } @@ -104,8 +104,7 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); // Ensure the list has a single parameterized type argument - if (actualTypeArguments.length == 1 && - CaseDocumentsDiscovery.class.isAssignableFrom((Class) actualTypeArguments[0])) { + if (actualTypeArguments.length == 1 && CaseDocumentsDiscovery.class.isAssignableFrom((Class) actualTypeArguments[0])) { // Get the value of the field and process the list List list = (List) field.get(caseData); From b1a212c4ea0d7be3cc7ad890369f0ed9bb5f0087 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 27 Jun 2024 15:34:31 +0100 Subject: [PATCH 65/96] Implementing CaseDocumentsDiscovery (continue) --- .../model/ccd/DocumentCollection.java | 13 ++- .../model/ccd/OrderRefusalCollection.java | 14 ++- .../model/ccd/OrderRefusalHolder.java | 11 ++- .../UploadConsentOrderDocumentCollection.java | 14 ++- .../DuplicateFilenameDocumentCheckerTest.java | 86 +++++++++++++++++++ 5 files changed, 134 insertions(+), 4 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DocumentCollection.java index 646e59a00c..83f86dcef0 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DocumentCollection.java @@ -6,11 +6,22 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class DocumentCollection { +public class DocumentCollection implements CaseDocumentsDiscovery { private CaseDocument value; + + @Override + public List discover() { + return ofNullable(value) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalCollection.java index fa8cd1095f..141d52f979 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalCollection.java @@ -6,11 +6,23 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class OrderRefusalCollection { +public class OrderRefusalCollection implements CaseDocumentsDiscovery { private OrderRefusalHolder value; + + @Override + public List discover() { + return ofNullable(value) + .map(OrderRefusalHolder::getOrderRefusalDocs) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalHolder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalHolder.java index ac88a21f38..f60c71b0df 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalHolder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalHolder.java @@ -14,13 +14,15 @@ import java.time.LocalDate; import java.util.List; +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class OrderRefusalHolder { +public class OrderRefusalHolder implements CaseDocumentsDiscovery { private String orderRefusalAfterText; private List orderRefusal; private String orderRefusalOther; @@ -32,4 +34,11 @@ public class OrderRefusalHolder { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") private LocalDate orderRefusalDate; private String orderRefusalAddComments; + + @Override + public List discover() { + return ofNullable(orderRefusalDocs) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderDocumentCollection.java index d0a7358052..27a48e7be1 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderDocumentCollection.java @@ -6,11 +6,23 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadConsentOrderDocumentCollection { +public class UploadConsentOrderDocumentCollection implements CaseDocumentsDiscovery { private UploadConsentOrderDocument value; + + @Override + public List discover() { + return ofNullable(value) + .map(UploadConsentOrderDocument::getDocumentLink) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index c49c445014..a9508c02e7 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -10,14 +10,19 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrderCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrderCollectionItem; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OrderRefusalCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OrderRefusalHolder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OtherDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OtherDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.PensionType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.PensionTypeCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConsentOrderDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConsentOrderDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralOrderWrapper; import java.util.List; @@ -188,4 +193,85 @@ void testGetWarnings_duplicateInOtherDocumentsCollection() throws DocumentConten assertDuplicateFilenameWarning(warnings); } + + @Test + void testGetWarnings_duplicateInAdditionalCicDocuments() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .additionalCicDocuments(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInOrderRefusalCollection() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .orderRefusalCollection(List.of(OrderRefusalCollection.builder() + .value(OrderRefusalHolder.builder() + .orderRefusalDocs(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInOrderRefusalCollectionNew() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .orderRefusalCollectionNew(List.of(OrderRefusalCollection.builder() + .value(OrderRefusalHolder.builder() + .orderRefusalDocs(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInOrderRefusalOnScreen() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .orderRefusalOnScreen(OrderRefusalHolder.builder() + .orderRefusalDocs(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInUploadConsentOrderDocuments() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .uploadConsentOrderDocuments(List.of(UploadConsentOrderDocumentCollection.builder() + .value(UploadConsentOrderDocument.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } } From 6c88e19a438f77698f991bec0bca5e9f32ef2701 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 27 Jun 2024 18:53:21 +0100 Subject: [PATCH 66/96] Implementing CaseDocumentsDiscovery (continue) --- .../AdditionalHearingDocumentCollection.java | 14 +- .../ccd/AmendedConsentOrderCollection.java | 14 +- .../ccd/ConfidentialUploadedDocumentData.java | 13 +- .../model/ccd/ConsentOrderCollection.java | 32 +- .../model/ccd/DirectionOrderCollection.java | 14 +- .../ccd/DraftDirectionOrderCollection.java | 14 +- .../IntervenerHearingNoticeCollection.java | 14 +- .../model/ccd/RefusalOrderCollection.java | 14 +- .../ccd/RespondToOrderDocumentCollection.java | 14 +- .../model/ccd/ScannedDocumentCollection.java | 14 +- .../UploadAdditionalDocumentCollection.java | 14 +- .../ccd/UploadCaseDocumentCollection.java | 13 +- .../model/ccd/UploadDocumentCollection.java | 14 +- .../ccd/UploadGeneralDocumentCollection.java | 14 +- .../model/ccd/UploadOrderCollection.java | 14 +- .../ccd/wrapper/DraftDirectionWrapper.java | 26 +- .../wrapper/GeneralApplicationWrapper.java | 49 +- .../GeneralApplicationsCollection.java | 28 +- .../model/ccd/wrapper/InterimWrapper.java | 20 +- .../wrapper/UploadCaseDocumentWrapper.java | 43 +- .../DuplicateFilenameDocumentCheckerTest.java | 719 +++++++++++++++++- 21 files changed, 1088 insertions(+), 23 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocumentCollection.java index dec9a4aa89..65b4d3fa34 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocumentCollection.java @@ -6,11 +6,23 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class AdditionalHearingDocumentCollection { +public class AdditionalHearingDocumentCollection implements CaseDocumentsDiscovery { private AdditionalHearingDocument value; + + @Override + public List discover() { + return ofNullable(value) + .map(AdditionalHearingDocument::getDocument) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AmendedConsentOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AmendedConsentOrderCollection.java index 3314d7dfbf..ea3c2a46a5 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AmendedConsentOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AmendedConsentOrderCollection.java @@ -6,11 +6,23 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class AmendedConsentOrderCollection { +public class AmendedConsentOrderCollection implements CaseDocumentsDiscovery { private AmendedConsentOrder value; + + @Override + public List discover() { + return ofNullable(value) + .map(AmendedConsentOrder::getAmendedConsentOrder) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConfidentialUploadedDocumentData.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConfidentialUploadedDocumentData.java index b2cddb1baf..3c1678533b 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConfidentialUploadedDocumentData.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConfidentialUploadedDocumentData.java @@ -9,6 +9,9 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.CaseDocumentTabData; import java.time.LocalDateTime; +import java.util.List; + +import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -16,7 +19,7 @@ @AllArgsConstructor @NoArgsConstructor @Deprecated -public class ConfidentialUploadedDocumentData implements CaseDocumentTabData { +public class ConfidentialUploadedDocumentData implements CaseDocumentTabData, CaseDocumentsDiscovery { private String id; private UploadConfidentialDocument value; @@ -33,4 +36,12 @@ public void setUploadDateTime(LocalDateTime date) { value.setConfidentialDocumentUploadDateTime(date); } } + + @Override + public List discover() { + return ofNullable(value) + .map(UploadConfidentialDocument::getDocumentLink) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentOrderCollection.java index 5a5366d9c1..c67d29255a 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentOrderCollection.java @@ -7,14 +7,44 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; +import java.util.stream.Stream; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class ConsentOrderCollection { +public class ConsentOrderCollection implements CaseDocumentsDiscovery { @JsonProperty("id") private String id; @JsonProperty("value") private ApprovedOrder approvedOrder; + + @Override + public List discover() { + List consentOrderDocuments = ofNullable(approvedOrder) + .map(ApprovedOrder::getConsentOrder) + .map(List::of) + .orElse(List.of()); + + List orderLetterDocuments = ofNullable(approvedOrder) + .map(ApprovedOrder::getOrderLetter) + .map(List::of) + .orElse(List.of()); + + List pensionDocuments = ofNullable(approvedOrder) + .map(ApprovedOrder::getPensionDocuments) + .orElse(List.of()) + .stream() + .flatMap(pensionTypeCollection -> pensionTypeCollection.discover().stream()) + .toList(); + + return Stream.concat( + Stream.concat(consentOrderDocuments.stream(), orderLetterDocuments.stream()), + pensionDocuments.stream()) + .toList(); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DirectionOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DirectionOrderCollection.java index 59e459bd42..d7f18b3a3d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DirectionOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DirectionOrderCollection.java @@ -7,15 +7,27 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class DirectionOrderCollection { +public class DirectionOrderCollection implements CaseDocumentsDiscovery { @JsonProperty("id") private String id; @JsonProperty("value") private DirectionOrder value; + + @Override + public List discover() { + return ofNullable(value) + .map(DirectionOrder::getUploadDraftDocument) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrderCollection.java index 11bff0ee04..8fc0396c40 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrderCollection.java @@ -6,11 +6,23 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class DraftDirectionOrderCollection { +public class DraftDirectionOrderCollection implements CaseDocumentsDiscovery{ private DraftDirectionOrder value; + + @Override + public List discover() { + return ofNullable(value) + .map(DraftDirectionOrder::getUploadDraftDocument) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/IntervenerHearingNoticeCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/IntervenerHearingNoticeCollection.java index fcd2f80e89..b44efd2d7a 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/IntervenerHearingNoticeCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/IntervenerHearingNoticeCollection.java @@ -7,15 +7,27 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class IntervenerHearingNoticeCollection { +public class IntervenerHearingNoticeCollection implements CaseDocumentsDiscovery { @JsonProperty("id") private String id; @JsonProperty("value") private IntervenerHearingNotice value; + + @Override + public List discover() { + return ofNullable(value) + .map(IntervenerHearingNotice::getCaseDocument) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RefusalOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RefusalOrderCollection.java index bec9df1140..6110a1736c 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RefusalOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RefusalOrderCollection.java @@ -6,11 +6,23 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class RefusalOrderCollection { +public class RefusalOrderCollection implements CaseDocumentsDiscovery { private RefusalOrder value; + + @Override + public List discover() { + return ofNullable(value) + .map(RefusalOrder::getRefusalOrderAdditionalDocument) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RespondToOrderDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RespondToOrderDocumentCollection.java index 613f7f5c0c..22c09780a1 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RespondToOrderDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RespondToOrderDocumentCollection.java @@ -6,11 +6,23 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class RespondToOrderDocumentCollection { +public class RespondToOrderDocumentCollection implements CaseDocumentsDiscovery { private RespondToOrderDocument value; + + @Override + public List discover() { + return ofNullable(value) + .map(RespondToOrderDocument::getDocumentLink) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ScannedDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ScannedDocumentCollection.java index ffd47efa97..de18c3d2ba 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ScannedDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ScannedDocumentCollection.java @@ -6,12 +6,24 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class ScannedDocumentCollection { +public class ScannedDocumentCollection implements CaseDocumentsDiscovery { private String id; private ScannedDocument value; + + @Override + public List discover() { + return ofNullable(value) + .map(ScannedDocument::getUrl) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadAdditionalDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadAdditionalDocumentCollection.java index b56365d35f..8fb02ad52f 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadAdditionalDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadAdditionalDocumentCollection.java @@ -6,11 +6,23 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadAdditionalDocumentCollection { +public class UploadAdditionalDocumentCollection implements CaseDocumentsDiscovery { private UploadAdditionalDocument value; + + @Override + public List discover() { + return ofNullable(value) + .map(UploadAdditionalDocument::getAdditionalDocuments) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadCaseDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadCaseDocumentCollection.java index 463c2b3bd7..95fab5b7b2 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadCaseDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadCaseDocumentCollection.java @@ -11,6 +11,9 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.CaseDocumentTabData; import java.time.LocalDateTime; +import java.util.List; + +import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -18,7 +21,7 @@ @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode -public class UploadCaseDocumentCollection implements CaseDocumentTabData { +public class UploadCaseDocumentCollection implements CaseDocumentTabData, CaseDocumentsDiscovery { private String id; @@ -39,4 +42,12 @@ public void setUploadDateTime(LocalDateTime date) { uploadCaseDocument.setCaseDocumentUploadDateTime(date); } } + + @Override + public List discover() { + return ofNullable(uploadCaseDocument) + .map(UploadCaseDocument::getCaseDocuments) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocumentCollection.java index f6f8c8d76d..ad3a91226b 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocumentCollection.java @@ -6,11 +6,23 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadDocumentCollection implements CaseDocumentCollection { +public class UploadDocumentCollection implements CaseDocumentCollection, CaseDocumentsDiscovery { private UploadDocument value; + + @Override + public List discover() { + return ofNullable(value) + .map(UploadDocument::getDocumentLink) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocumentCollection.java index 26922b3f7b..b3cac7f721 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocumentCollection.java @@ -6,11 +6,23 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadGeneralDocumentCollection implements CaseDocumentCollection { +public class UploadGeneralDocumentCollection implements CaseDocumentCollection, CaseDocumentsDiscovery { private UploadGeneralDocument value; + + @Override + public List discover() { + return ofNullable(value) + .map(UploadGeneralDocument::getDocumentLink) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadOrderCollection.java index a47a59c8a2..d3e5fbcf39 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadOrderCollection.java @@ -6,12 +6,24 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadOrderCollection { +public class UploadOrderCollection implements CaseDocumentsDiscovery { private UploadOrder value; private String id; + + @Override + public List discover() { + return ofNullable(value) + .map(UploadOrder::getDocumentLink) + .map(List::of) + .orElse(List.of()); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/DraftDirectionWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/DraftDirectionWrapper.java index f83e67e272..b055cd0f03 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/DraftDirectionWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/DraftDirectionWrapper.java @@ -6,11 +6,17 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DraftDirectionDetailsCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DraftDirectionOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DraftDirectionOrderCollection; import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; + +import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -18,10 +24,28 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class DraftDirectionWrapper { +public class DraftDirectionWrapper implements CaseDocumentsDiscovery { private List draftDirectionOrderCollection; private DraftDirectionOrder latestDraftDirectionOrder; private List judgesAmendedOrderCollection; private List draftDirectionDetailsCollection; private List draftDirectionDetailsCollectionRO; + + @Override + public List discover() { + return Stream.of( + Stream.of(ofNullable(latestDraftDirectionOrder).orElse(DraftDirectionOrder.builder().build()).getUploadDraftDocument()), + ofNullable(draftDirectionOrderCollection) + .orElse(List.of()) + .stream() + .flatMap(d -> d.discover().stream()), + ofNullable(judgesAmendedOrderCollection) + .orElse(List.of()) + .stream() + .flatMap(d -> d.discover().stream()) + ) + .flatMap(s -> s) + .filter(Objects::nonNull) + .toList(); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationWrapper.java index c981dc2b66..026b012c18 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationWrapper.java @@ -12,6 +12,7 @@ import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApplicantAndRespondentEvidenceParty; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DynamicList; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralApplicationCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralApplicationOutcome; @@ -20,6 +21,10 @@ import java.time.LocalDate; import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; + +import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -27,7 +32,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class GeneralApplicationWrapper { +public class GeneralApplicationWrapper implements CaseDocumentsDiscovery { private YesOrNo generalApplicationDirectionsHearingRequired; private String generalApplicationReceivedFrom; private ApplicantAndRespondentEvidenceParty appRespGeneralApplicationReceivedFrom; @@ -76,4 +81,46 @@ public class GeneralApplicationWrapper { private String generalApplicationReferDetail; private DynamicList generalApplicationOutcomeList; private DynamicList generalApplicationDirectionsList; + + @Override + public List discover() { + return Stream.of( + Stream.of(generalApplicationDirectionsDocument, + generalApplicationDocument, + generalApplicationLatestDocument, + generalApplicationDraftOrder + ), + ofNullable(generalApplicationIntvrOrders) + .orElse(List.of()) + .stream() + .flatMap(d -> d.discover().stream()), + ofNullable(generalApplications) + .orElse(List.of()) + .stream() + .flatMap(d -> d.discover().stream()), + ofNullable(appRespGeneralApplications) + .orElse(List.of()) + .stream() + .flatMap(d -> d.discover().stream()), + ofNullable(intervener1GeneralApplications) + .orElse(List.of()) + .stream() + .flatMap(d -> d.discover().stream()), + ofNullable(intervener2GeneralApplications) + .orElse(List.of()) + .stream() + .flatMap(d -> d.discover().stream()), + ofNullable(intervener3GeneralApplications) + .orElse(List.of()) + .stream() + .flatMap(d -> d.discover().stream()), + ofNullable(intervener4GeneralApplications) + .orElse(List.of()) + .stream() + .flatMap(d -> d.discover().stream()) + ) + .flatMap(s -> s) + .filter(Objects::nonNull) + .toList(); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationsCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationsCollection.java index 07dd5aaff5..4f546f182d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationsCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationsCollection.java @@ -6,18 +6,44 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralApplicationItems; +import java.util.List; import java.util.UUID; +import java.util.stream.Stream; + +import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class GeneralApplicationsCollection { +public class GeneralApplicationsCollection implements CaseDocumentsDiscovery { @JsonProperty("id") private UUID id; @JsonProperty("value") private GeneralApplicationItems value; + + @Override + public List discover() { + return Stream.of( + ofNullable(value) + .map(GeneralApplicationItems::getGeneralApplicationDocument) + .map(List::of) + .orElse(List.of()), + ofNullable(value) + .map(GeneralApplicationItems::getGeneralApplicationDraftOrder) + .map(List::of) + .orElse(List.of()), + ofNullable(value) + .map(GeneralApplicationItems::getGeneralApplicationDirectionsDocument) + .map(List::of) + .orElse(List.of()) + ) + .flatMap(List::stream) + .toList(); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/InterimWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/InterimWrapper.java index 752e010d82..1b144b6ddc 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/InterimWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/InterimWrapper.java @@ -11,7 +11,9 @@ import lombok.Data; import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DirectionDetailInterimCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.InterimHearingBulkPrintDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.InterimHearingBulkPrintDocumentsData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.InterimHearingCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.InterimHearingCollectionItemData; @@ -20,6 +22,10 @@ import java.time.LocalDate; import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; + +import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -27,7 +33,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class InterimWrapper { +public class InterimWrapper implements CaseDocumentsDiscovery { private List directionDetailsCollectionInterim; private String interimTimeEstimate; @JsonSerialize(using = LocalDateSerializer.class) @@ -44,4 +50,16 @@ public class InterimWrapper { @JsonProperty("iHCollectionItemIds") private List interimHearingCollectionItemIds; private List interimHearingDocuments; + + @Override + public List discover() { + return Stream.of( + Stream.of(interimUploadAdditionalDocument, interimHearingDirectionsDocument), + ofNullable(interimHearingDocuments).orElse(List.of()).stream() + .map(d -> ofNullable(d.getValue()).orElse(InterimHearingBulkPrintDocument.builder().build()).getCaseDocument()) + ) + .flatMap(s -> s) + .filter(Objects::nonNull) + .toList(); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/UploadCaseDocumentWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/UploadCaseDocumentWrapper.java index dbe398848f..a4e5f20d62 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/UploadCaseDocumentWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/UploadCaseDocumentWrapper.java @@ -8,9 +8,13 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadCaseDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.document.CaseDocumentCollectionType; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -18,13 +22,16 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder(toBuilder = true) @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class UploadCaseDocumentWrapper { +@Slf4j +public class UploadCaseDocumentWrapper implements CaseDocumentsDiscovery { private List uploadCaseDocument; private List fdrCaseDocumentCollection; private List appCorrespondenceCollection; @@ -317,5 +324,39 @@ private List getNonNull(List discover() { + List result = new ArrayList<>(); + + // Get all fields of the class + Field[] fields = this.getClass().getDeclaredFields(); + + for (Field field : fields) { + // Check if the field is of type List + if (field.getType().equals(List.class)) { + try { + // Make the field accessible + field.setAccessible(true); + + // Get the value of the field + List collection = (List) field.get(this); + + // Process the collection + result.addAll( + ofNullable(collection) + .orElse(List.of()) + .stream() + .flatMap(c -> c.discover().stream()) + .toList() + ); + } catch (IllegalAccessException e) { + log.info("Fail to implement discover() using reflection.", e); + } + } + } + + return result; + } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index a9508c02e7..f5a17c5a68 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -7,23 +7,61 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AdditionalHearingDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AdditionalHearingDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AmendedConsentOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AmendedConsentOrderCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApprovedOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConfidentialUploadedDocumentData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConsentOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrderCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DirectionOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DirectionOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DraftDirectionOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DraftDirectionOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralApplicationItems; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrderCollectionItem; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.InterimHearingBulkPrintDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.InterimHearingBulkPrintDocumentsData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.IntervenerHearingNotice; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.IntervenerHearingNoticeCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OrderRefusalCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OrderRefusalHolder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OtherDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OtherDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.PensionType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.PensionTypeCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.RefusalOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.RefusalOrderCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.RespondToOrderDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.RespondToOrderDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ScannedDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ScannedDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadAdditionalDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadAdditionalDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadCaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadCaseDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConfidentialDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConsentOrderDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConsentOrderDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadOrderCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.DraftDirectionWrapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralApplicationWrapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralApplicationsCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralOrderWrapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.InterimWrapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.UploadCaseDocumentWrapper; import java.util.List; @@ -166,9 +204,9 @@ void testGetWarnings_duplicateInPensionCollection() throws DocumentContentChecke FinremCaseDetails.builder() .data(FinremCaseData.builder() .pensionCollection(List.of(PensionTypeCollection.builder() - .typedCaseDocument(PensionType.builder() - .pensionDocument(DUPLICATED_CASE_DOCUMENT) - .build()) + .typedCaseDocument(PensionType.builder() + .pensionDocument(DUPLICATED_CASE_DOCUMENT) + .build()) .build())) .build()) .build(), @@ -274,4 +312,679 @@ void testGetWarnings_duplicateInUploadConsentOrderDocuments() throws DocumentCon assertDuplicateFilenameWarning(warnings); } + + @Test + void testGetWarnings_duplicateInUploadOrder() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .uploadOrder(List.of(UploadOrderCollection.builder() + .value(UploadOrder.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInUploadDocuments() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .uploadDocuments(List.of(UploadDocumentCollection.builder() + .value(UploadDocument.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInRespondToOrderDocuments() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .respondToOrderDocuments(List.of(RespondToOrderDocumentCollection.builder() + .value(RespondToOrderDocument.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInAmendedConsentOrderCollection() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .amendedConsentOrderCollection(List.of(AmendedConsentOrderCollection.builder() + .value(AmendedConsentOrder.builder() + .amendedConsentOrder(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInScannedDocuments() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .scannedDocuments(List.of(ScannedDocumentCollection.builder() + .value(ScannedDocument.builder() + .url(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInApprovedOrderCollection_orderLetter() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .approvedOrderCollection(List.of(ConsentOrderCollection.builder() + .approvedOrder(ApprovedOrder.builder() + .orderLetter(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInApprovedOrderCollection_consentOrder() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .approvedOrderCollection(List.of(ConsentOrderCollection.builder() + .approvedOrder(ApprovedOrder.builder() + .consentOrder(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInApprovedOrderCollection_pensionDocuments() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .approvedOrderCollection(List.of(ConsentOrderCollection.builder() + .approvedOrder(ApprovedOrder.builder() + .pensionDocuments(List.of(PensionTypeCollection.builder() + .typedCaseDocument(PensionType.builder() + .pensionDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInScannedD81s() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .scannedD81s(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInAdditionalHearingDocuments() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .additionalHearingDocuments(List.of(AdditionalHearingDocumentCollection.builder() + .value(AdditionalHearingDocument.builder() + .document(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInHearingNoticeDocumentPack() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .hearingNoticeDocumentPack(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInHearingNoticesDocumentCollection() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .hearingNoticesDocumentCollection(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInUploadGeneralDocuments() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .uploadGeneralDocuments(List.of(UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInUploadHearingOrder() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .uploadHearingOrder(List.of(DirectionOrderCollection.builder() + .value(DirectionOrder.builder() + .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInHearingOrderOtherDocuments() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .hearingOrderOtherDocuments(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInIntv1HearingNoticesCollection() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .intv1HearingNoticesCollection(List.of(IntervenerHearingNoticeCollection.builder() + .value(IntervenerHearingNotice.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInIntv2HearingNoticesCollection() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .intv2HearingNoticesCollection(List.of(IntervenerHearingNoticeCollection.builder() + .value(IntervenerHearingNotice.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInIntv3HearingNoticesCollection() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .intv3HearingNoticesCollection(List.of(IntervenerHearingNoticeCollection.builder() + .value(IntervenerHearingNotice.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInIntv4HearingNoticesCollection() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .intv4HearingNoticesCollection(List.of(IntervenerHearingNoticeCollection.builder() + .value(IntervenerHearingNotice.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInRefusalOrderCollection() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .refusalOrderCollection(List.of(RefusalOrderCollection.builder() + .value(RefusalOrder.builder() + .refusalOrderAdditionalDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInUploadAdditionalDocument() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .uploadAdditionalDocument(List.of(UploadAdditionalDocumentCollection.builder() + .value(UploadAdditionalDocument.builder() + .additionalDocuments(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInCconfidentialDocumentsUploaded() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .confidentialDocumentsUploaded(List.of(ConfidentialUploadedDocumentData.builder() + .value(UploadConfidentialDocument.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInManageCaseDocumentCollection() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .manageCaseDocumentCollection(List.of(UploadCaseDocumentCollection.builder() + .uploadCaseDocument(UploadCaseDocument.builder() + .caseDocuments(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInUploadCaseDocumentWrapper_uploadCaseDocument() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .uploadCaseDocumentWrapper(UploadCaseDocumentWrapper.builder() + .uploadCaseDocument(List.of(UploadCaseDocumentCollection.builder() + .uploadCaseDocument(UploadCaseDocument.builder() + .caseDocuments(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInUploadCaseDocumentWrapper_intv3QaShared() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .uploadCaseDocumentWrapper(UploadCaseDocumentWrapper.builder() + .intv3QaShared(List.of(UploadCaseDocumentCollection.builder() + .uploadCaseDocument(UploadCaseDocument.builder() + .caseDocuments(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationDirectionsDocument() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationDirectionsDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationDocument() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationLatestDocument() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationLatestDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationDraftOrder() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationDraftOrder(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationIntvrOrders_generalApplicationDirectionsDocument() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationIntvrOrders(List.of(GeneralApplicationsCollection.builder() + .value(GeneralApplicationItems.builder() + .generalApplicationDirectionsDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationIntvrOrders_generalApplicationDraftOrder() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationIntvrOrders(List.of(GeneralApplicationsCollection.builder() + .value(GeneralApplicationItems.builder() + .generalApplicationDraftOrder(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationIntvrOrders_generalApplicationDocument() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationIntvrOrders(List.of(GeneralApplicationsCollection.builder() + .value(GeneralApplicationItems.builder() + .generalApplicationDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplications() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplications(List.of(GeneralApplicationsCollection.builder() + .value(GeneralApplicationItems.builder() + .generalApplicationDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInInterimWrapper_interimUploadAdditionalDocument() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .interimWrapper(InterimWrapper.builder() + .interimUploadAdditionalDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInInterimWrapper_interimHearingDirectionsDocument() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .interimWrapper(InterimWrapper.builder() + .interimHearingDirectionsDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInInterimWrapper_interimHearingDocuments() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .interimWrapper(InterimWrapper.builder() + .interimHearingDocuments(List.of(InterimHearingBulkPrintDocumentsData.builder() + .value(InterimHearingBulkPrintDocument.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInDraftDirectionWrapper_draftDirectionOrderCollection() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .draftDirectionWrapper(DraftDirectionWrapper.builder() + .draftDirectionOrderCollection(List.of(DraftDirectionOrderCollection.builder() + .value(DraftDirectionOrder.builder() + .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInDraftDirectionWrapper_latestDraftDirectionOrder() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .draftDirectionWrapper(DraftDirectionWrapper.builder() + .latestDraftDirectionOrder(DraftDirectionOrder.builder() + .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInDraftDirectionWrapper_judgesAmendedOrderCollection() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .draftDirectionWrapper(DraftDirectionWrapper.builder() + .judgesAmendedOrderCollection(List.of(DraftDirectionOrderCollection.builder() + .value(DraftDirectionOrder.builder() + .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } } From 28fa908928ac3875a6ce147f6963d89b4c6b285b Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 27 Jun 2024 19:15:14 +0100 Subject: [PATCH 67/96] Implementing CaseDocumentsDiscovery (continue) --- .../ccd/DraftDirectionOrderCollection.java | 2 +- .../model/ccd/GeneralLetterCollection.java | 30 ++++- .../ccd/wrapper/GeneralLetterWrapper.java | 25 +++- .../DuplicateFilenameDocumentCheckerTest.java | 115 ++++++++++++++++++ 4 files changed, 169 insertions(+), 3 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrderCollection.java index 8fc0396c40..0b4c59d3de 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrderCollection.java @@ -15,7 +15,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class DraftDirectionOrderCollection implements CaseDocumentsDiscovery{ +public class DraftDirectionOrderCollection implements CaseDocumentsDiscovery { private DraftDirectionOrder value; @Override diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralLetterCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralLetterCollection.java index 44f0a98076..2bcd0515e3 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralLetterCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralLetterCollection.java @@ -6,11 +6,39 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; + +import static java.util.Optional.ofNullable; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class GeneralLetterCollection { +public class GeneralLetterCollection implements CaseDocumentsDiscovery { private GeneralLetter value; + + @Override + public List discover() { + return Stream.of( + ofNullable(value) + .map(GeneralLetter::getGeneratedLetter) + .map(List::of) + .orElse(List.of()).stream(), + ofNullable(value) + .map(GeneralLetter::getGeneralLetterUploadedDocument) + .map(List::of) + .orElse(List.of()).stream(), + ofNullable(ofNullable(value).orElse(GeneralLetter.builder().build()) + .getGeneralLetterUploadedDocuments()) + .orElse(List.of()) + .stream() + .flatMap(d -> d.discover().stream()) + ) + .flatMap(s -> s) + .filter(Objects::nonNull) + .toList(); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralLetterWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralLetterWrapper.java index e0c9722c2e..46cf7e3451 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralLetterWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralLetterWrapper.java @@ -8,12 +8,17 @@ import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.Address; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DynamicRadioList; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralLetterAddressToType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralLetterCollection; import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; + +import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -21,7 +26,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class GeneralLetterWrapper { +public class GeneralLetterWrapper implements CaseDocumentsDiscovery { private DynamicRadioList generalLetterAddressee; private GeneralLetterAddressToType generalLetterAddressTo; private String generalLetterRecipient; @@ -32,4 +37,22 @@ public class GeneralLetterWrapper { private CaseDocument generalLetterUploadedDocument; private List generalLetterUploadedDocuments; private List generalLetterCollection; + + @Override + public List discover() { + return Stream.of( + Stream.of(generalLetterPreview, generalLetterUploadedDocument), + ofNullable(generalLetterUploadedDocuments) + .orElse(List.of()) + .stream() + .flatMap(d -> d.discover().stream()), + ofNullable(generalLetterCollection) + .orElse(List.of()) + .stream() + .flatMap(d -> d.discover().stream()) + ) + .flatMap(s -> s) + .filter(Objects::nonNull) + .toList(); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index f5a17c5a68..77174d1dbd 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -25,6 +25,8 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralApplicationItems; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralLetter; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralLetterCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrderCollectionItem; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.InterimHearingBulkPrintDocument; @@ -59,6 +61,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.DraftDirectionWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralApplicationWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralApplicationsCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralLetterWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralOrderWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.InterimWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.UploadCaseDocumentWrapper; @@ -987,4 +990,116 @@ void testGetWarnings_duplicateInDraftDirectionWrapper_judgesAmendedOrderCollecti assertDuplicateFilenameWarning(warnings); } + + @Test + void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterPreview() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalLetterWrapper(GeneralLetterWrapper.builder() + .generalLetterPreview(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterUploadedDocument() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalLetterWrapper(GeneralLetterWrapper.builder() + .generalLetterUploadedDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterUploadedDocuments() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalLetterWrapper(GeneralLetterWrapper.builder() + .generalLetterUploadedDocuments(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterCollection_generatedLetter() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalLetterWrapper(GeneralLetterWrapper.builder() + .generalLetterCollection(List.of(GeneralLetterCollection.builder() + .value(GeneralLetter.builder() + .generatedLetter(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterCollection_generalLetterUploadedDocument() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalLetterWrapper(GeneralLetterWrapper.builder() + .generalLetterCollection(List.of(GeneralLetterCollection.builder() + .value(GeneralLetter.builder() + .generalLetterUploadedDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterCollection_generalLetterUploadedDocuments() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalLetterWrapper(GeneralLetterWrapper.builder() + .generalLetterCollection(List.of(GeneralLetterCollection.builder() + .value(GeneralLetter.builder() + .generalLetterUploadedDocuments(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } } From 8a00fe7faeb8b35002437a17b528f971b0011a7a Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 27 Jun 2024 22:13:03 +0100 Subject: [PATCH 68/96] Remove logging --- .../model/ccd/wrapper/UploadCaseDocumentWrapper.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/UploadCaseDocumentWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/UploadCaseDocumentWrapper.java index a4e5f20d62..2b0b3b942e 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/UploadCaseDocumentWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/UploadCaseDocumentWrapper.java @@ -8,7 +8,6 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import lombok.extern.slf4j.Slf4j; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadCaseDocumentCollection; @@ -30,7 +29,6 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_EMPTY) -@Slf4j public class UploadCaseDocumentWrapper implements CaseDocumentsDiscovery { private List uploadCaseDocument; private List fdrCaseDocumentCollection; @@ -351,7 +349,7 @@ public List discover() { .toList() ); } catch (IllegalAccessException e) { - log.info("Fail to implement discover() using reflection.", e); + throw new RuntimeException("Fail to implement discover() using reflection.", e); } } } From 5c8ee1fff4eaaeedac1c55d4f428b6c4df93dc6b Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 28 Jun 2024 11:16:59 +0100 Subject: [PATCH 69/96] Implements HasCaseDocument --- .../model/ccd/AdditionalHearingDocument.java | 2 +- .../AdditionalHearingDocumentCollection.java | 15 +-- .../model/ccd/AmendedConsentOrder.java | 2 +- .../ccd/AmendedConsentOrderCollection.java | 14 +-- .../model/ccd/ApprovedOrder.java | 2 +- .../model/ccd/CaseDocumentCollection.java | 2 +- .../model/ccd/CaseDocumentsDiscovery.java | 7 -- .../ccd/ConfidentialUploadedDocumentData.java | 13 +- .../model/ccd/ConsentOrderCollection.java | 32 +---- .../model/ccd/ContestedGeneralOrder.java | 2 +- .../ccd/ContestedGeneralOrderCollection.java | 2 +- .../model/ccd/DirectionOrder.java | 2 +- .../model/ccd/DirectionOrderCollection.java | 14 +-- .../model/ccd/DocumentCollection.java | 13 +- .../model/ccd/DraftDirectionOrder.java | 2 +- .../ccd/DraftDirectionOrderCollection.java | 14 +-- .../model/ccd/GeneralApplication.java | 2 +- .../ccd/GeneralApplicationCollection.java | 2 +- .../model/ccd/GeneralApplicationItems.java | 2 +- ...eralApplicationSuportingDocumentItems.java | 2 +- ...eralApplicationSupportingDocumentData.java | 2 +- .../model/ccd/GeneralLetter.java | 2 +- .../model/ccd/GeneralLetterCollection.java | 30 +---- .../model/ccd/GeneralOrder.java | 2 +- .../model/ccd/GeneralOrderCollectionItem.java | 2 +- .../model/ccd/HasCaseDocument.java | 1 - .../model/ccd/HasDocumentLink.java | 6 + .../ccd/InterimHearingBulkPrintDocument.java | 2 +- .../InterimHearingBulkPrintDocumentsData.java | 2 +- .../model/ccd/InterimHearingCollection.java | 2 +- .../model/ccd/InterimHearingItem.java | 2 +- .../model/ccd/IntervenerHearingNotice.java | 2 +- .../IntervenerHearingNoticeCollection.java | 14 +-- .../model/ccd/OrderRefusalCollection.java | 14 +-- .../model/ccd/OrderRefusalHolder.java | 11 +- .../model/ccd/OtherDocument.java | 2 +- .../model/ccd/OtherDocumentCollection.java | 14 +-- .../model/ccd/PaymentDocument.java | 2 +- .../model/ccd/PaymentDocumentCollection.java | 14 +-- .../model/ccd/PensionType.java | 2 +- .../model/ccd/PensionTypeCollection.java | 14 +-- .../model/ccd/RefusalOrder.java | 2 +- .../model/ccd/RefusalOrderCollection.java | 14 +-- .../model/ccd/RespondToOrderDocument.java | 2 +- .../ccd/RespondToOrderDocumentCollection.java | 14 +-- .../model/ccd/ScannedDocument.java | 2 +- .../model/ccd/ScannedDocumentCollection.java | 14 +-- .../model/ccd/UploadAdditionalDocument.java | 2 +- .../UploadAdditionalDocumentCollection.java | 14 +-- .../model/ccd/UploadCaseDocument.java | 2 +- .../ccd/UploadCaseDocumentCollection.java | 13 +- .../model/ccd/UploadConfidentialDocument.java | 2 +- .../model/ccd/UploadConsentOrderDocument.java | 2 +- .../UploadConsentOrderDocumentCollection.java | 14 +-- .../model/ccd/UploadDocument.java | 2 +- .../model/ccd/UploadDocumentCollection.java | 14 +-- .../model/ccd/UploadGeneralDocument.java | 2 +- .../ccd/UploadGeneralDocumentCollection.java | 14 +-- .../model/ccd/UploadOrder.java | 2 +- .../model/ccd/UploadOrderCollection.java | 14 +-- .../ccd/wrapper/DraftDirectionWrapper.java | 27 +--- .../wrapper/GeneralApplicationWrapper.java | 50 +------- .../GeneralApplicationsCollection.java | 29 +---- .../ccd/wrapper/GeneralLetterWrapper.java | 26 +--- .../ccd/wrapper/GeneralOrderWrapper.java | 26 +--- .../model/ccd/wrapper/InterimWrapper.java | 21 +--- .../wrapper/UploadCaseDocumentWrapper.java | 42 +------ .../DuplicateFilenameDocumentChecker.java | 119 +++++++++--------- 68 files changed, 138 insertions(+), 635 deletions(-) delete mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentsDiscovery.java create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/HasDocumentLink.java diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocument.java index 80a375453a..51e4cba2c5 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocument.java @@ -18,7 +18,7 @@ @Setter @NoArgsConstructor @AllArgsConstructor -public class AdditionalHearingDocument { +public class AdditionalHearingDocument implements HasCaseDocument { @JsonProperty("additionalHearingDocument") private CaseDocument document; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocumentCollection.java index 65b4d3fa34..98a9341c8f 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocumentCollection.java @@ -5,24 +5,11 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; - -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class AdditionalHearingDocumentCollection implements CaseDocumentsDiscovery { +public class AdditionalHearingDocumentCollection implements HasCaseDocument { private AdditionalHearingDocument value; - - @Override - public List discover() { - return ofNullable(value) - .map(AdditionalHearingDocument::getDocument) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AmendedConsentOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AmendedConsentOrder.java index 6842ecc5dd..f4cd03daeb 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AmendedConsentOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AmendedConsentOrder.java @@ -15,7 +15,7 @@ @AllArgsConstructor @NoArgsConstructor @SuppressWarnings("java:S1700") -public class AmendedConsentOrder { +public class AmendedConsentOrder implements HasCaseDocument { @JsonProperty("amendedConsentOrder") private CaseDocument amendedConsentOrder; @JsonProperty("amendedConsentOrderDate") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AmendedConsentOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AmendedConsentOrderCollection.java index ea3c2a46a5..8f9d2a0781 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AmendedConsentOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AmendedConsentOrderCollection.java @@ -6,23 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class AmendedConsentOrderCollection implements CaseDocumentsDiscovery { +public class AmendedConsentOrderCollection implements HasCaseDocument { private AmendedConsentOrder value; - - @Override - public List discover() { - return ofNullable(value) - .map(AmendedConsentOrder::getAmendedConsentOrder) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApprovedOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApprovedOrder.java index 11502fcbc8..0d3d71aa79 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApprovedOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApprovedOrder.java @@ -14,7 +14,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class ApprovedOrder { +public class ApprovedOrder implements HasCaseDocument { @JsonProperty("orderLetter") private CaseDocument orderLetter; @JsonProperty("consentOrder") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java index c0f26d0ce5..c9b70c8b8d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentCollection.java @@ -1,5 +1,5 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd; -public interface CaseDocumentCollection { +public interface CaseDocumentCollection { T getValue(); } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentsDiscovery.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentsDiscovery.java deleted file mode 100644 index 6105616048..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocumentsDiscovery.java +++ /dev/null @@ -1,7 +0,0 @@ -package uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd; - -import java.util.List; - -public interface CaseDocumentsDiscovery { - List discover(); -} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConfidentialUploadedDocumentData.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConfidentialUploadedDocumentData.java index 3c1678533b..b8f24cbe35 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConfidentialUploadedDocumentData.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConfidentialUploadedDocumentData.java @@ -9,9 +9,6 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.CaseDocumentTabData; import java.time.LocalDateTime; -import java.util.List; - -import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -19,7 +16,7 @@ @AllArgsConstructor @NoArgsConstructor @Deprecated -public class ConfidentialUploadedDocumentData implements CaseDocumentTabData, CaseDocumentsDiscovery { +public class ConfidentialUploadedDocumentData implements CaseDocumentTabData, HasCaseDocument { private String id; private UploadConfidentialDocument value; @@ -36,12 +33,4 @@ public void setUploadDateTime(LocalDateTime date) { value.setConfidentialDocumentUploadDateTime(date); } } - - @Override - public List discover() { - return ofNullable(value) - .map(UploadConfidentialDocument::getDocumentLink) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentOrderCollection.java index c67d29255a..4b79b96dc7 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentOrderCollection.java @@ -7,44 +7,14 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; -import java.util.stream.Stream; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class ConsentOrderCollection implements CaseDocumentsDiscovery { +public class ConsentOrderCollection implements HasCaseDocument { @JsonProperty("id") private String id; @JsonProperty("value") private ApprovedOrder approvedOrder; - - @Override - public List discover() { - List consentOrderDocuments = ofNullable(approvedOrder) - .map(ApprovedOrder::getConsentOrder) - .map(List::of) - .orElse(List.of()); - - List orderLetterDocuments = ofNullable(approvedOrder) - .map(ApprovedOrder::getOrderLetter) - .map(List::of) - .orElse(List.of()); - - List pensionDocuments = ofNullable(approvedOrder) - .map(ApprovedOrder::getPensionDocuments) - .orElse(List.of()) - .stream() - .flatMap(pensionTypeCollection -> pensionTypeCollection.discover().stream()) - .toList(); - - return Stream.concat( - Stream.concat(consentOrderDocuments.stream(), orderLetterDocuments.stream()), - pensionDocuments.stream()) - .toList(); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ContestedGeneralOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ContestedGeneralOrder.java index c00ac1adf7..f8a996dba7 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ContestedGeneralOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ContestedGeneralOrder.java @@ -19,7 +19,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class ContestedGeneralOrder { +public class ContestedGeneralOrder implements HasCaseDocument { private String generalOrderText; private CaseDocument additionalDocument; @JsonProperty("selectJudge") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ContestedGeneralOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ContestedGeneralOrderCollection.java index e74fcac778..5be2cc9532 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ContestedGeneralOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ContestedGeneralOrderCollection.java @@ -11,6 +11,6 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class ContestedGeneralOrderCollection { +public class ContestedGeneralOrderCollection implements HasCaseDocument { private ContestedGeneralOrder value; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DirectionOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DirectionOrder.java index c53a404e13..f1d20cae94 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DirectionOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DirectionOrder.java @@ -16,7 +16,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class DirectionOrder { +public class DirectionOrder implements HasCaseDocument { @JsonProperty("uploadDraftDocument") CaseDocument uploadDraftDocument; @JsonProperty("orderDateTime") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DirectionOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DirectionOrderCollection.java index d7f18b3a3d..292722a915 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DirectionOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DirectionOrderCollection.java @@ -7,27 +7,15 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class DirectionOrderCollection implements CaseDocumentsDiscovery { +public class DirectionOrderCollection implements HasCaseDocument { @JsonProperty("id") private String id; @JsonProperty("value") private DirectionOrder value; - - @Override - public List discover() { - return ofNullable(value) - .map(DirectionOrder::getUploadDraftDocument) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DocumentCollection.java index 83f86dcef0..388e0a5476 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DocumentCollection.java @@ -6,22 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class DocumentCollection implements CaseDocumentsDiscovery { +public class DocumentCollection implements HasCaseDocument { private CaseDocument value; - - @Override - public List discover() { - return ofNullable(value) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrder.java index 1eaed4eb57..31b4cc4925 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrder.java @@ -14,7 +14,7 @@ @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode -public class DraftDirectionOrder { +public class DraftDirectionOrder implements HasCaseDocument { @JsonProperty("purposeOfDocument") String purposeOfDocument; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrderCollection.java index 0b4c59d3de..c017d2314a 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DraftDirectionOrderCollection.java @@ -6,23 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class DraftDirectionOrderCollection implements CaseDocumentsDiscovery { +public class DraftDirectionOrderCollection implements HasCaseDocument { private DraftDirectionOrder value; - - @Override - public List discover() { - return ofNullable(value) - .map(DraftDirectionOrder::getUploadDraftDocument) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplication.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplication.java index a47611451a..2cd63fb197 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplication.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplication.java @@ -10,7 +10,7 @@ @Getter @NoArgsConstructor @AllArgsConstructor -public class GeneralApplication { +public class GeneralApplication implements HasCaseDocument { @JsonProperty("generalApplicationDocument") private CaseDocument generalApplicationDocument; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationCollection.java index ca9bba9061..9082d361ee 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationCollection.java @@ -11,6 +11,6 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class GeneralApplicationCollection { +public class GeneralApplicationCollection implements HasCaseDocument { private GeneralApplication value; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationItems.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationItems.java index 04dcf5c2f7..fc5a617498 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationItems.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationItems.java @@ -17,7 +17,7 @@ @NoArgsConstructor @AllArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class GeneralApplicationItems { +public class GeneralApplicationItems implements HasCaseDocument { @JsonProperty("generalApplicationDocument") private CaseDocument generalApplicationDocument; @JsonProperty("generalApplicationCreatedBy") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationSuportingDocumentItems.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationSuportingDocumentItems.java index 4797a24096..0a756fb23e 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationSuportingDocumentItems.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationSuportingDocumentItems.java @@ -12,7 +12,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class GeneralApplicationSuportingDocumentItems { +public class GeneralApplicationSuportingDocumentItems implements HasCaseDocument { @JsonProperty("supportDocument") private CaseDocument supportDocument; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationSupportingDocumentData.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationSupportingDocumentData.java index 761877eb6a..990a8dd101 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationSupportingDocumentData.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralApplicationSupportingDocumentData.java @@ -12,7 +12,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class GeneralApplicationSupportingDocumentData { +public class GeneralApplicationSupportingDocumentData implements HasCaseDocument { @JsonProperty("id") private String id; @JsonProperty("value") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralLetter.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralLetter.java index 8a88f156c9..235032bb1e 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralLetter.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralLetter.java @@ -16,7 +16,7 @@ @NoArgsConstructor @AllArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class GeneralLetter { +public class GeneralLetter implements HasCaseDocument { @JsonProperty("generatedLetter") private CaseDocument generatedLetter; @JsonProperty("generalLetterUploadedDocument") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralLetterCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralLetterCollection.java index 2bcd0515e3..7248019415 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralLetterCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralLetterCollection.java @@ -6,39 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class GeneralLetterCollection implements CaseDocumentsDiscovery { +public class GeneralLetterCollection implements HasCaseDocument { private GeneralLetter value; - - @Override - public List discover() { - return Stream.of( - ofNullable(value) - .map(GeneralLetter::getGeneratedLetter) - .map(List::of) - .orElse(List.of()).stream(), - ofNullable(value) - .map(GeneralLetter::getGeneralLetterUploadedDocument) - .map(List::of) - .orElse(List.of()).stream(), - ofNullable(ofNullable(value).orElse(GeneralLetter.builder().build()) - .getGeneralLetterUploadedDocuments()) - .orElse(List.of()) - .stream() - .flatMap(d -> d.discover().stream()) - ) - .flatMap(s -> s) - .filter(Objects::nonNull) - .toList(); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralOrder.java index a26eeebf65..6dbb7efc45 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralOrder.java @@ -19,7 +19,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class GeneralOrder { +public class GeneralOrder implements HasCaseDocument { @JsonProperty("generalOrder_addressTo") private String generalOrderAddressTo; @JsonProperty("generalOrder_order") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralOrderCollectionItem.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralOrderCollectionItem.java index 0ed1d15fbf..abccb78dfa 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralOrderCollectionItem.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralOrderCollectionItem.java @@ -14,7 +14,7 @@ @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode(callSuper = true) -public class GeneralOrderCollectionItem extends CollectionElement { +public class GeneralOrderCollectionItem extends CollectionElement implements HasCaseDocument { @JsonProperty("value") private GeneralOrder generalOrder; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/HasCaseDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/HasCaseDocument.java index 58bb10dbb2..7f2be0f2e2 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/HasCaseDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/HasCaseDocument.java @@ -1,5 +1,4 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd; public interface HasCaseDocument { - CaseDocument getDocumentLink(); } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/HasDocumentLink.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/HasDocumentLink.java new file mode 100644 index 0000000000..f0d3903b83 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/HasDocumentLink.java @@ -0,0 +1,6 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd; + +public interface HasDocumentLink extends HasCaseDocument { + + CaseDocument getDocumentLink(); +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingBulkPrintDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingBulkPrintDocument.java index 83b0f33322..60cd5584e2 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingBulkPrintDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingBulkPrintDocument.java @@ -12,7 +12,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class InterimHearingBulkPrintDocument { +public class InterimHearingBulkPrintDocument implements HasCaseDocument { @JsonProperty("bulkprintDocument") CaseDocument caseDocument; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingBulkPrintDocumentsData.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingBulkPrintDocumentsData.java index 9c25c69c12..24159e7544 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingBulkPrintDocumentsData.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingBulkPrintDocumentsData.java @@ -12,7 +12,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class InterimHearingBulkPrintDocumentsData { +public class InterimHearingBulkPrintDocumentsData implements HasCaseDocument { @JsonProperty("id") private String id; @JsonProperty("value") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingCollection.java index 3cfdfc77d3..83eb5f2ebe 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingCollection.java @@ -14,7 +14,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class InterimHearingCollection { +public class InterimHearingCollection implements HasCaseDocument { @JsonProperty("id") private UUID id; @JsonProperty("value") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingItem.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingItem.java index cba78605a3..08662da607 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingItem.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/InterimHearingItem.java @@ -17,7 +17,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class InterimHearingItem { +public class InterimHearingItem implements HasCaseDocument { @JsonSerialize(using = LocalDateSerializer.class) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") public LocalDate interimHearingDate; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/IntervenerHearingNotice.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/IntervenerHearingNotice.java index b66c50dac9..97cba1b6c3 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/IntervenerHearingNotice.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/IntervenerHearingNotice.java @@ -16,7 +16,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class IntervenerHearingNotice { +public class IntervenerHearingNotice implements HasCaseDocument { @JsonProperty("hearingNotice") CaseDocument caseDocument; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/IntervenerHearingNoticeCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/IntervenerHearingNoticeCollection.java index b44efd2d7a..4fcf6fa54f 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/IntervenerHearingNoticeCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/IntervenerHearingNoticeCollection.java @@ -7,27 +7,15 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class IntervenerHearingNoticeCollection implements CaseDocumentsDiscovery { +public class IntervenerHearingNoticeCollection implements HasCaseDocument { @JsonProperty("id") private String id; @JsonProperty("value") private IntervenerHearingNotice value; - - @Override - public List discover() { - return ofNullable(value) - .map(IntervenerHearingNotice::getCaseDocument) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalCollection.java index 141d52f979..ad5e6d5389 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalCollection.java @@ -6,23 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class OrderRefusalCollection implements CaseDocumentsDiscovery { +public class OrderRefusalCollection implements HasCaseDocument { private OrderRefusalHolder value; - - @Override - public List discover() { - return ofNullable(value) - .map(OrderRefusalHolder::getOrderRefusalDocs) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalHolder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalHolder.java index f60c71b0df..d5d676de08 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalHolder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderRefusalHolder.java @@ -14,15 +14,13 @@ import java.time.LocalDate; import java.util.List; -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class OrderRefusalHolder implements CaseDocumentsDiscovery { +public class OrderRefusalHolder implements HasCaseDocument { private String orderRefusalAfterText; private List orderRefusal; private String orderRefusalOther; @@ -34,11 +32,4 @@ public class OrderRefusalHolder implements CaseDocumentsDiscovery { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") private LocalDate orderRefusalDate; private String orderRefusalAddComments; - - @Override - public List discover() { - return ofNullable(orderRefusalDocs) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OtherDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OtherDocument.java index bff3e9c40d..70a290a2fc 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OtherDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OtherDocument.java @@ -11,7 +11,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class OtherDocument { +public class OtherDocument implements HasCaseDocument { private OtherDocumentType typeOfDocument; private CaseDocument uploadedDocument; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OtherDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OtherDocumentCollection.java index 1138996db2..edf2134e96 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OtherDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OtherDocumentCollection.java @@ -6,23 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class OtherDocumentCollection implements CaseDocumentsDiscovery { +public class OtherDocumentCollection implements HasCaseDocument { private OtherDocument value; - - @Override - public List discover() { - return ofNullable(value) - .map(OtherDocument::getUploadedDocument) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocument.java index 601534479d..afe5eadc86 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocument.java @@ -11,7 +11,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class PaymentDocument { +public class PaymentDocument implements HasCaseDocument{ private PaymentDocumentType typeOfDocument; private CaseDocument uploadedDocument; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocumentCollection.java index 0a14c4dcee..4278c6399a 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocumentCollection.java @@ -6,23 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class PaymentDocumentCollection implements CaseDocumentsDiscovery { +public class PaymentDocumentCollection implements HasCaseDocument { private PaymentDocument value; - - @Override - public List discover() { - return ofNullable(value) - .map(PaymentDocument::getUploadedDocument) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PensionType.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PensionType.java index c9ba623e5a..3505289040 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PensionType.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PensionType.java @@ -12,7 +12,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class PensionType { +public class PensionType implements HasCaseDocument { private PensionDocumentType typeOfDocument; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PensionTypeCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PensionTypeCollection.java index 29ec02d0d0..ea4ddfaa2a 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PensionTypeCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PensionTypeCollection.java @@ -7,26 +7,14 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class PensionTypeCollection implements CaseDocumentsDiscovery { +public class PensionTypeCollection implements HasCaseDocument { @JsonProperty("id") private String id; @JsonProperty("value") private PensionType typedCaseDocument; - - @Override - public List discover() { - return ofNullable(typedCaseDocument) - .map(PensionType::getPensionDocument) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RefusalOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RefusalOrder.java index 169d0c8cd9..8ebf219d64 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RefusalOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RefusalOrder.java @@ -11,6 +11,6 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class RefusalOrder { +public class RefusalOrder implements HasCaseDocument { private CaseDocument refusalOrderAdditionalDocument; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RefusalOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RefusalOrderCollection.java index 6110a1736c..978a86d487 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RefusalOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RefusalOrderCollection.java @@ -6,23 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class RefusalOrderCollection implements CaseDocumentsDiscovery { +public class RefusalOrderCollection implements HasCaseDocument { private RefusalOrder value; - - @Override - public List discover() { - return ofNullable(value) - .map(RefusalOrder::getRefusalOrderAdditionalDocument) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RespondToOrderDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RespondToOrderDocument.java index 7967cbc493..0175667302 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RespondToOrderDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RespondToOrderDocument.java @@ -19,7 +19,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class RespondToOrderDocument { +public class RespondToOrderDocument implements HasCaseDocument { @JsonProperty("DocumentType") private RespondToOrderDocumentType documentType; @JsonProperty("DocumentEmailContent") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RespondToOrderDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RespondToOrderDocumentCollection.java index 22c09780a1..f9f277f16d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RespondToOrderDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/RespondToOrderDocumentCollection.java @@ -6,23 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class RespondToOrderDocumentCollection implements CaseDocumentsDiscovery { +public class RespondToOrderDocumentCollection implements HasCaseDocument { private RespondToOrderDocument value; - - @Override - public List discover() { - return ofNullable(value) - .map(RespondToOrderDocument::getDocumentLink) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ScannedDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ScannedDocument.java index 9905ef8e10..2775fbfb6f 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ScannedDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ScannedDocument.java @@ -17,7 +17,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class ScannedDocument { +public class ScannedDocument implements HasCaseDocument { private ScannedDocumentType type; private String subtype; private CaseDocument url; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ScannedDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ScannedDocumentCollection.java index de18c3d2ba..113c643ac9 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ScannedDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ScannedDocumentCollection.java @@ -6,24 +6,12 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class ScannedDocumentCollection implements CaseDocumentsDiscovery { +public class ScannedDocumentCollection implements HasCaseDocument { private String id; private ScannedDocument value; - - @Override - public List discover() { - return ofNullable(value) - .map(ScannedDocument::getUrl) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadAdditionalDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadAdditionalDocument.java index 22ca9a54e0..fd3fe111b3 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadAdditionalDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadAdditionalDocument.java @@ -11,7 +11,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadAdditionalDocument { +public class UploadAdditionalDocument implements HasCaseDocument { private CaseDocument additionalDocuments; private AdditionalDocumentType additionalDocumentType; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadAdditionalDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadAdditionalDocumentCollection.java index 8fb02ad52f..9d15781ec7 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadAdditionalDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadAdditionalDocumentCollection.java @@ -6,23 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadAdditionalDocumentCollection implements CaseDocumentsDiscovery { +public class UploadAdditionalDocumentCollection implements HasCaseDocument { private UploadAdditionalDocument value; - - @Override - public List discover() { - return ofNullable(value) - .map(UploadAdditionalDocument::getAdditionalDocuments) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadCaseDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadCaseDocument.java index f36d45a179..96875f3a0d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadCaseDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadCaseDocument.java @@ -17,7 +17,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class UploadCaseDocument { +public class UploadCaseDocument implements HasCaseDocument { private CaseDocument caseDocuments; private CaseDocumentType caseDocumentType; private CaseDocumentParty caseDocumentParty; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadCaseDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadCaseDocumentCollection.java index 95fab5b7b2..3542b582cf 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadCaseDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadCaseDocumentCollection.java @@ -11,9 +11,6 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.CaseDocumentTabData; import java.time.LocalDateTime; -import java.util.List; - -import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -21,7 +18,7 @@ @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode -public class UploadCaseDocumentCollection implements CaseDocumentTabData, CaseDocumentsDiscovery { +public class UploadCaseDocumentCollection implements CaseDocumentTabData, HasCaseDocument { private String id; @@ -42,12 +39,4 @@ public void setUploadDateTime(LocalDateTime date) { uploadCaseDocument.setCaseDocumentUploadDateTime(date); } } - - @Override - public List discover() { - return ofNullable(uploadCaseDocument) - .map(UploadCaseDocument::getCaseDocuments) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConfidentialDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConfidentialDocument.java index 533c0c7ff8..2790526d48 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConfidentialDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConfidentialDocument.java @@ -22,7 +22,7 @@ @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) @Deprecated -public class UploadConfidentialDocument { +public class UploadConfidentialDocument implements HasCaseDocument { @JsonProperty("DocumentType") private CaseDocumentType documentType; @JsonProperty("DocumentLink") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderDocument.java index 084a7a777e..c10664d03e 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderDocument.java @@ -19,7 +19,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class UploadConsentOrderDocument { +public class UploadConsentOrderDocument implements HasCaseDocument { @JsonProperty("DocumentType") private UploadConsentOrderDocumentType documentType; @JsonProperty("DocumentEmailContent") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderDocumentCollection.java index 27a48e7be1..8143a0aca9 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderDocumentCollection.java @@ -6,23 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadConsentOrderDocumentCollection implements CaseDocumentsDiscovery { +public class UploadConsentOrderDocumentCollection implements HasCaseDocument { private UploadConsentOrderDocument value; - - @Override - public List discover() { - return ofNullable(value) - .map(UploadConsentOrderDocument::getDocumentLink) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocument.java index fde4835bbb..18dec80601 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocument.java @@ -19,7 +19,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class UploadDocument implements HasCaseDocument { +public class UploadDocument implements HasDocumentLink { @JsonProperty("DocumentType") private UploadDocumentType documentType; @JsonProperty("DocumentEmailContent") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocumentCollection.java index ad3a91226b..cee75425cb 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadDocumentCollection.java @@ -6,23 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadDocumentCollection implements CaseDocumentCollection, CaseDocumentsDiscovery { +public class UploadDocumentCollection implements CaseDocumentCollection, HasCaseDocument { private UploadDocument value; - - @Override - public List discover() { - return ofNullable(value) - .map(UploadDocument::getDocumentLink) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocument.java index 67590d3493..371961d722 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocument.java @@ -21,7 +21,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class UploadGeneralDocument implements HasCaseDocument { +public class UploadGeneralDocument implements HasDocumentLink { @JsonProperty("DocumentType") private UploadGeneralDocumentType documentType; @JsonProperty("DocumentEmailContent") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocumentCollection.java index b3cac7f721..17bf97f498 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadGeneralDocumentCollection.java @@ -6,23 +6,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadGeneralDocumentCollection implements CaseDocumentCollection, CaseDocumentsDiscovery { +public class UploadGeneralDocumentCollection implements CaseDocumentCollection, HasCaseDocument { private UploadGeneralDocument value; - - @Override - public List discover() { - return ofNullable(value) - .map(UploadGeneralDocument::getDocumentLink) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadOrder.java index 8ebf9496b7..acbc78018f 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadOrder.java @@ -19,7 +19,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class UploadOrder { +public class UploadOrder implements HasCaseDocument { @JsonProperty("DocumentType") private UploadOrderDocumentType documentType; @JsonProperty("DocumentLink") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadOrderCollection.java index d3e5fbcf39..86c3c6d1dd 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadOrderCollection.java @@ -6,24 +6,12 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadOrderCollection implements CaseDocumentsDiscovery { +public class UploadOrderCollection implements HasCaseDocument { private UploadOrder value; private String id; - - @Override - public List discover() { - return ofNullable(value) - .map(UploadOrder::getDocumentLink) - .map(List::of) - .orElse(List.of()); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/DraftDirectionWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/DraftDirectionWrapper.java index b055cd0f03..931f70700d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/DraftDirectionWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/DraftDirectionWrapper.java @@ -6,17 +6,12 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DraftDirectionDetailsCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DraftDirectionOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DraftDirectionOrderCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - -import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -24,28 +19,10 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class DraftDirectionWrapper implements CaseDocumentsDiscovery { +public class DraftDirectionWrapper implements HasCaseDocument { private List draftDirectionOrderCollection; private DraftDirectionOrder latestDraftDirectionOrder; private List judgesAmendedOrderCollection; private List draftDirectionDetailsCollection; private List draftDirectionDetailsCollectionRO; - - @Override - public List discover() { - return Stream.of( - Stream.of(ofNullable(latestDraftDirectionOrder).orElse(DraftDirectionOrder.builder().build()).getUploadDraftDocument()), - ofNullable(draftDirectionOrderCollection) - .orElse(List.of()) - .stream() - .flatMap(d -> d.discover().stream()), - ofNullable(judgesAmendedOrderCollection) - .orElse(List.of()) - .stream() - .flatMap(d -> d.discover().stream()) - ) - .flatMap(s -> s) - .filter(Objects::nonNull) - .toList(); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationWrapper.java index 026b012c18..4a0f39e95b 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationWrapper.java @@ -12,19 +12,15 @@ import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApplicantAndRespondentEvidenceParty; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DynamicList; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralApplicationCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralApplicationOutcome; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.JudgeType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.YesOrNo; import java.time.LocalDate; import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - -import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -32,7 +28,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class GeneralApplicationWrapper implements CaseDocumentsDiscovery { +public class GeneralApplicationWrapper implements HasCaseDocument { private YesOrNo generalApplicationDirectionsHearingRequired; private String generalApplicationReceivedFrom; private ApplicantAndRespondentEvidenceParty appRespGeneralApplicationReceivedFrom; @@ -81,46 +77,4 @@ public class GeneralApplicationWrapper implements CaseDocumentsDiscovery { private String generalApplicationReferDetail; private DynamicList generalApplicationOutcomeList; private DynamicList generalApplicationDirectionsList; - - @Override - public List discover() { - return Stream.of( - Stream.of(generalApplicationDirectionsDocument, - generalApplicationDocument, - generalApplicationLatestDocument, - generalApplicationDraftOrder - ), - ofNullable(generalApplicationIntvrOrders) - .orElse(List.of()) - .stream() - .flatMap(d -> d.discover().stream()), - ofNullable(generalApplications) - .orElse(List.of()) - .stream() - .flatMap(d -> d.discover().stream()), - ofNullable(appRespGeneralApplications) - .orElse(List.of()) - .stream() - .flatMap(d -> d.discover().stream()), - ofNullable(intervener1GeneralApplications) - .orElse(List.of()) - .stream() - .flatMap(d -> d.discover().stream()), - ofNullable(intervener2GeneralApplications) - .orElse(List.of()) - .stream() - .flatMap(d -> d.discover().stream()), - ofNullable(intervener3GeneralApplications) - .orElse(List.of()) - .stream() - .flatMap(d -> d.discover().stream()), - ofNullable(intervener4GeneralApplications) - .orElse(List.of()) - .stream() - .flatMap(d -> d.discover().stream()) - ) - .flatMap(s -> s) - .filter(Objects::nonNull) - .toList(); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationsCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationsCollection.java index 4f546f182d..af9129a807 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationsCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralApplicationsCollection.java @@ -6,44 +6,19 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralApplicationItems; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; -import java.util.List; import java.util.UUID; -import java.util.stream.Stream; - -import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class GeneralApplicationsCollection implements CaseDocumentsDiscovery { +public class GeneralApplicationsCollection implements HasCaseDocument { @JsonProperty("id") private UUID id; @JsonProperty("value") private GeneralApplicationItems value; - - @Override - public List discover() { - return Stream.of( - ofNullable(value) - .map(GeneralApplicationItems::getGeneralApplicationDocument) - .map(List::of) - .orElse(List.of()), - ofNullable(value) - .map(GeneralApplicationItems::getGeneralApplicationDraftOrder) - .map(List::of) - .orElse(List.of()), - ofNullable(value) - .map(GeneralApplicationItems::getGeneralApplicationDirectionsDocument) - .map(List::of) - .orElse(List.of()) - ) - .flatMap(List::stream) - .toList(); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralLetterWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralLetterWrapper.java index 46cf7e3451..b97a1dc8d4 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralLetterWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralLetterWrapper.java @@ -8,17 +8,13 @@ import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.Address; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DynamicRadioList; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralLetterAddressToType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralLetterCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - -import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -26,7 +22,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class GeneralLetterWrapper implements CaseDocumentsDiscovery { +public class GeneralLetterWrapper implements HasCaseDocument { private DynamicRadioList generalLetterAddressee; private GeneralLetterAddressToType generalLetterAddressTo; private String generalLetterRecipient; @@ -37,22 +33,4 @@ public class GeneralLetterWrapper implements CaseDocumentsDiscovery { private CaseDocument generalLetterUploadedDocument; private List generalLetterUploadedDocuments; private List generalLetterCollection; - - @Override - public List discover() { - return Stream.of( - Stream.of(generalLetterPreview, generalLetterUploadedDocument), - ofNullable(generalLetterUploadedDocuments) - .orElse(List.of()) - .stream() - .flatMap(d -> d.discover().stream()), - ofNullable(generalLetterCollection) - .orElse(List.of()) - .stream() - .flatMap(d -> d.discover().stream()) - ) - .flatMap(s -> s) - .filter(Objects::nonNull) - .toList(); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralOrderWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralOrderWrapper.java index a467614e6a..80a5cf71e2 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralOrderWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralOrderWrapper.java @@ -10,20 +10,14 @@ import lombok.Data; import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrderCollection; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrderAddressTo; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrderCollectionItem; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.JudgeType; import java.time.LocalDate; import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - -import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -31,7 +25,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class GeneralOrderWrapper implements CaseDocumentsDiscovery { +public class GeneralOrderWrapper implements HasCaseDocument { private GeneralOrderAddressTo generalOrderAddressTo; @JsonSerialize(using = LocalDateSerializer.class) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") @@ -46,20 +40,4 @@ public class GeneralOrderWrapper implements CaseDocumentsDiscovery { private List generalOrders; private List generalOrdersConsent; private List generalOrderCollection; - - @Override - public List discover() { - return Stream.of( - Stream.of(generalOrderLatestDocument, generalOrderPreviewDocument), - ofNullable(generalOrders).orElse(List.of()).stream() - .map(d -> ofNullable(d.getValue()).orElse(ContestedGeneralOrder.builder().build()).getAdditionalDocument()), - ofNullable(generalOrdersConsent).orElse(List.of()).stream() - .map(d -> ofNullable(d.getValue()).orElse(ContestedGeneralOrder.builder().build()).getAdditionalDocument()), - ofNullable(generalOrderCollection).orElse(List.of()).stream() - .map(d -> ofNullable(d.getGeneralOrder()).orElse(GeneralOrder.builder().build()).getGeneralOrderDocumentUpload()) - ) - .flatMap(s -> s) - .filter(Objects::nonNull) - .toList(); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/InterimWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/InterimWrapper.java index 1b144b6ddc..99d33b7320 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/InterimWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/InterimWrapper.java @@ -11,9 +11,8 @@ import lombok.Data; import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DirectionDetailInterimCollection; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.InterimHearingBulkPrintDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.InterimHearingBulkPrintDocumentsData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.InterimHearingCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.InterimHearingCollectionItemData; @@ -22,10 +21,6 @@ import java.time.LocalDate; import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - -import static java.util.Optional.ofNullable; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -33,7 +28,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class InterimWrapper implements CaseDocumentsDiscovery { +public class InterimWrapper implements HasCaseDocument { private List directionDetailsCollectionInterim; private String interimTimeEstimate; @JsonSerialize(using = LocalDateSerializer.class) @@ -50,16 +45,4 @@ public class InterimWrapper implements CaseDocumentsDiscovery { @JsonProperty("iHCollectionItemIds") private List interimHearingCollectionItemIds; private List interimHearingDocuments; - - @Override - public List discover() { - return Stream.of( - Stream.of(interimUploadAdditionalDocument, interimHearingDirectionsDocument), - ofNullable(interimHearingDocuments).orElse(List.of()).stream() - .map(d -> ofNullable(d.getValue()).orElse(InterimHearingBulkPrintDocument.builder().build()).getCaseDocument()) - ) - .flatMap(s -> s) - .filter(Objects::nonNull) - .toList(); - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/UploadCaseDocumentWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/UploadCaseDocumentWrapper.java index 2b0b3b942e..89179779e2 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/UploadCaseDocumentWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/UploadCaseDocumentWrapper.java @@ -8,12 +8,10 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadCaseDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.document.CaseDocumentCollectionType; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -21,15 +19,13 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static java.util.Optional.ofNullable; - @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder(toBuilder = true) @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class UploadCaseDocumentWrapper implements CaseDocumentsDiscovery { +public class UploadCaseDocumentWrapper implements HasCaseDocument { private List uploadCaseDocument; private List fdrCaseDocumentCollection; private List appCorrespondenceCollection; @@ -322,39 +318,5 @@ private List getNonNull(List discover() { - List result = new ArrayList<>(); - - // Get all fields of the class - Field[] fields = this.getClass().getDeclaredFields(); - - for (Field field : fields) { - // Check if the field is of type List - if (field.getType().equals(List.class)) { - try { - // Make the field accessible - field.setAccessible(true); - - // Get the value of the field - List collection = (List) field.get(this); - - // Process the collection - result.addAll( - ofNullable(collection) - .orElse(List.of()) - .stream() - .flatMap(c -> c.discover().stream()) - .toList() - ); - } catch (IllegalAccessException e) { - throw new RuntimeException("Fail to implement discover() using reflection.", e); - } - } - } - - return result; - } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index bbea103093..0b74cdbe81 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -1,21 +1,19 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeanWrapperImpl; import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentsDiscovery; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; import java.lang.reflect.Field; -import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.function.Supplier; import static java.util.Optional.ofNullable; @@ -36,65 +34,57 @@ private boolean isDuplicateFilename(CaseDocument caseDocument, Supplier d.getDocumentFilename().equals(caseDocument.getDocumentFilename())); } - private boolean isDuplicatedFilenameInFinremCaseData(CaseDocument caseDocument, FinremCaseData caseData) { - return Arrays.stream(new BeanWrapperImpl(caseData.getClass()).getPropertyDescriptors()) - .filter(d -> CaseDocument.class.isAssignableFrom(d.getPropertyType())) - .anyMatch(pd -> - isDuplicateFilename(caseDocument, () -> { - try { - return List.of((CaseDocument) pd.getReadMethod().invoke(caseData)); - } catch (Exception e) { - log.error("Fail to invoke:" + pd.getReadMethod().getName()); - return null; - } - }) - ) || Arrays.stream(new BeanWrapperImpl(caseData.getClass()).getPropertyDescriptors()) - .filter(d -> CaseDocumentsDiscovery.class.isAssignableFrom(d.getPropertyType())) - .anyMatch(pd -> - isDuplicateFilename(caseDocument, () -> { - try { - return ((CaseDocumentsDiscovery) pd.getReadMethod().invoke(caseData)).discover(); - } catch (Exception e) { - log.error("Fail to invoke:" + pd.getReadMethod().getName()); - return null; - } - }) - ); - } - private static void processList(List list, List allDocuments) { - String methodName = "discover"; if (list != null) { for (Object item : list) { - try { - // Invoke the 'discover' method on each item in the list - Method discoverMethod = item.getClass().getMethod(methodName); - @SuppressWarnings("unchecked") - List documents = (List) discoverMethod.invoke(item); - allDocuments.addAll(documents); - } catch (Exception e) { - log.error("Fail to invoke " + methodName + "()", e); + if (item instanceof HasCaseDocument) { + processHasCaseDocument((HasCaseDocument) item, allDocuments); + } else { + log.warn("Ignored " + item.getClass().getName()); } } } } - @Override - public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails) - throws DocumentContentCheckerException { + private static void processHasCaseDocument(HasCaseDocument hcd, List allDocuments) { + if (hcd != null) { + try { + // Collect all fields from HasCaseDocument class + Field[] fields = hcd.getClass().getDeclaredFields(); - FinremCaseData caseData = beforeCaseDetails.getData(); - if (isDuplicatedFilenameInFinremCaseData(caseDocument, caseData)) { - return List.of(WARNING); + for (Field field : fields) { + field.setAccessible(true); + + // Check if the field is a List with a parameterized type + if (List.class.isAssignableFrom(field.getType())) { + ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType(); + Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); + + // Ensure the list has a single parameterized type argument + if (actualTypeArguments.length == 1 && HasCaseDocument.class.isAssignableFrom((Class) actualTypeArguments[0])) { + + // Get the value of the field and process the list + processList((List) field.get(hcd), allDocuments); + } + } else if (CaseDocument.class.isAssignableFrom(field.getType())) { + allDocuments.add((CaseDocument) field.get(hcd)); + } else if (HasCaseDocument.class.isAssignableFrom(field.getType())) { + processHasCaseDocument((HasCaseDocument) field.get(hcd), allDocuments); + } + } + } catch (Exception e) { + log.error("Failed to check for duplicate filenames and return warnings", e); + } } + } + private List collectCaseDocumentsFromFinremCaseData(FinremCaseData caseData) { + // List to collect all CaseDocument instances + List allDocuments = new ArrayList<>(); try { // Collect all fields from FinremCaseData class Field[] fields = FinremCaseData.class.getDeclaredFields(); - // List to collect all CaseDocument instances - List allDocuments = new ArrayList<>(); - for (Field field : fields) { field.setAccessible(true); @@ -104,26 +94,39 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); // Ensure the list has a single parameterized type argument - if (actualTypeArguments.length == 1 && CaseDocumentsDiscovery.class.isAssignableFrom((Class) actualTypeArguments[0])) { + if (actualTypeArguments.length == 1 && HasCaseDocument.class.isAssignableFrom((Class) actualTypeArguments[0])) { // Get the value of the field and process the list List list = (List) field.get(caseData); processList(list, allDocuments); } + } else if (CaseDocument.class.isAssignableFrom(field.getType())) { + allDocuments.add((CaseDocument) field.get(caseData)); + } else if (HasCaseDocument.class.isAssignableFrom(field.getType())) { + processHasCaseDocument((HasCaseDocument) field.get(caseData), allDocuments); } } + } catch (Exception e) { + log.error("Failed to check for duplicate filenames and return warnings", e); + } + return allDocuments.stream().filter(Objects::nonNull).toList(); + } + + @Override + public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails) + throws DocumentContentCheckerException { - log.info("Iterating all CaseDocuments with interface CaseDocumentsDiscovery."); + FinremCaseData caseData = beforeCaseDetails.getData(); + List allDocuments = collectCaseDocumentsFromFinremCaseData(caseData); - // Check for duplicate filenames in the collected documents - boolean hasDuplicates = allDocuments.stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d))); + log.info("Iterating all CaseDocuments with interface HasCaseDocument."); - if (hasDuplicates) { - return List.of(WARNING); - } - } catch (Exception e) { - log.error("Failed to check for duplicate filenames and return warnings", e); + // Check for duplicate filenames in the collected documents + boolean hasDuplicates = allDocuments.stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d))); + + if (hasDuplicates) { + return List.of(WARNING); } return Collections.emptyList(); From d3c27bb28492bfac19b43e76c7ff8acdb4ab94dc Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 28 Jun 2024 11:44:07 +0100 Subject: [PATCH 70/96] Checkstyle fix and add interface to GeneralEmailWrapper --- .../AdditionalHearingDocumentCollection.java | 1 + .../model/ccd/GeneralEmailCollection.java | 2 +- .../model/ccd/GeneralEmailHolder.java | 2 +- .../model/ccd/PaymentDocument.java | 2 +- .../ccd/wrapper/GeneralEmailWrapper.java | 3 +- .../DuplicateFilenameDocumentCheckerTest.java | 39 +++++++++++++++++++ 6 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocumentCollection.java index 98a9341c8f..192e2333a4 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/AdditionalHearingDocumentCollection.java @@ -5,6 +5,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; + @JsonIgnoreProperties(ignoreUnknown = true) @Data @Builder diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralEmailCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralEmailCollection.java index e172e9f7f3..e3e14d5202 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralEmailCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralEmailCollection.java @@ -11,6 +11,6 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class GeneralEmailCollection { +public class GeneralEmailCollection implements HasCaseDocument { private GeneralEmailHolder value; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralEmailHolder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralEmailHolder.java index b25b46b166..51da0776c9 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralEmailHolder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/GeneralEmailHolder.java @@ -13,7 +13,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class GeneralEmailHolder { +public class GeneralEmailHolder implements HasCaseDocument { private String generalEmailRecipient; private String generalEmailCreatedBy; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocument.java index afe5eadc86..6159f5e8cc 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/PaymentDocument.java @@ -11,7 +11,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class PaymentDocument implements HasCaseDocument{ +public class PaymentDocument implements HasCaseDocument { private PaymentDocumentType typeOfDocument; private CaseDocument uploadedDocument; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralEmailWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralEmailWrapper.java index 7fe9d98580..c88cc5dcac 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralEmailWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/GeneralEmailWrapper.java @@ -8,6 +8,7 @@ import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralEmailCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; import java.util.List; @@ -17,7 +18,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class GeneralEmailWrapper { +public class GeneralEmailWrapper implements HasCaseDocument { private String generalEmailRecipient; private String generalEmailCreatedBy; private String generalEmailBody; diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index 77174d1dbd..2d12c9ec75 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -25,6 +25,8 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralApplicationItems; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralEmailCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralEmailHolder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralLetter; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralLetterCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.GeneralOrder; @@ -61,6 +63,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.DraftDirectionWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralApplicationWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralApplicationsCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralEmailWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralLetterWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralOrderWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.InterimWrapper; @@ -1102,4 +1105,40 @@ void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterCollection_gen assertDuplicateFilenameWarning(warnings); } + + @Test + void testGetWarnings_duplicateInGeneralEmailWrapper_generalEmailUploadedDocument() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalEmailWrapper(GeneralEmailWrapper.builder() + .generalEmailUploadedDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInGeneralEmailWrapper_generalEmailCollection() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .generalEmailWrapper(GeneralEmailWrapper.builder() + .generalEmailCollection(List.of(GeneralEmailCollection.builder() + .value(GeneralEmailHolder.builder() + .generalEmailUploadedDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } } From eea6dbf397c9118822188b381873df4597a5deef Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 28 Jun 2024 12:16:41 +0100 Subject: [PATCH 71/96] Support Document as well. --- .../model/ccd/CaseDocument.java | 2 +- .../ccd/ConsentInContestedApprovedOrder.java | 2 +- ...entInContestedApprovedOrderCollection.java | 2 +- .../caseorchestration/model/ccd/Document.java | 7 +- .../model/ccd/DocumentFileNameProvider.java | 5 + .../model/ccd/UnapproveOrder.java | 2 +- .../model/ccd/UnapprovedOrderCollection.java | 2 +- .../model/ccd/UploadConsentOrder.java | 2 +- .../ccd/UploadConsentOrderCollection.java | 2 +- .../model/ccd/VariationDocumentType.java | 2 +- .../ccd/VariationDocumentTypeCollection.java | 2 +- .../ccd/wrapper/ConsentOrderWrapper.java | 3 +- .../DuplicateFilenameDocumentChecker.java | 25 +- .../DuplicateFilenameDocumentCheckerTest.java | 340 ++++++++++++++++++ 14 files changed, 375 insertions(+), 23 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DocumentFileNameProvider.java diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocument.java index 20bb53f7c7..28a3b24cd4 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocument.java @@ -16,7 +16,7 @@ @AllArgsConstructor @EqualsAndHashCode @JsonInclude(JsonInclude.Include.NON_NULL) -public class CaseDocument { +public class CaseDocument implements DocumentFileNameProvider { @JsonProperty("document_url") private String documentUrl; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentInContestedApprovedOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentInContestedApprovedOrder.java index 0aa807e3fc..b0becbbf95 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentInContestedApprovedOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentInContestedApprovedOrder.java @@ -17,7 +17,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class ConsentInContestedApprovedOrder { +public class ConsentInContestedApprovedOrder implements HasCaseDocument{ @JsonProperty("orderLetter") private CaseDocument orderLetter; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentInContestedApprovedOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentInContestedApprovedOrderCollection.java index 0a0681c857..d3e47dd897 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentInContestedApprovedOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentInContestedApprovedOrderCollection.java @@ -12,7 +12,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class ConsentInContestedApprovedOrderCollection { +public class ConsentInContestedApprovedOrderCollection implements HasCaseDocument { @JsonProperty("id") private String id; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/Document.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/Document.java index 0946762cfb..8a2151c639 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/Document.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/Document.java @@ -12,7 +12,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class Document { +public class Document implements DocumentFileNameProvider { @JsonProperty("document_url") private String url; @@ -20,4 +20,9 @@ public class Document { private String binaryUrl; @JsonProperty("document_filename") private String filename; + + @Override + public String getDocumentFilename() { + return filename; + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DocumentFileNameProvider.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DocumentFileNameProvider.java new file mode 100644 index 0000000000..06aa409965 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/DocumentFileNameProvider.java @@ -0,0 +1,5 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd; + +public interface DocumentFileNameProvider { + String getDocumentFilename(); +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UnapproveOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UnapproveOrder.java index 9b5f551a19..c69cb6fc6f 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UnapproveOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UnapproveOrder.java @@ -17,7 +17,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class UnapproveOrder { +public class UnapproveOrder implements HasCaseDocument { @JsonProperty("unapproveOrder") CaseDocument caseDocument; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UnapprovedOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UnapprovedOrderCollection.java index aaeca879f4..a48ea03d47 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UnapprovedOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UnapprovedOrderCollection.java @@ -12,7 +12,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class UnapprovedOrderCollection { +public class UnapprovedOrderCollection implements HasCaseDocument { @JsonProperty("id") private String id; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrder.java index 3f8b78a804..9eb2018a5d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrder.java @@ -19,7 +19,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class UploadConsentOrder { +public class UploadConsentOrder implements HasCaseDocument { @JsonProperty("DocumentType") private ConsentOrderType documentType; @JsonProperty("DocumentEmailContent") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderCollection.java index 918956b89e..4f3fa7d817 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/UploadConsentOrderCollection.java @@ -11,6 +11,6 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class UploadConsentOrderCollection { +public class UploadConsentOrderCollection implements HasCaseDocument { private UploadConsentOrder value; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/VariationDocumentType.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/VariationDocumentType.java index cd5c526b04..e47533e0ad 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/VariationDocumentType.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/VariationDocumentType.java @@ -13,7 +13,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class VariationDocumentType { +public class VariationDocumentType implements HasCaseDocument { private VariationTypeOfDocument typeOfDocument; private Document uploadedDocument; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/VariationDocumentTypeCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/VariationDocumentTypeCollection.java index 659e3530e2..d9f4f68326 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/VariationDocumentTypeCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/VariationDocumentTypeCollection.java @@ -15,7 +15,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class VariationDocumentTypeCollection { +public class VariationDocumentTypeCollection implements HasCaseDocument { private UUID id; private VariationDocumentType value; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/ConsentOrderWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/ConsentOrderWrapper.java index bc3e6824fe..449d5908d7 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/ConsentOrderWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/ConsentOrderWrapper.java @@ -16,6 +16,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConsentOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DraftDirectionDetailsCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DraftDirectionOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.NatureApplication; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OtherDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.PensionProvider; @@ -33,7 +34,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class ConsentOrderWrapper { +public class ConsentOrderWrapper implements HasCaseDocument { private DraftDirectionOrder latestDraftDirectionOrder; private List draftDirectionDetailsCollection; private List draftDirectionDetailsCollectionRO; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index 0b74cdbe81..a8fd066d57 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -3,6 +3,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DocumentFileNameProvider; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; @@ -29,16 +30,16 @@ public boolean canCheck(CaseDocument caseDocument) { return true; } - private boolean isDuplicateFilename(CaseDocument caseDocument, Supplier> caseDocumentSupplier) { + private boolean isDuplicateFilename(CaseDocument caseDocument, Supplier> caseDocumentSupplier) { return ofNullable(caseDocumentSupplier.get()).orElse(List.of(CaseDocument.builder().documentFilename("").build())) .stream().anyMatch(d -> d.getDocumentFilename().equals(caseDocument.getDocumentFilename())); } - private static void processList(List list, List allDocuments) { + private static void processList(List list, List allDocuments) { if (list != null) { for (Object item : list) { - if (item instanceof HasCaseDocument) { - processHasCaseDocument((HasCaseDocument) item, allDocuments); + if (item instanceof HasCaseDocument hasCaseDocument) { + processHasCaseDocument(hasCaseDocument, allDocuments); } else { log.warn("Ignored " + item.getClass().getName()); } @@ -46,7 +47,7 @@ private static void processList(List list, List allDocuments) { } } - private static void processHasCaseDocument(HasCaseDocument hcd, List allDocuments) { + private static void processHasCaseDocument(HasCaseDocument hcd, List allDocuments) { if (hcd != null) { try { // Collect all fields from HasCaseDocument class @@ -66,8 +67,8 @@ private static void processHasCaseDocument(HasCaseDocument hcd, List) field.get(hcd), allDocuments); } - } else if (CaseDocument.class.isAssignableFrom(field.getType())) { - allDocuments.add((CaseDocument) field.get(hcd)); + } else if (DocumentFileNameProvider.class.isAssignableFrom(field.getType())) { + allDocuments.add((DocumentFileNameProvider) field.get(hcd)); } else if (HasCaseDocument.class.isAssignableFrom(field.getType())) { processHasCaseDocument((HasCaseDocument) field.get(hcd), allDocuments); } @@ -78,9 +79,9 @@ private static void processHasCaseDocument(HasCaseDocument hcd, List collectCaseDocumentsFromFinremCaseData(FinremCaseData caseData) { + private List collectCaseDocumentsFromFinremCaseData(FinremCaseData caseData) { // List to collect all CaseDocument instances - List allDocuments = new ArrayList<>(); + List allDocuments = new ArrayList<>(); try { // Collect all fields from FinremCaseData class Field[] fields = FinremCaseData.class.getDeclaredFields(); @@ -100,8 +101,8 @@ private List collectCaseDocumentsFromFinremCaseData(FinremCaseData List list = (List) field.get(caseData); processList(list, allDocuments); } - } else if (CaseDocument.class.isAssignableFrom(field.getType())) { - allDocuments.add((CaseDocument) field.get(caseData)); + } else if (DocumentFileNameProvider.class.isAssignableFrom(field.getType())) { + allDocuments.add((DocumentFileNameProvider) field.get(caseData)); } else if (HasCaseDocument.class.isAssignableFrom(field.getType())) { processHasCaseDocument((HasCaseDocument) field.get(caseData), allDocuments); } @@ -117,7 +118,7 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC throws DocumentContentCheckerException { FinremCaseData caseData = beforeCaseDetails.getData(); - List allDocuments = collectCaseDocumentsFromFinremCaseData(caseData); + List allDocuments = collectCaseDocumentsFromFinremCaseData(caseData); log.info("Iterating all CaseDocuments with interface HasCaseDocument."); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index 2d12c9ec75..41db737924 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -14,11 +14,14 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApprovedOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConfidentialUploadedDocumentData; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConsentInContestedApprovedOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConsentInContestedApprovedOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConsentOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DirectionOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DirectionOrderCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.Document; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DraftDirectionOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DraftDirectionOrderCollection; @@ -47,11 +50,15 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.RespondToOrderDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ScannedDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ScannedDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UnapproveOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UnapprovedOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadAdditionalDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadAdditionalDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadCaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadCaseDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConfidentialDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConsentOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConsentOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConsentOrderDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadConsentOrderDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocument; @@ -60,6 +67,9 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadOrderCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.VariationDocumentType; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.VariationDocumentTypeCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ConsentOrderWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.DraftDirectionWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralApplicationWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralApplicationsCollection; @@ -83,6 +93,8 @@ class DuplicateFilenameDocumentCheckerTest { private static final CaseDocument DUPLICATED_CASE_DOCUMENT = CaseDocument.builder().documentFilename(DUPLICATED_FILENAME).build(); + private static final Document DUPLICATED_DOCUMENT = Document.builder().filename(DUPLICATED_FILENAME).build(); + @InjectMocks private DuplicateFilenameDocumentChecker underTest; @@ -1141,4 +1153,332 @@ void testGetWarnings_duplicateInGeneralEmailWrapper_generalEmailCollection() assertDuplicateFilenameWarning(warnings); } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_consentD81Joint() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentD81Joint(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_consentD81Applicant() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentD81Applicant(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_consentD81Respondent() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentD81Respondent(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_consentMiniFormA() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentMiniFormA(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_uploadApprovedConsentOrder() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .uploadApprovedConsentOrder(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_latestDraftDirectionOrder() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .latestDraftDirectionOrder(DraftDirectionOrder.builder() + .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_consentOtherCollection() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentOtherCollection(List.of(OtherDocumentCollection.builder() + .value(OtherDocument.builder() + .uploadedDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_consentedNotApprovedOrders_consentOrder() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentedNotApprovedOrders(List.of(ConsentOrderCollection.builder() + .approvedOrder(ApprovedOrder.builder() + .consentOrder(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_consentedNotApprovedOrders_orderLetter() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentedNotApprovedOrders(List.of(ConsentOrderCollection.builder() + .approvedOrder(ApprovedOrder.builder() + .orderLetter(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_consentedNotApprovedOrders_pensionDocuments() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentedNotApprovedOrders(List.of(ConsentOrderCollection.builder() + .approvedOrder(ApprovedOrder.builder() + .pensionDocuments(List.of(PensionTypeCollection.builder() + .typedCaseDocument(PensionType.builder() + .pensionDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_uploadConsentOrder() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .uploadConsentOrder(List.of(UploadConsentOrderCollection.builder() + .value(UploadConsentOrder.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_otherVariationCollection() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .otherVariationCollection(List.of(VariationDocumentTypeCollection.builder() + .value(VariationDocumentType.builder() + .uploadedDocument(DUPLICATED_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_appConsentApprovedOrders_orderLetter() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .appConsentApprovedOrders(List.of(ConsentInContestedApprovedOrderCollection.builder() + .approvedOrder(ConsentInContestedApprovedOrder.builder() + .orderLetter(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_appConsentApprovedOrders_consentOrder() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .appConsentApprovedOrders(List.of(ConsentInContestedApprovedOrderCollection.builder() + .approvedOrder(ConsentInContestedApprovedOrder.builder() + .consentOrder(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_appConsentApprovedOrders_pensionDocuments() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .appConsentApprovedOrders(List.of(ConsentInContestedApprovedOrderCollection.builder() + .approvedOrder(ConsentInContestedApprovedOrder.builder() + .pensionDocuments(List.of(PensionTypeCollection.builder() + .typedCaseDocument(PensionType.builder() + .pensionDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_appConsentApprovedOrders_additionalConsentDocuments() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .appConsentApprovedOrders(List.of(ConsentInContestedApprovedOrderCollection.builder() + .approvedOrder(ConsentInContestedApprovedOrder.builder() + .additionalConsentDocuments(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarnings_duplicateInConsentOrderWrapper_appRefusedOrderCollection() + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .appRefusedOrderCollection(List.of(UnapprovedOrderCollection.builder() + .value(UnapproveOrder.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()) + .build(), + FinremCaseDetails.builder().build()); + + assertDuplicateFilenameWarning(warnings); + } } From f0f8ce554169ad7282187029b5066146423a8154 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 28 Jun 2024 13:05:49 +0100 Subject: [PATCH 72/96] update test cases --- .../model/ccd/ApproveOrder.java | 2 +- .../model/ccd/ApproveOrdersHolder.java | 2 +- .../model/ccd/ApprovedOrderCollection.java | 2 +- .../ApprovedOrderConsolidateCollection.java | 2 +- .../ccd/ConsentInContestedApprovedOrder.java | 2 +- .../ccd/ConsentedHearingDataElement.java | 2 +- .../ccd/ConsentedHearingDataWrapper.java | 2 +- .../model/ccd/ManageScannedDocument.java | 2 +- .../ccd/ManageScannedDocumentCollection.java | 2 +- .../ccd/OrderSentToPartiesCollection.java | 2 +- .../model/ccd/SendOrderDocuments.java | 2 +- .../model/ccd/wrapper/OrderWrapper.java | 3 +- .../DuplicateFilenameDocumentCheckerTest.java | 1927 ++++++----------- 13 files changed, 684 insertions(+), 1268 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApproveOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApproveOrder.java index 53ff4bd098..549b95e45b 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApproveOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApproveOrder.java @@ -16,7 +16,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class ApproveOrder { +public class ApproveOrder implements HasCaseDocument { @JsonProperty("approveOrder") CaseDocument caseDocument; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApproveOrdersHolder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApproveOrdersHolder.java index 0ad0b5af03..c7ef041053 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApproveOrdersHolder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApproveOrdersHolder.java @@ -18,7 +18,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class ApproveOrdersHolder { +public class ApproveOrdersHolder implements HasCaseDocument { @JsonSerialize(using = LocalDateTimeSerializer.class) private LocalDateTime orderReceivedAt; private List approveOrders; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApprovedOrderCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApprovedOrderCollection.java index 1a4a9106fb..98503420c8 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApprovedOrderCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApprovedOrderCollection.java @@ -12,7 +12,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class ApprovedOrderCollection { +public class ApprovedOrderCollection implements HasCaseDocument { @JsonProperty("id") private String id; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApprovedOrderConsolidateCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApprovedOrderConsolidateCollection.java index 66a8036c85..0f7c87e398 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApprovedOrderConsolidateCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ApprovedOrderConsolidateCollection.java @@ -11,7 +11,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class ApprovedOrderConsolidateCollection { +public class ApprovedOrderConsolidateCollection implements HasCaseDocument { private ApproveOrdersHolder value; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentInContestedApprovedOrder.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentInContestedApprovedOrder.java index b0becbbf95..92ef00c35b 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentInContestedApprovedOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentInContestedApprovedOrder.java @@ -17,7 +17,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class ConsentInContestedApprovedOrder implements HasCaseDocument{ +public class ConsentInContestedApprovedOrder implements HasCaseDocument { @JsonProperty("orderLetter") private CaseDocument orderLetter; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentedHearingDataElement.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentedHearingDataElement.java index b7954587e9..0af7ebb29b 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentedHearingDataElement.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentedHearingDataElement.java @@ -14,7 +14,7 @@ @NoArgsConstructor @AllArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class ConsentedHearingDataElement { +public class ConsentedHearingDataElement implements HasCaseDocument { @JsonProperty("hearingType") public String hearingType; @JsonProperty("hearingTimeEstimate") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentedHearingDataWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentedHearingDataWrapper.java index fa2a387558..02ad0c0dbd 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentedHearingDataWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ConsentedHearingDataWrapper.java @@ -12,7 +12,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class ConsentedHearingDataWrapper { +public class ConsentedHearingDataWrapper implements HasCaseDocument { @JsonProperty("id") private String id; @JsonProperty("value") diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ManageScannedDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ManageScannedDocument.java index 16aafce6ab..8de0b7d146 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ManageScannedDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ManageScannedDocument.java @@ -14,7 +14,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class ManageScannedDocument { +public class ManageScannedDocument implements HasCaseDocument { private YesOrNo selectForUpdate; @JsonUnwrapped diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ManageScannedDocumentCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ManageScannedDocumentCollection.java index 1d46731ba2..7171119c80 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ManageScannedDocumentCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/ManageScannedDocumentCollection.java @@ -14,7 +14,7 @@ @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode -public class ManageScannedDocumentCollection { +public class ManageScannedDocumentCollection implements HasCaseDocument { private String id; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderSentToPartiesCollection.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderSentToPartiesCollection.java index fad0d0b757..f4deaf721f 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderSentToPartiesCollection.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/OrderSentToPartiesCollection.java @@ -12,7 +12,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class OrderSentToPartiesCollection { +public class OrderSentToPartiesCollection implements HasCaseDocument { @JsonProperty("id") private String id; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/SendOrderDocuments.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/SendOrderDocuments.java index c0e6cd1129..d6a3a8e95d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/SendOrderDocuments.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/SendOrderDocuments.java @@ -12,7 +12,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class SendOrderDocuments { +public class SendOrderDocuments implements HasCaseDocument { @JsonProperty("bulkPrintDocument") CaseDocument caseDocument; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/OrderWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/OrderWrapper.java index 1f02bb6634..3efddc5057 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/OrderWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/OrderWrapper.java @@ -8,6 +8,7 @@ import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApprovedOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApprovedOrderConsolidateCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; import java.util.List; @@ -17,7 +18,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class OrderWrapper { +public class OrderWrapper implements HasCaseDocument { private List appOrderCollections; private List respOrderCollections; private List intv1OrderCollections; diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index 41db737924..5163ebb0af 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -3,6 +3,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; @@ -11,12 +14,18 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AdditionalHearingDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AmendedConsentOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AmendedConsentOrderCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApproveOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApproveOrdersHolder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApprovedOrder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApprovedOrderCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApprovedOrderConsolidateCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConfidentialUploadedDocumentData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConsentInContestedApprovedOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConsentInContestedApprovedOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConsentOrderCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConsentedHearingDataElement; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConsentedHearingDataWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ContestedGeneralOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DirectionOrder; @@ -38,8 +47,11 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.InterimHearingBulkPrintDocumentsData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.IntervenerHearingNotice; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.IntervenerHearingNoticeCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ManageScannedDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ManageScannedDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OrderRefusalCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OrderRefusalHolder; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OrderSentToPartiesCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OtherDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.OtherDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.PensionType; @@ -50,6 +62,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.RespondToOrderDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ScannedDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ScannedDocumentCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.SendOrderDocuments; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UnapproveOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UnapprovedOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadAdditionalDocument; @@ -77,9 +90,11 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralLetterWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralOrderWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.InterimWrapper; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.OrderWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.UploadCaseDocumentWrapper; import java.util.List; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; @@ -130,332 +145,487 @@ void testGetWarnings_NoDuplicate() throws DocumentContentCheckerException { assertThat(warnings).isEmpty(); } - @Test - void testGetWarnings_duplicateInGeneralOrderWrapper_generalOrderLatestDocument() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalOrderWrapper(GeneralOrderWrapper.builder() - .generalOrderLatestDocument(DUPLICATED_CASE_DOCUMENT) - .build()) + private static Stream testGetWarningsOnExistingCase() { + return Stream.of( + Arguments.of(FinremCaseData.builder() + .generalOrderWrapper(GeneralOrderWrapper.builder() + .generalOrderLatestDocument(DUPLICATED_CASE_DOCUMENT) .build()) - .build(), - FinremCaseDetails.builder().build()); - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralOrderWrapper_generalOrderPreviewDocument() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalOrderWrapper(GeneralOrderWrapper.builder() - .generalOrderPreviewDocument(DUPLICATED_CASE_DOCUMENT) - .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .generalOrderWrapper(GeneralOrderWrapper.builder() + .generalOrderPreviewDocument(DUPLICATED_CASE_DOCUMENT) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralOrderWrapper_generalOrders() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalOrderWrapper(GeneralOrderWrapper.builder() - .generalOrders(List.of(ContestedGeneralOrderCollection.builder() - .value(ContestedGeneralOrder.builder() - .additionalDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .generalOrderWrapper(GeneralOrderWrapper.builder() + .generalOrders(List.of(ContestedGeneralOrderCollection.builder() + .value(ContestedGeneralOrder.builder() + .additionalDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralOrderWrapper_generalOrdersConsent() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalOrderWrapper(GeneralOrderWrapper.builder() - .generalOrdersConsent(List.of(ContestedGeneralOrderCollection.builder() - .value(ContestedGeneralOrder.builder() - .additionalDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .generalOrderWrapper(GeneralOrderWrapper.builder() + .generalOrdersConsent(List.of(ContestedGeneralOrderCollection.builder() + .value(ContestedGeneralOrder.builder() + .additionalDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralOrderWrapper_generalOrderCollection() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalOrderWrapper(GeneralOrderWrapper.builder() - .generalOrderCollection(List.of(GeneralOrderCollectionItem.builder() - .generalOrder(GeneralOrder.builder() - .generalOrderDocumentUpload(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .generalOrderWrapper(GeneralOrderWrapper.builder() + .generalOrderCollection(List.of(GeneralOrderCollectionItem.builder() + .generalOrder(GeneralOrder.builder() + .generalOrderDocumentUpload(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .pensionCollection(List.of(PensionTypeCollection.builder() + .typedCaseDocument(PensionType.builder() + .pensionDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .otherDocumentsCollection(List.of(OtherDocumentCollection.builder() + .value(OtherDocument.builder() + .uploadedDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .additionalCicDocuments(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .orderRefusalCollection(List.of(OrderRefusalCollection.builder() + .value(OrderRefusalHolder.builder() + .orderRefusalDocs(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .orderRefusalCollectionNew(List.of(OrderRefusalCollection.builder() + .value(OrderRefusalHolder.builder() + .orderRefusalDocs(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .orderRefusalOnScreen(OrderRefusalHolder.builder() + .orderRefusalDocs(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .uploadConsentOrderDocuments(List.of(UploadConsentOrderDocumentCollection.builder() + .value(UploadConsentOrderDocument.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .uploadOrder(List.of(UploadOrderCollection.builder() + .value(UploadOrder.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .uploadDocuments(List.of(UploadDocumentCollection.builder() + .value(UploadDocument.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .approvedOrderCollection(List.of(ConsentOrderCollection.builder() + .approvedOrder(ApprovedOrder.builder() + .orderLetter(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .respondToOrderDocuments(List.of(RespondToOrderDocumentCollection.builder() + .value(RespondToOrderDocument.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .amendedConsentOrderCollection(List.of(AmendedConsentOrderCollection.builder() + .value(AmendedConsentOrder.builder() + .amendedConsentOrder(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .scannedDocuments(List.of(ScannedDocumentCollection.builder() + .value(ScannedDocument.builder() + .url(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .approvedOrderCollection(List.of(ConsentOrderCollection.builder() + .approvedOrder(ApprovedOrder.builder() + .consentOrder(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .approvedOrderCollection(List.of(ConsentOrderCollection.builder() + .approvedOrder(ApprovedOrder.builder() + .pensionDocuments(List.of(PensionTypeCollection.builder() + .typedCaseDocument(PensionType.builder() + .pensionDocument(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .scannedD81s(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .additionalHearingDocuments(List.of(AdditionalHearingDocumentCollection.builder() + .value(AdditionalHearingDocument.builder() + .document(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .hearingNoticeDocumentPack(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .hearingNoticesDocumentCollection(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .uploadGeneralDocuments(List.of(UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .uploadHearingOrder(List.of(DirectionOrderCollection.builder() + .value(DirectionOrder.builder() + .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .hearingOrderOtherDocuments(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .intv1HearingNoticesCollection(List.of(IntervenerHearingNoticeCollection.builder() + .value(IntervenerHearingNotice.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .intv2HearingNoticesCollection(List.of(IntervenerHearingNoticeCollection.builder() + .value(IntervenerHearingNotice.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .intv3HearingNoticesCollection(List.of(IntervenerHearingNoticeCollection.builder() + .value(IntervenerHearingNotice.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .intv4HearingNoticesCollection(List.of(IntervenerHearingNoticeCollection.builder() + .value(IntervenerHearingNotice.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .refusalOrderCollection(List.of(RefusalOrderCollection.builder() + .value(RefusalOrder.builder() + .refusalOrderAdditionalDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .uploadAdditionalDocument(List.of(UploadAdditionalDocumentCollection.builder() + .value(UploadAdditionalDocument.builder() + .additionalDocuments(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .confidentialDocumentsUploaded(List.of(ConfidentialUploadedDocumentData.builder() + .value(UploadConfidentialDocument.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .manageCaseDocumentCollection(List.of(UploadCaseDocumentCollection.builder() + .uploadCaseDocument(UploadCaseDocument.builder() + .caseDocuments(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .uploadCaseDocumentWrapper(UploadCaseDocumentWrapper.builder() + .uploadCaseDocument(List.of(UploadCaseDocumentCollection.builder() + .uploadCaseDocument(UploadCaseDocument.builder() + .caseDocuments(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInPensionCollection() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .pensionCollection(List.of(PensionTypeCollection.builder() - .typedCaseDocument(PensionType.builder() - .pensionDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .uploadCaseDocumentWrapper(UploadCaseDocumentWrapper.builder() + .intv3QaShared(List.of(UploadCaseDocumentCollection.builder() + .uploadCaseDocument(UploadCaseDocument.builder() + .caseDocuments(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInOtherDocumentsCollection() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .otherDocumentsCollection(List.of(OtherDocumentCollection.builder() - .value(OtherDocument.builder() - .uploadedDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationDirectionsDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationLatestDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationDraftOrder(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationIntvrOrders(List.of(GeneralApplicationsCollection.builder() + .value(GeneralApplicationItems.builder() + .generalApplicationDirectionsDocument(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInAdditionalCicDocuments() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .additionalCicDocuments(List.of(DocumentCollection.builder() - .value(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationIntvrOrders(List.of(GeneralApplicationsCollection.builder() + .value(GeneralApplicationItems.builder() + .generalApplicationDraftOrder(DUPLICATED_CASE_DOCUMENT) + .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInOrderRefusalCollection() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .orderRefusalCollection(List.of(OrderRefusalCollection.builder() - .value(OrderRefusalHolder.builder() - .orderRefusalDocs(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplicationIntvrOrders(List.of(GeneralApplicationsCollection.builder() + .value(GeneralApplicationItems.builder() + .generalApplicationDocument(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInOrderRefusalCollectionNew() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .orderRefusalCollectionNew(List.of(OrderRefusalCollection.builder() - .value(OrderRefusalHolder.builder() - .orderRefusalDocs(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .generalApplicationWrapper(GeneralApplicationWrapper.builder() + .generalApplications(List.of(GeneralApplicationsCollection.builder() + .value(GeneralApplicationItems.builder() + .generalApplicationDocument(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInOrderRefusalOnScreen() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .orderRefusalOnScreen(OrderRefusalHolder.builder() - .orderRefusalDocs(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .interimWrapper(InterimWrapper.builder() + .interimUploadAdditionalDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .interimWrapper(InterimWrapper.builder() + .interimHearingDirectionsDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .interimWrapper(InterimWrapper.builder() + .interimHearingDocuments(List.of(InterimHearingBulkPrintDocumentsData.builder() + .value(InterimHearingBulkPrintDocument.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .draftDirectionWrapper(DraftDirectionWrapper.builder() + .draftDirectionOrderCollection(List.of(DraftDirectionOrderCollection.builder() + .value(DraftDirectionOrder.builder() + .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .draftDirectionWrapper(DraftDirectionWrapper.builder() + .latestDraftDirectionOrder(DraftDirectionOrder.builder() + .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) .build()) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInUploadConsentOrderDocuments() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .uploadConsentOrderDocuments(List.of(UploadConsentOrderDocumentCollection.builder() - .value(UploadConsentOrderDocument.builder() - .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .draftDirectionWrapper(DraftDirectionWrapper.builder() + .judgesAmendedOrderCollection(List.of(DraftDirectionOrderCollection.builder() + .value(DraftDirectionOrder.builder() + .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInUploadOrder() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .uploadOrder(List.of(UploadOrderCollection.builder() - .value(UploadOrder.builder() - .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .generalLetterWrapper(GeneralLetterWrapper.builder() + .generalLetterPreview(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .generalLetterWrapper(GeneralLetterWrapper.builder() + .generalLetterUploadedDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .generalLetterWrapper(GeneralLetterWrapper.builder() + .generalLetterUploadedDocuments(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .generalLetterWrapper(GeneralLetterWrapper.builder() + .generalLetterCollection(List.of(GeneralLetterCollection.builder() + .value(GeneralLetter.builder() + .generatedLetter(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInUploadDocuments() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .uploadDocuments(List.of(UploadDocumentCollection.builder() - .value(UploadDocument.builder() - .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .generalLetterWrapper(GeneralLetterWrapper.builder() + .generalLetterCollection(List.of(GeneralLetterCollection.builder() + .value(GeneralLetter.builder() + .generalLetterUploadedDocument(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInRespondToOrderDocuments() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .respondToOrderDocuments(List.of(RespondToOrderDocumentCollection.builder() - .value(RespondToOrderDocument.builder() - .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .generalLetterWrapper(GeneralLetterWrapper.builder() + .generalLetterCollection(List.of(GeneralLetterCollection.builder() + .value(GeneralLetter.builder() + .generalLetterUploadedDocuments(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInAmendedConsentOrderCollection() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .amendedConsentOrderCollection(List.of(AmendedConsentOrderCollection.builder() - .value(AmendedConsentOrder.builder() - .amendedConsentOrder(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .generalEmailWrapper(GeneralEmailWrapper.builder() + .generalEmailUploadedDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .generalEmailWrapper(GeneralEmailWrapper.builder() + .generalEmailCollection(List.of(GeneralEmailCollection.builder() + .value(GeneralEmailHolder.builder() + .generalEmailUploadedDocument(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInScannedDocuments() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .scannedDocuments(List.of(ScannedDocumentCollection.builder() - .value(ScannedDocument.builder() - .url(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentD81Joint(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentD81Applicant(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentD81Respondent(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentMiniFormA(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .uploadApprovedConsentOrder(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .latestDraftDirectionOrder(DraftDirectionOrder.builder() + .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build()) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentOtherCollection(List.of(OtherDocumentCollection.builder() + .value(OtherDocument.builder() + .uploadedDocument(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInApprovedOrderCollection_orderLetter() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .approvedOrderCollection(List.of(ConsentOrderCollection.builder() + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentedNotApprovedOrders(List.of(ConsentOrderCollection.builder() .approvedOrder(ApprovedOrder.builder() - .orderLetter(DUPLICATED_CASE_DOCUMENT) + .consentOrder(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInApprovedOrderCollection_consentOrder() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .approvedOrderCollection(List.of(ConsentOrderCollection.builder() + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentedNotApprovedOrders(List.of(ConsentOrderCollection.builder() .approvedOrder(ApprovedOrder.builder() - .consentOrder(DUPLICATED_CASE_DOCUMENT) + .orderLetter(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInApprovedOrderCollection_pensionDocuments() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .approvedOrderCollection(List.of(ConsentOrderCollection.builder() + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .consentedNotApprovedOrders(List.of(ConsentOrderCollection.builder() .approvedOrder(ApprovedOrder.builder() .pensionDocuments(List.of(PensionTypeCollection.builder() .typedCaseDocument(PensionType.builder() @@ -465,1020 +635,265 @@ void testGetWarnings_duplicateInApprovedOrderCollection_pensionDocuments() throw .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInScannedD81s() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .scannedD81s(List.of(DocumentCollection.builder() - .value(DUPLICATED_CASE_DOCUMENT) - .build())) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInAdditionalHearingDocuments() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .additionalHearingDocuments(List.of(AdditionalHearingDocumentCollection.builder() - .value(AdditionalHearingDocument.builder() - .document(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInHearingNoticeDocumentPack() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .hearingNoticeDocumentPack(List.of(DocumentCollection.builder() - .value(DUPLICATED_CASE_DOCUMENT) - .build())) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInHearingNoticesDocumentCollection() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .hearingNoticesDocumentCollection(List.of(DocumentCollection.builder() - .value(DUPLICATED_CASE_DOCUMENT) - .build())) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInUploadGeneralDocuments() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .uploadGeneralDocuments(List.of(UploadGeneralDocumentCollection.builder() - .value(UploadGeneralDocument.builder() + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .uploadConsentOrder(List.of(UploadConsentOrderCollection.builder() + .value(UploadConsentOrder.builder() .documentLink(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInUploadHearingOrder() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .uploadHearingOrder(List.of(DirectionOrderCollection.builder() - .value(DirectionOrder.builder() - .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .otherVariationCollection(List.of(VariationDocumentTypeCollection.builder() + .value(VariationDocumentType.builder() + .uploadedDocument(DUPLICATED_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInHearingOrderOtherDocuments() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .hearingOrderOtherDocuments(List.of(DocumentCollection.builder() - .value(DUPLICATED_CASE_DOCUMENT) - .build())) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInIntv1HearingNoticesCollection() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .intv1HearingNoticesCollection(List.of(IntervenerHearingNoticeCollection.builder() - .value(IntervenerHearingNotice.builder() - .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .appConsentApprovedOrders(List.of(ConsentInContestedApprovedOrderCollection.builder() + .approvedOrder(ConsentInContestedApprovedOrder.builder() + .orderLetter(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInIntv2HearingNoticesCollection() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .intv2HearingNoticesCollection(List.of(IntervenerHearingNoticeCollection.builder() - .value(IntervenerHearingNotice.builder() - .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .appConsentApprovedOrders(List.of(ConsentInContestedApprovedOrderCollection.builder() + .approvedOrder(ConsentInContestedApprovedOrder.builder() + .consentOrder(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInIntv3HearingNoticesCollection() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .intv3HearingNoticesCollection(List.of(IntervenerHearingNoticeCollection.builder() - .value(IntervenerHearingNotice.builder() - .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .appConsentApprovedOrders(List.of(ConsentInContestedApprovedOrderCollection.builder() + .approvedOrder(ConsentInContestedApprovedOrder.builder() + .pensionDocuments(List.of(PensionTypeCollection.builder() + .typedCaseDocument(PensionType.builder() + .pensionDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInIntv4HearingNoticesCollection() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .intv4HearingNoticesCollection(List.of(IntervenerHearingNoticeCollection.builder() - .value(IntervenerHearingNotice.builder() - .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .appConsentApprovedOrders(List.of(ConsentInContestedApprovedOrderCollection.builder() + .approvedOrder(ConsentInContestedApprovedOrder.builder() + .additionalConsentDocuments(List.of(DocumentCollection.builder() + .value(DUPLICATED_CASE_DOCUMENT) + .build())) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInRefusalOrderCollection() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .refusalOrderCollection(List.of(RefusalOrderCollection.builder() - .value(RefusalOrder.builder() - .refusalOrderAdditionalDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderWrapper(ConsentOrderWrapper.builder() + .appRefusedOrderCollection(List.of(UnapprovedOrderCollection.builder() + .value(UnapproveOrder.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInUploadAdditionalDocument() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .uploadAdditionalDocument(List.of(UploadAdditionalDocumentCollection.builder() - .value(UploadAdditionalDocument.builder() - .additionalDocuments(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .orderWrapper(OrderWrapper.builder() + .appOrderCollections(List.of(ApprovedOrderConsolidateCollection.builder() + .value(ApproveOrdersHolder.builder() + .approveOrders(List.of(ApprovedOrderCollection.builder() + .value(ApproveOrder.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInCconfidentialDocumentsUploaded() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .confidentialDocumentsUploaded(List.of(ConfidentialUploadedDocumentData.builder() - .value(UploadConfidentialDocument.builder() - .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .orderWrapper(OrderWrapper.builder() + .appOrderCollection(List.of(ApprovedOrderCollection.builder() + .value(ApproveOrder.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) .build()) .build())) .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInManageCaseDocumentCollection() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .manageCaseDocumentCollection(List.of(UploadCaseDocumentCollection.builder() + .build()), + Arguments.of(FinremCaseData.builder() + .applicantScanDocuments(List.of(ScannedDocumentCollection.builder() + .value(ScannedDocument.builder() + .url(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .respondentScanDocuments(List.of(ScannedDocumentCollection.builder() + .value(ScannedDocument.builder() + .url(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .manageScannedDocumentCollection(List.of(ManageScannedDocumentCollection.builder() + .manageScannedDocument(ManageScannedDocument.builder() .uploadCaseDocument(UploadCaseDocument.builder() .caseDocuments(DUPLICATED_CASE_DOCUMENT) .build()) - .build())) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInUploadCaseDocumentWrapper_uploadCaseDocument() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .uploadCaseDocumentWrapper(UploadCaseDocumentWrapper.builder() - .uploadCaseDocument(List.of(UploadCaseDocumentCollection.builder() - .uploadCaseDocument(UploadCaseDocument.builder() - .caseDocuments(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInUploadCaseDocumentWrapper_intv3QaShared() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .uploadCaseDocumentWrapper(UploadCaseDocumentWrapper.builder() - .intv3QaShared(List.of(UploadCaseDocumentCollection.builder() - .uploadCaseDocument(UploadCaseDocument.builder() - .caseDocuments(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationDirectionsDocument() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalApplicationWrapper(GeneralApplicationWrapper.builder() - .generalApplicationDirectionsDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationDocument() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalApplicationWrapper(GeneralApplicationWrapper.builder() - .generalApplicationDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationLatestDocument() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalApplicationWrapper(GeneralApplicationWrapper.builder() - .generalApplicationLatestDocument(DUPLICATED_CASE_DOCUMENT) .build()) - .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .ordersSentToPartiesCollection(List.of(OrderSentToPartiesCollection.builder() + .value(SendOrderDocuments.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .listForHearings(List.of(ConsentedHearingDataWrapper.builder() + .value(ConsentedHearingDataElement.builder() + .hearingNotice(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .listForHearings(List.of(ConsentedHearingDataWrapper.builder() + .value(ConsentedHearingDataElement.builder() + .uploadAdditionalDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + .build())) + .build()), + Arguments.of(FinremCaseData.builder() + .divorceUploadEvidence1(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .d11(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .divorceUploadEvidence2(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .miniFormA(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrder(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .consentOrderText(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .latestConsentOrder(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .d81Joint(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .d81Applicant(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .d81Respondent(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .orderDirectionOpt1(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .additionalDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .orderRefusalPreviewDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .approvedConsentOrderLetter(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .bulkPrintCoverSheetApp(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .bulkPrintCoverSheetRes(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .bulkPrintCoverSheetIntv1(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .bulkPrintCoverSheetIntv2(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .bulkPrintCoverSheetIntv3(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .bulkPrintCoverSheetIntv4(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .formA(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .bulkPrintCoverSheetAppConfidential(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .bulkPrintCoverSheetResConfidential(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .divorceUploadPetition(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .uploadMediatorDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .uploadMediatorDocumentPaperCase(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .formC(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .formG(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .refusalOrderPreviewDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .latestRefusalOrder(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .refusalOrderAdditionalDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .latestDraftHearingOrder(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .orderApprovedCoverLetter(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .outOfFamilyCourtResolution(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .additionalListOfHearingDocuments(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .variationOrderDocument(DUPLICATED_CASE_DOCUMENT) + .build()), + Arguments.of(FinremCaseData.builder() + .consentVariationOrderDocument(DUPLICATED_CASE_DOCUMENT) + .build()) + ); + } + + @ParameterizedTest + @MethodSource + void testGetWarningsOnExistingCase(FinremCaseData caseData) + throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetails.builder() + .data(caseData) .build(), FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationDraftOrder() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalApplicationWrapper(GeneralApplicationWrapper.builder() - .generalApplicationDraftOrder(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationIntvrOrders_generalApplicationDirectionsDocument() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalApplicationWrapper(GeneralApplicationWrapper.builder() - .generalApplicationIntvrOrders(List.of(GeneralApplicationsCollection.builder() - .value(GeneralApplicationItems.builder() - .generalApplicationDirectionsDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationIntvrOrders_generalApplicationDraftOrder() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalApplicationWrapper(GeneralApplicationWrapper.builder() - .generalApplicationIntvrOrders(List.of(GeneralApplicationsCollection.builder() - .value(GeneralApplicationItems.builder() - .generalApplicationDraftOrder(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplicationIntvrOrders_generalApplicationDocument() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalApplicationWrapper(GeneralApplicationWrapper.builder() - .generalApplicationIntvrOrders(List.of(GeneralApplicationsCollection.builder() - .value(GeneralApplicationItems.builder() - .generalApplicationDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralApplicationWrapper_generalApplications() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalApplicationWrapper(GeneralApplicationWrapper.builder() - .generalApplications(List.of(GeneralApplicationsCollection.builder() - .value(GeneralApplicationItems.builder() - .generalApplicationDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInInterimWrapper_interimUploadAdditionalDocument() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .interimWrapper(InterimWrapper.builder() - .interimUploadAdditionalDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInInterimWrapper_interimHearingDirectionsDocument() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .interimWrapper(InterimWrapper.builder() - .interimHearingDirectionsDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInInterimWrapper_interimHearingDocuments() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .interimWrapper(InterimWrapper.builder() - .interimHearingDocuments(List.of(InterimHearingBulkPrintDocumentsData.builder() - .value(InterimHearingBulkPrintDocument.builder() - .caseDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInDraftDirectionWrapper_draftDirectionOrderCollection() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .draftDirectionWrapper(DraftDirectionWrapper.builder() - .draftDirectionOrderCollection(List.of(DraftDirectionOrderCollection.builder() - .value(DraftDirectionOrder.builder() - .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInDraftDirectionWrapper_latestDraftDirectionOrder() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .draftDirectionWrapper(DraftDirectionWrapper.builder() - .latestDraftDirectionOrder(DraftDirectionOrder.builder() - .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInDraftDirectionWrapper_judgesAmendedOrderCollection() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .draftDirectionWrapper(DraftDirectionWrapper.builder() - .judgesAmendedOrderCollection(List.of(DraftDirectionOrderCollection.builder() - .value(DraftDirectionOrder.builder() - .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterPreview() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalLetterWrapper(GeneralLetterWrapper.builder() - .generalLetterPreview(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterUploadedDocument() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalLetterWrapper(GeneralLetterWrapper.builder() - .generalLetterUploadedDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterUploadedDocuments() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalLetterWrapper(GeneralLetterWrapper.builder() - .generalLetterUploadedDocuments(List.of(DocumentCollection.builder() - .value(DUPLICATED_CASE_DOCUMENT) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterCollection_generatedLetter() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalLetterWrapper(GeneralLetterWrapper.builder() - .generalLetterCollection(List.of(GeneralLetterCollection.builder() - .value(GeneralLetter.builder() - .generatedLetter(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterCollection_generalLetterUploadedDocument() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalLetterWrapper(GeneralLetterWrapper.builder() - .generalLetterCollection(List.of(GeneralLetterCollection.builder() - .value(GeneralLetter.builder() - .generalLetterUploadedDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralLetterWrapper_generalLetterCollection_generalLetterUploadedDocuments() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalLetterWrapper(GeneralLetterWrapper.builder() - .generalLetterCollection(List.of(GeneralLetterCollection.builder() - .value(GeneralLetter.builder() - .generalLetterUploadedDocuments(List.of(DocumentCollection.builder() - .value(DUPLICATED_CASE_DOCUMENT) - .build())) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralEmailWrapper_generalEmailUploadedDocument() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalEmailWrapper(GeneralEmailWrapper.builder() - .generalEmailUploadedDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInGeneralEmailWrapper_generalEmailCollection() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .generalEmailWrapper(GeneralEmailWrapper.builder() - .generalEmailCollection(List.of(GeneralEmailCollection.builder() - .value(GeneralEmailHolder.builder() - .generalEmailUploadedDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_consentD81Joint() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .consentD81Joint(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_consentD81Applicant() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .consentD81Applicant(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_consentD81Respondent() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .consentD81Respondent(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_consentMiniFormA() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .consentMiniFormA(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_uploadApprovedConsentOrder() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .uploadApprovedConsentOrder(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_latestDraftDirectionOrder() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .latestDraftDirectionOrder(DraftDirectionOrder.builder() - .uploadDraftDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_consentOtherCollection() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .consentOtherCollection(List.of(OtherDocumentCollection.builder() - .value(OtherDocument.builder() - .uploadedDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_consentedNotApprovedOrders_consentOrder() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .consentedNotApprovedOrders(List.of(ConsentOrderCollection.builder() - .approvedOrder(ApprovedOrder.builder() - .consentOrder(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_consentedNotApprovedOrders_orderLetter() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .consentedNotApprovedOrders(List.of(ConsentOrderCollection.builder() - .approvedOrder(ApprovedOrder.builder() - .orderLetter(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_consentedNotApprovedOrders_pensionDocuments() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .consentedNotApprovedOrders(List.of(ConsentOrderCollection.builder() - .approvedOrder(ApprovedOrder.builder() - .pensionDocuments(List.of(PensionTypeCollection.builder() - .typedCaseDocument(PensionType.builder() - .pensionDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_uploadConsentOrder() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .uploadConsentOrder(List.of(UploadConsentOrderCollection.builder() - .value(UploadConsentOrder.builder() - .documentLink(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_otherVariationCollection() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .otherVariationCollection(List.of(VariationDocumentTypeCollection.builder() - .value(VariationDocumentType.builder() - .uploadedDocument(DUPLICATED_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_appConsentApprovedOrders_orderLetter() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .appConsentApprovedOrders(List.of(ConsentInContestedApprovedOrderCollection.builder() - .approvedOrder(ConsentInContestedApprovedOrder.builder() - .orderLetter(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_appConsentApprovedOrders_consentOrder() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .appConsentApprovedOrders(List.of(ConsentInContestedApprovedOrderCollection.builder() - .approvedOrder(ConsentInContestedApprovedOrder.builder() - .consentOrder(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_appConsentApprovedOrders_pensionDocuments() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .appConsentApprovedOrders(List.of(ConsentInContestedApprovedOrderCollection.builder() - .approvedOrder(ConsentInContestedApprovedOrder.builder() - .pensionDocuments(List.of(PensionTypeCollection.builder() - .typedCaseDocument(PensionType.builder() - .pensionDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_appConsentApprovedOrders_additionalConsentDocuments() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .appConsentApprovedOrders(List.of(ConsentInContestedApprovedOrderCollection.builder() - .approvedOrder(ConsentInContestedApprovedOrder.builder() - .additionalConsentDocuments(List.of(DocumentCollection.builder() - .value(DUPLICATED_CASE_DOCUMENT) - .build())) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - - assertDuplicateFilenameWarning(warnings); - } - - @Test - void testGetWarnings_duplicateInConsentOrderWrapper_appRefusedOrderCollection() - throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() - .consentOrderWrapper(ConsentOrderWrapper.builder() - .appRefusedOrderCollection(List.of(UnapprovedOrderCollection.builder() - .value(UnapproveOrder.builder() - .caseDocument(DUPLICATED_CASE_DOCUMENT) - .build()) - .build())) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); - assertDuplicateFilenameWarning(warnings); } } From a08a85598ed8bf409b32ac03d485be31ff75e82a Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 28 Jun 2024 13:15:54 +0100 Subject: [PATCH 73/96] Simplified the logic --- .../model/ccd/FinremCaseData.java | 2 +- .../DuplicateFilenameDocumentChecker.java | 31 +------------------ 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/FinremCaseData.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/FinremCaseData.java index baeacfdc3f..0ad5fce08c 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/FinremCaseData.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/FinremCaseData.java @@ -59,7 +59,7 @@ @SuperBuilder(toBuilder = true) @AllArgsConstructor @NoArgsConstructor -public class FinremCaseData { +public class FinremCaseData implements HasCaseDocument { @JsonProperty(access = WRITE_ONLY) private String ccdCaseId; diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index a8fd066d57..f4187c9ed8 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -63,7 +63,6 @@ private static void processHasCaseDocument(HasCaseDocument hcd, List) actualTypeArguments[0])) { - // Get the value of the field and process the list processList((List) field.get(hcd), allDocuments); } @@ -80,36 +79,8 @@ private static void processHasCaseDocument(HasCaseDocument hcd, List collectCaseDocumentsFromFinremCaseData(FinremCaseData caseData) { - // List to collect all CaseDocument instances List allDocuments = new ArrayList<>(); - try { - // Collect all fields from FinremCaseData class - Field[] fields = FinremCaseData.class.getDeclaredFields(); - - for (Field field : fields) { - field.setAccessible(true); - - // Check if the field is a List with a parameterized type - if (List.class.isAssignableFrom(field.getType())) { - ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType(); - Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); - - // Ensure the list has a single parameterized type argument - if (actualTypeArguments.length == 1 && HasCaseDocument.class.isAssignableFrom((Class) actualTypeArguments[0])) { - - // Get the value of the field and process the list - List list = (List) field.get(caseData); - processList(list, allDocuments); - } - } else if (DocumentFileNameProvider.class.isAssignableFrom(field.getType())) { - allDocuments.add((DocumentFileNameProvider) field.get(caseData)); - } else if (HasCaseDocument.class.isAssignableFrom(field.getType())) { - processHasCaseDocument((HasCaseDocument) field.get(caseData), allDocuments); - } - } - } catch (Exception e) { - log.error("Failed to check for duplicate filenames and return warnings", e); - } + processHasCaseDocument(caseData, allDocuments); return allDocuments.stream().filter(Objects::nonNull).toList(); } From d7a297d90935c5f866c3420413a4b42c3d626e94 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 28 Jun 2024 14:37:11 +0100 Subject: [PATCH 74/96] Check the duplication on uploading documents. --- .../DuplicateFilenameDocumentChecker.java | 23 +++++++- .../DuplicateFilenameDocumentCheckerTest.java | 59 ++++++++++++++++--- 2 files changed, 72 insertions(+), 10 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index f4187c9ed8..656f9b0d16 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -7,6 +7,8 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; import java.lang.reflect.Field; import java.lang.reflect.ParameterizedType; @@ -87,7 +89,6 @@ private List collectCaseDocumentsFromFinremCaseData(Fi @Override public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails) throws DocumentContentCheckerException { - FinremCaseData caseData = beforeCaseDetails.getData(); List allDocuments = collectCaseDocumentsFromFinremCaseData(caseData); @@ -101,6 +102,26 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC return List.of(WARNING); } + // check if duplication occurs on uploading documents + FinremCaseData newCaseData = caseDetails.getData(); + if ( + (newCaseData.isConsentedApplication() && + ofNullable(newCaseData.getUploadDocuments()).orElse(List.of()).stream() + .map(d -> ofNullable(d.getValue()).orElse(UploadDocument.builder().build()).getDocumentLink()) + .filter(Objects::nonNull) + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d))) + ) + || + (newCaseData.isContestedApplication() && + ofNullable(newCaseData.getUploadGeneralDocuments()).orElse(List.of()).stream() + .map(d -> ofNullable(d.getValue()).orElse(UploadGeneralDocument.builder().build()).getDocumentLink()) + .filter(Objects::nonNull) + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d))) + ) + ) { + return List.of(WARNING); + } + return Collections.emptyList(); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index 5163ebb0af..7b8b239499 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -5,11 +5,13 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.finrem.caseorchestration.FinremCaseDetailsBuilderFactory; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AdditionalHearingDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AdditionalHearingDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AmendedConsentOrder; @@ -20,6 +22,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApprovedOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ApprovedOrderConsolidateCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConfidentialUploadedDocumentData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConsentInContestedApprovedOrder; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.ConsentInContestedApprovedOrderCollection; @@ -129,23 +132,21 @@ void testCanCheck_alwaysReturnsTrue() { assertThat(underTest.canCheck(DUPLICATED_CASE_DOCUMENT)).isTrue(); } - @Test - void testGetWarnings_NoDuplicate() throws DocumentContentCheckerException { + @ParameterizedTest + @EnumSource(value = CaseType.class, names = {"CONTESTED", "CONSENTED"}) + void testGetWarnings_noDuplication(CaseType caseType) throws DocumentContentCheckerException { List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(FinremCaseData.builder() + FinremCaseDetailsBuilderFactory.from(caseType, FinremCaseData.builder() .additionalDocument(CaseDocument.builder().documentFilename("additionalDocument").build()) .generalOrderWrapper(GeneralOrderWrapper.builder() .generalOrderLatestDocument(CaseDocument.builder().documentFilename("generalOrderLatestDocument").build()) - .build()) - .build()) - .build(), - FinremCaseDetails.builder().build()); + .build())).build(), + FinremCaseDetailsBuilderFactory.from(caseType).build()); assertThat(warnings).isEmpty(); } - private static Stream testGetWarningsOnExistingCase() { + static Stream testGetWarningsOnExistingCase() { return Stream.of( Arguments.of(FinremCaseData.builder() .generalOrderWrapper(GeneralOrderWrapper.builder() @@ -896,4 +897,44 @@ void testGetWarningsOnExistingCase(FinremCaseData caseData) FinremCaseDetails.builder().build()); assertDuplicateFilenameWarning(warnings); } + + @Test + void testGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeConsented() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetailsBuilderFactory.from(CaseType.CONSENTED).build(), + FinremCaseDetailsBuilderFactory.from(CaseType.CONSENTED, FinremCaseData.builder() + .uploadDocuments(List.of( + UploadDocumentCollection.builder().value(UploadDocument.builder() + .documentComment("1") + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build(), + UploadDocumentCollection.builder().value(UploadDocument.builder() + .documentComment("2") + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build() + ))).build()); + assertDuplicateFilenameWarning(warnings); + } + + @Test + void testGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeContented() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED).build(), + FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED, FinremCaseData.builder() + .uploadGeneralDocuments(List.of( + UploadGeneralDocumentCollection.builder().value(UploadGeneralDocument.builder() + .documentComment("1") + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build(), + UploadGeneralDocumentCollection.builder().value(UploadGeneralDocument.builder() + .documentComment("2") + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build() + ))).build()); + assertDuplicateFilenameWarning(warnings); + } } From 93366052bd7345fd00abc340d3b9a95f3e0fceb9 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 28 Jun 2024 14:58:27 +0100 Subject: [PATCH 75/96] checkstyle --- .../DuplicateFilenameDocumentChecker.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index 656f9b0d16..7bcca4e00e 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -105,19 +105,17 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC // check if duplication occurs on uploading documents FinremCaseData newCaseData = caseDetails.getData(); if ( - (newCaseData.isConsentedApplication() && - ofNullable(newCaseData.getUploadDocuments()).orElse(List.of()).stream() + (newCaseData.isConsentedApplication() + && ofNullable(newCaseData.getUploadDocuments()).orElse(List.of()).stream() .map(d -> ofNullable(d.getValue()).orElse(UploadDocument.builder().build()).getDocumentLink()) .filter(Objects::nonNull) - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d))) - ) - || - (newCaseData.isContestedApplication() && - ofNullable(newCaseData.getUploadGeneralDocuments()).orElse(List.of()).stream() - .map(d -> ofNullable(d.getValue()).orElse(UploadGeneralDocument.builder().build()).getDocumentLink()) - .filter(Objects::nonNull) - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d))) - ) + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d)))) + || + (newCaseData.isContestedApplication() + && ofNullable(newCaseData.getUploadGeneralDocuments()).orElse(List.of()).stream() + .map(d -> ofNullable(d.getValue()).orElse(UploadGeneralDocument.builder().build()).getDocumentLink()) + .filter(Objects::nonNull) + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d)))) ) { return List.of(WARNING); } From 21427dda39d980743a8989116f7785efe6830820 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 28 Jun 2024 15:22:12 +0100 Subject: [PATCH 76/96] Bug fix and skip the first match --- .../DuplicateFilenameDocumentChecker.java | 4 +-- .../DuplicateFilenameDocumentCheckerTest.java | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index 7bcca4e00e..acc94a8981 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -109,13 +109,13 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC && ofNullable(newCaseData.getUploadDocuments()).orElse(List.of()).stream() .map(d -> ofNullable(d.getValue()).orElse(UploadDocument.builder().build()).getDocumentLink()) .filter(Objects::nonNull) - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d)))) + .filter(d -> isDuplicateFilename(caseDocument, () -> List.of(d))).count() > 1) || (newCaseData.isContestedApplication() && ofNullable(newCaseData.getUploadGeneralDocuments()).orElse(List.of()).stream() .map(d -> ofNullable(d.getValue()).orElse(UploadGeneralDocument.builder().build()).getDocumentLink()) .filter(Objects::nonNull) - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d)))) + .filter(d -> isDuplicateFilename(caseDocument, () -> List.of(d))).count() > 1) ) { return List.of(WARNING); } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index 7b8b239499..75b535357a 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -918,6 +918,22 @@ void testGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeConsented() throws Do assertDuplicateFilenameWarning(warnings); } + @Test + void shouldNotGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeConsented() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetailsBuilderFactory.from(CaseType.CONSENTED).build(), + FinremCaseDetailsBuilderFactory.from(CaseType.CONSENTED, FinremCaseData.builder() + .uploadDocuments(List.of( + UploadDocumentCollection.builder().value(UploadDocument.builder() + .documentComment("1") + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build() + ))).build()); + + assertThat(warnings).isEmpty(); + } + @Test void testGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeContented() throws DocumentContentCheckerException { List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], @@ -937,4 +953,20 @@ void testGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeContented() throws Do ))).build()); assertDuplicateFilenameWarning(warnings); } + + @Test + void shouldNotetWarningsOnUploadingDuplicatedFilesAtTheSameTimeContented() throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], + FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED).build(), + FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED, FinremCaseData.builder() + .uploadGeneralDocuments(List.of( + UploadGeneralDocumentCollection.builder().value(UploadGeneralDocument.builder() + .documentComment("1") + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()) + .build() + ))).build()); + + assertThat(warnings).isEmpty(); + } } From 4946ef9f4159459f1b2aac6f63731341d9e78628 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 1 Jul 2024 15:39:17 +0100 Subject: [PATCH 77/96] Remove checking null logic and an unnecessary log. --- .../DuplicateFilenameDocumentChecker.java | 48 +++++++++---------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index acc94a8981..05bc0aefe7 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -42,41 +42,37 @@ private static void processList(List list, List all for (Object item : list) { if (item instanceof HasCaseDocument hasCaseDocument) { processHasCaseDocument(hasCaseDocument, allDocuments); - } else { - log.warn("Ignored " + item.getClass().getName()); } } } } private static void processHasCaseDocument(HasCaseDocument hcd, List allDocuments) { - if (hcd != null) { - try { - // Collect all fields from HasCaseDocument class - Field[] fields = hcd.getClass().getDeclaredFields(); - - for (Field field : fields) { - field.setAccessible(true); - - // Check if the field is a List with a parameterized type - if (List.class.isAssignableFrom(field.getType())) { - ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType(); - Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); - - // Ensure the list has a single parameterized type argument - if (actualTypeArguments.length == 1 && HasCaseDocument.class.isAssignableFrom((Class) actualTypeArguments[0])) { - // Get the value of the field and process the list - processList((List) field.get(hcd), allDocuments); - } - } else if (DocumentFileNameProvider.class.isAssignableFrom(field.getType())) { - allDocuments.add((DocumentFileNameProvider) field.get(hcd)); - } else if (HasCaseDocument.class.isAssignableFrom(field.getType())) { - processHasCaseDocument((HasCaseDocument) field.get(hcd), allDocuments); + try { + // Collect all fields from HasCaseDocument class + Field[] fields = hcd.getClass().getDeclaredFields(); + + for (Field field : fields) { + field.setAccessible(true); + + // Check if the field is a List with a parameterized type + if (List.class.isAssignableFrom(field.getType())) { + ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType(); + Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); + + // Ensure the list has a single parameterized type argument + if (actualTypeArguments.length == 1 && HasCaseDocument.class.isAssignableFrom((Class) actualTypeArguments[0])) { + // Get the value of the field and process the list + processList((List) field.get(hcd), allDocuments); } + } else if (DocumentFileNameProvider.class.isAssignableFrom(field.getType())) { + allDocuments.add((DocumentFileNameProvider) field.get(hcd)); + } else if (HasCaseDocument.class.isAssignableFrom(field.getType())) { + processHasCaseDocument((HasCaseDocument) field.get(hcd), allDocuments); } - } catch (Exception e) { - log.error("Failed to check for duplicate filenames and return warnings", e); } + } catch (Exception e) { + log.error("Failed to check for duplicate filenames and return warnings", e); } } From 4bf6010b3206521200ee5fdbbb61c8d5fa52d01d Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 1 Jul 2024 15:46:46 +0100 Subject: [PATCH 78/96] typo --- .../documentchecker/DuplicateFilenameDocumentCheckerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index 75b535357a..70058c5490 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -935,7 +935,7 @@ void shouldNotGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeConsented() thro } @Test - void testGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeContented() throws DocumentContentCheckerException { + void testGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeContested() throws DocumentContentCheckerException { List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED).build(), FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED, FinremCaseData.builder() @@ -955,7 +955,7 @@ void testGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeContented() throws Do } @Test - void shouldNotetWarningsOnUploadingDuplicatedFilesAtTheSameTimeContented() throws DocumentContentCheckerException { + void shouldNotGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeContested() throws DocumentContentCheckerException { List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED).build(), FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED, FinremCaseData.builder() From b4c259b1d2f396580820f8716401aa408afaf190 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Mon, 1 Jul 2024 15:59:14 +0100 Subject: [PATCH 79/96] Added a Javadoc --- .../DuplicateFilenameDocumentChecker.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index 05bc0aefe7..c8e9a6dab0 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -47,6 +47,14 @@ private static void processList(List list, List all } } + /** + * Processes a {@link HasCaseDocument} instance to collect all documents that implement + * the {@link DocumentFileNameProvider} interface from its fields, including nested + * {@link HasCaseDocument} instances and lists of such instances. + * + * @param hcd the {@link HasCaseDocument} instance to process + * @param allDocuments the list to which collected {@link DocumentFileNameProvider} instances will be added + */ private static void processHasCaseDocument(HasCaseDocument hcd, List allDocuments) { try { // Collect all fields from HasCaseDocument class @@ -68,6 +76,7 @@ private static void processHasCaseDocument(HasCaseDocument hcd, List Date: Tue, 2 Jul 2024 14:49:20 +0100 Subject: [PATCH 80/96] Use Builder pattern for the parameters --- .../model/DocumentCheckContext.java | 15 +++++ .../documentchecker/DocumentChecker.java | 5 +- .../DocumentCheckerService.java | 7 +- .../documentchecker/DocxDocumentChecker.java | 9 ++- .../DuplicateFilenameDocumentChecker.java | 11 ++-- .../documentchecker/PdfDocumentChecker.java | 9 ++- .../DocumentCheckerServiceTest.java | 8 +-- .../DocxDocumentCheckerTest.java | 15 ++++- .../DuplicateFilenameDocumentCheckerTest.java | 66 ++++++++++++------- .../PdfDocumentCheckerTest.java | 8 ++- 10 files changed, 100 insertions(+), 53 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/DocumentCheckContext.java diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/DocumentCheckContext.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/DocumentCheckContext.java new file mode 100644 index 0000000000..c156fde59c --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/DocumentCheckContext.java @@ -0,0 +1,15 @@ +package uk.gov.hmcts.reform.finrem.caseorchestration.model; + +import lombok.Builder; +import lombok.Getter; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; + +@Builder +@Getter +public class DocumentCheckContext { + private CaseDocument caseDocument; + private byte[] bytes; + private FinremCaseDetails beforeCaseDetails; + private FinremCaseDetails caseDetails; +} diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentChecker.java index d865fc8934..06e2e2da0d 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentChecker.java @@ -1,7 +1,7 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.DocumentCheckContext; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import java.util.List; @@ -9,6 +9,5 @@ public interface DocumentChecker { boolean canCheck(CaseDocument caseDocument); - List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails) - throws DocumentContentCheckerException; + List getWarnings(DocumentCheckContext context) throws DocumentContentCheckerException; } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java index fbd35f53c7..ce6ad01e5c 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java @@ -2,6 +2,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.DocumentCheckContext; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.service.evidencemanagement.EvidenceManagementDownloadService; @@ -40,7 +41,11 @@ public List getWarnings(CaseDocument caseDocument, FinremCaseDetails bef List warnings = new ArrayList<>(); documentCheckersForDocument.forEach(dc -> { try { - warnings.addAll(dc.getWarnings(caseDocument, bytes, beforeCaseDetails, caseDetails)); + warnings.addAll(dc.getWarnings(DocumentCheckContext.builder() + .caseDocument(caseDocument).bytes(bytes) + .beforeCaseDetails(beforeCaseDetails) + .caseDetails(caseDetails) + .build())); } catch (DocumentContentCheckerException e) { log.error(format("Unexpected error when getting warnings from %s", dc.getClass().getName()), e); } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java index d598487194..e419873eb7 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentChecker.java @@ -2,8 +2,8 @@ import org.apache.commons.io.FilenameUtils; import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.DocumentCheckContext; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.DocumentContentChecker; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentreader.DocxDocumentReader; @@ -28,12 +28,11 @@ public boolean canCheck(CaseDocument caseDocument) { } @Override - public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails) - throws DocumentContentCheckerException { - String[] content = getContent(bytes); + public List getWarnings(DocumentCheckContext context) throws DocumentContentCheckerException { + String[] content = getContent(context.getBytes()); return documentContentCheckers.stream() - .map(dcc -> dcc.getWarning(caseDetails, content)) + .map(dcc -> dcc.getWarning(context.getCaseDetails(), content)) .filter(Objects::nonNull) .toList(); } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index c8e9a6dab0..bbc03a0d43 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -2,10 +2,10 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.DocumentCheckContext; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DocumentFileNameProvider; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadGeneralDocument; @@ -92,10 +92,9 @@ private List collectCaseDocumentsFromFinremCaseData(Fi } @Override - public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails) - throws DocumentContentCheckerException { - FinremCaseData caseData = beforeCaseDetails.getData(); - List allDocuments = collectCaseDocumentsFromFinremCaseData(caseData); + public List getWarnings(DocumentCheckContext context) throws DocumentContentCheckerException { + CaseDocument caseDocument = context.getCaseDocument(); + List allDocuments = collectCaseDocumentsFromFinremCaseData(context.getBeforeCaseDetails().getData()); log.info("Iterating all CaseDocuments with interface HasCaseDocument."); @@ -108,7 +107,7 @@ public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremC } // check if duplication occurs on uploading documents - FinremCaseData newCaseData = caseDetails.getData(); + FinremCaseData newCaseData = context.getCaseDetails().getData(); if ( (newCaseData.isConsentedApplication() && ofNullable(newCaseData.getUploadDocuments()).orElse(List.of()).stream() diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java index 0289b5a8e1..ae1c207295 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentChecker.java @@ -2,8 +2,8 @@ import org.apache.commons.io.FilenameUtils; import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.DocumentCheckContext; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; -import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.DocumentContentChecker; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentreader.PdfDocumentReader; @@ -30,13 +30,12 @@ public boolean canCheck(CaseDocument caseDocument) { } @Override - public List getWarnings(CaseDocument caseDocument, byte[] bytes, FinremCaseDetails beforeCaseDetails, FinremCaseDetails caseDetails) - throws DocumentContentCheckerException { + public List getWarnings(DocumentCheckContext context) throws DocumentContentCheckerException { try { - String[] content = getContent(bytes); + String[] content = getContent(context.getBytes()); return documentContentCheckers.stream() - .map(dcc -> dcc.getWarning(caseDetails, content)) + .map(dcc -> dcc.getWarning(context.getCaseDetails(), content)) .filter(Objects::nonNull) .toList(); } catch (IOException e) { diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java index 1f4408fba7..fa0a075faf 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java @@ -53,7 +53,7 @@ void testSingleWarningReturnedByDocxDocumentChecker() throws DocumentContentChec when(downloadService.download(any(), eq(AUTH_TOKEN))).thenReturn(new byte[]{}); when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); - when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any(), any())).thenReturn(List.of("docx warning")); + when(docxDocumentChecker.getWarnings(any())).thenReturn(List.of("docx warning")); List actual = underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), FinremCaseDetails.builder().build(), AUTH_TOKEN); @@ -66,9 +66,9 @@ void testMultipleWarningsReturnedCheckers() throws DocumentContentCheckerExcepti when(downloadService.download(any(), eq(AUTH_TOKEN))).thenReturn(new byte[]{}); when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); - when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any(), any())).thenReturn(List.of("docx warning")); + when(docxDocumentChecker.getWarnings(any())).thenReturn(List.of("docx warning")); when(duplicateFilenameDocumentChecker.canCheck(caseDocument)).thenReturn(true); - when(duplicateFilenameDocumentChecker.getWarnings(eq(caseDocument), any(), any(), any())).thenReturn(List.of("duplicate warning")); + when(duplicateFilenameDocumentChecker.getWarnings(any())).thenReturn(List.of("duplicate warning")); List actual = underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), FinremCaseDetails.builder().build(), AUTH_TOKEN); @@ -79,7 +79,7 @@ void testMultipleWarningsReturnedCheckers() throws DocumentContentCheckerExcepti void testIfDocxCheckerThrowDocumentContentCheckerException() throws DocumentContentCheckerException { final CaseDocument caseDocument = caseDocument(); when(docxDocumentChecker.canCheck(caseDocument)).thenReturn(true); - when(docxDocumentChecker.getWarnings(eq(caseDocument), any(), any(), any())) + when(docxDocumentChecker.getWarnings(any())) .thenThrow(new DocumentContentCheckerException(new RuntimeException("test"))); underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), FinremCaseDetails.builder().build(), AUTH_TOKEN); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java index 3181da953a..317bcb616b 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocxDocumentCheckerTest.java @@ -8,6 +8,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.DocumentCheckContext; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.CaseNumberDocumentContentChecker; @@ -82,7 +83,12 @@ void testGetWarnings_withValidContent(int testCase) throws DocumentContentChecke when(caseNumberDocumentContentChecker.getWarning(eq(caseDetails), any(String[].class))) .thenReturn(testCase == 1 ? null : "Warning2"); - List warnings = underTest.getWarnings(caseDocument, documentBytes, caseDetails, caseDetails); + List warnings = underTest.getWarnings(DocumentCheckContext.builder() + .caseDocument(caseDocument) + .bytes(documentBytes) + .beforeCaseDetails(caseDetails) + .caseDetails(caseDetails) + .build()); assertThat(warnings).hasSize(testCase == 1 ? 1 : 2).contains("Warning1"); @@ -103,7 +109,12 @@ void testGetWarnings_whenGivenFileCannotBeRead() throws IOException { FinremCaseDetails caseDetails = new FinremCaseDetails(); byte[] documentBytes = "Invalid content".getBytes(); - assertThatThrownBy(() -> underTest.getWarnings(caseDocument, documentBytes, caseDetails, caseDetails)) + assertThatThrownBy(() -> underTest.getWarnings(DocumentCheckContext.builder() + .caseDocument(caseDocument) + .bytes(documentBytes) + .beforeCaseDetails(caseDetails) + .caseDetails(caseDetails) + .build())) .isInstanceOf(DocumentContentCheckerException.class); } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index 70058c5490..90a0756ca8 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -12,6 +12,7 @@ import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; import uk.gov.hmcts.reform.finrem.caseorchestration.FinremCaseDetailsBuilderFactory; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.DocumentCheckContext; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AdditionalHearingDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AdditionalHearingDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AmendedConsentOrder; @@ -135,13 +136,16 @@ void testCanCheck_alwaysReturnsTrue() { @ParameterizedTest @EnumSource(value = CaseType.class, names = {"CONTESTED", "CONSENTED"}) void testGetWarnings_noDuplication(CaseType caseType) throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetailsBuilderFactory.from(caseType, FinremCaseData.builder() + List warnings = underTest.getWarnings(DocumentCheckContext.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .bytes(new byte[0]) + .beforeCaseDetails(FinremCaseDetailsBuilderFactory.from(caseType, FinremCaseData.builder() .additionalDocument(CaseDocument.builder().documentFilename("additionalDocument").build()) .generalOrderWrapper(GeneralOrderWrapper.builder() .generalOrderLatestDocument(CaseDocument.builder().documentFilename("generalOrderLatestDocument").build()) - .build())).build(), - FinremCaseDetailsBuilderFactory.from(caseType).build()); + .build())).build()) + .caseDetails(FinremCaseDetailsBuilderFactory.from(caseType).build()) + .build()); assertThat(warnings).isEmpty(); } @@ -890,19 +894,21 @@ static Stream testGetWarningsOnExistingCase() { @MethodSource void testGetWarningsOnExistingCase(FinremCaseData caseData) throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetails.builder() - .data(caseData) - .build(), - FinremCaseDetails.builder().build()); + List warnings = underTest.getWarnings(DocumentCheckContext.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .bytes(new byte[0]) + .beforeCaseDetails(FinremCaseDetails.builder().data(caseData).build()) + .caseDetails(FinremCaseDetails.builder().build()).build()); assertDuplicateFilenameWarning(warnings); } @Test void testGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeConsented() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetailsBuilderFactory.from(CaseType.CONSENTED).build(), - FinremCaseDetailsBuilderFactory.from(CaseType.CONSENTED, FinremCaseData.builder() + List warnings = underTest.getWarnings(DocumentCheckContext.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .bytes(new byte[0]) + .beforeCaseDetails(FinremCaseDetailsBuilderFactory.from(CaseType.CONSENTED).build()) + .caseDetails(FinremCaseDetailsBuilderFactory.from(CaseType.CONSENTED, FinremCaseData.builder() .uploadDocuments(List.of( UploadDocumentCollection.builder().value(UploadDocument.builder() .documentComment("1") @@ -914,31 +920,37 @@ void testGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeConsented() throws Do .documentLink(DUPLICATED_CASE_DOCUMENT) .build()) .build() - ))).build()); + ))).build()) + .build()); assertDuplicateFilenameWarning(warnings); } @Test void shouldNotGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeConsented() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetailsBuilderFactory.from(CaseType.CONSENTED).build(), - FinremCaseDetailsBuilderFactory.from(CaseType.CONSENTED, FinremCaseData.builder() + List warnings = underTest.getWarnings(DocumentCheckContext.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .bytes(new byte[0]) + .beforeCaseDetails(FinremCaseDetailsBuilderFactory.from(CaseType.CONSENTED).build()) + .caseDetails(FinremCaseDetailsBuilderFactory.from(CaseType.CONSENTED, FinremCaseData.builder() .uploadDocuments(List.of( UploadDocumentCollection.builder().value(UploadDocument.builder() .documentComment("1") .documentLink(DUPLICATED_CASE_DOCUMENT) .build()) .build() - ))).build()); + ))).build()) + .build()); assertThat(warnings).isEmpty(); } @Test void testGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeContested() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED).build(), - FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED, FinremCaseData.builder() + List warnings = underTest.getWarnings(DocumentCheckContext.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .bytes(new byte[0]) + .beforeCaseDetails(FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED).build()) + .caseDetails(FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED, FinremCaseData.builder() .uploadGeneralDocuments(List.of( UploadGeneralDocumentCollection.builder().value(UploadGeneralDocument.builder() .documentComment("1") @@ -950,22 +962,26 @@ void testGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeContested() throws Do .documentLink(DUPLICATED_CASE_DOCUMENT) .build()) .build() - ))).build()); + ))).build()) + .build()); assertDuplicateFilenameWarning(warnings); } @Test void shouldNotGetWarningsOnUploadingDuplicatedFilesAtTheSameTimeContested() throws DocumentContentCheckerException { - List warnings = underTest.getWarnings(DUPLICATED_CASE_DOCUMENT, new byte[0], - FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED).build(), - FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED, FinremCaseData.builder() + List warnings = underTest.getWarnings(DocumentCheckContext.builder() + .caseDocument(DUPLICATED_CASE_DOCUMENT) + .bytes(new byte[0]) + .beforeCaseDetails(FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED).build()) + .caseDetails(FinremCaseDetailsBuilderFactory.from(CaseType.CONTESTED, FinremCaseData.builder() .uploadGeneralDocuments(List.of( UploadGeneralDocumentCollection.builder().value(UploadGeneralDocument.builder() .documentComment("1") .documentLink(DUPLICATED_CASE_DOCUMENT) .build()) .build() - ))).build()); + ))).build()) + .build()); assertThat(warnings).isEmpty(); } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java index e53aa7e0fc..e88b632367 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/PdfDocumentCheckerTest.java @@ -8,6 +8,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.DocumentCheckContext; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker.CaseNumberDocumentContentChecker; @@ -82,7 +83,9 @@ void testGetWarnings_withValidContent(int testCase) throws DocumentContentChecke when(caseNumberDocumentContentChecker.getWarning(eq(caseDetails), any(String[].class))) .thenReturn(testCase == 1 ? null : "Warning2"); - List warnings = underTest.getWarnings(caseDocument, documentBytes, caseDetails, caseDetails); + List warnings = underTest.getWarnings(DocumentCheckContext.builder() + .caseDocument(caseDocument).bytes(documentBytes).caseDetails(caseDetails) + .build()); assertThat(warnings).hasSize(testCase == 1 ? 1 : 2).contains("Warning1"); @@ -103,7 +106,8 @@ void testGetWarnings_whenGivenFileCannotBeRead() throws IOException { FinremCaseDetails caseDetails = new FinremCaseDetails(); byte[] documentBytes = "Invalid content".getBytes(); - assertThatThrownBy(() -> underTest.getWarnings(caseDocument, documentBytes, caseDetails, caseDetails)) + assertThatThrownBy(() -> underTest.getWarnings(DocumentCheckContext.builder() + .caseDocument(caseDocument).bytes(documentBytes).caseDetails(caseDetails).build())) .isInstanceOf(DocumentContentCheckerException.class); } } From 3d0af6bf2634fd5dce259cc70fec2d4b1e5298c4 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 4 Jul 2024 10:07:04 +0100 Subject: [PATCH 81/96] Modify CaseNumberDocumentContentChecker to detect "Case No" and "Reference number" as well. --- .../CaseNumberDocumentContentChecker.java | 4 +++- .../CaseNumberDocumentContentCheckerTest.java | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java index 46ec6cdf5c..6da1617158 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java @@ -23,7 +23,9 @@ public String getWarning(FinremCaseDetails caseDetails, String[] content) { } private boolean containsCaseNumber(String text) { - return defaultString(text).contains("Case number"); + return defaultString(text).toLowerCase().contains("case number") + || defaultString(text).toLowerCase().contains("case no") + || defaultString(text).toLowerCase().contains("reference number"); } private boolean contentCaseNumberNotEqualsCaseNumber(FinremCaseDetails caseDetails, String content) { diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java index 896d36a2bb..a56504ab30 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java @@ -1,6 +1,5 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.contentchecker; -import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.NullSource; import org.junit.jupiter.params.provider.ValueSource; @@ -18,7 +17,7 @@ class CaseNumberDocumentContentCheckerTest { private final CaseNumberDocumentContentChecker underTest = new CaseNumberDocumentContentChecker(); @ParameterizedTest - @ValueSource(strings = {"Case number 1234567890", "whatever", ""}) + @ValueSource(strings = {"Case number 1234567890", "Case No: 1234567890", "Reference number: 1234567890", "whatever", ""}) @NullSource void givenCaseData_whenContentContainCaseNumber(String validContent) { Arrays.stream(StringDecorator.values()).forEach(validContentDecorator -> @@ -26,14 +25,15 @@ void givenCaseData_whenContentContainCaseNumber(String validContent) { new String[]{validContentDecorator.decorate(validContent)})).isNull()); } - @Test - void givenCaseData_whenContentDoesNotMatchCaseNumber() { + @ParameterizedTest + @ValueSource(strings = {"Case number 1234567891", "Case No: 1234567891", "Reference number: 1234567891"}) + void givenCaseData_whenContentDoesNotMatchCaseNumber(String caseNumber) { assertThat(underTest.getWarning(FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID)).build(), - new String[] {"Case number 1234567891"})).isEqualTo("Case numbers may not match"); + new String[] {caseNumber})).isEqualTo("Case numbers may not match"); } @ParameterizedTest - @ValueSource(strings = {"Case number 1234567890", "whatever", ""}) + @ValueSource(strings = {"Case number 1234567890", "Case No: 1234567890", "Reference number: 1234567890", "whatever", ""}) @NullSource void givenCaseDataWithoutId_whenContentDoesNotMatchCaseNumber(String content) { Arrays.stream(StringDecorator.values()).forEach(contentDecorator -> From d4c6e9917efa27efb2e65965b0e689fe1dad3626 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 5 Jul 2024 10:51:47 +0100 Subject: [PATCH 82/96] Add warning messages with character to capture the sorting behavior --- .../UploadDocumentConsentedAboutToSubmitHandlerTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java index 5964026cbc..c76d8a6339 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java @@ -108,8 +108,8 @@ void givenValidCaseData_whenWarningsAreDetected_thenPopulateSortedWarnings(boole .value(UploadDocument.builder().build()) .build() )); - when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenReturn(hasWarnings ? List.of("2warnings", "1warnings","1warnings") - : List.of()); + when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenReturn(hasWarnings ? List.of("2warnings", "1warnings", "1warnings", + "abc", "Aae") : List.of()); FinremCaseDetails finremCaseDetails = FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONSENTED, FinremCaseData.builder() .uploadDocuments(List.of( @@ -128,7 +128,7 @@ void givenValidCaseData_whenWarningsAreDetected_thenPopulateSortedWarnings(boole .caseDetails(finremCaseDetails) .caseDetailsBefore(finremCaseDetailsBefore).build(), AUTH_TOKEN); - assertThat(response.getWarnings()).isEqualTo(hasWarnings ? List.of("1warnings", "2warnings") : List.of()); + assertThat(response.getWarnings()).isEqualTo(hasWarnings ? List.of("1warnings", "2warnings", "Aae", "abc") : List.of()); if (hasWarnings) { assertThat(logs.getInfos()).containsExactly(format( "Number of warnings encountered when uploading document for a case %s: %s", CASE_ID, 2)); From 0a4b54de5518fa2b86fd84dbfd5263d18aae8430 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 10 Jul 2024 15:40:30 +0100 Subject: [PATCH 83/96] update test case --- .../DuplicateFilenameDocumentCheckerTest.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index 90a0756ca8..5d6fac0216 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -97,7 +97,9 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.OrderWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.UploadCaseDocumentWrapper; +import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; @@ -898,7 +900,17 @@ void testGetWarningsOnExistingCase(FinremCaseData caseData) .caseDocument(DUPLICATED_CASE_DOCUMENT) .bytes(new byte[0]) .beforeCaseDetails(FinremCaseDetails.builder().data(caseData).build()) - .caseDetails(FinremCaseDetails.builder().build()).build()); + .caseDetails(FinremCaseDetails.builder().data( + caseData.toBuilder().uploadDocuments( + Stream.concat( + Optional.ofNullable(caseData.getUploadDocuments()).orElse(new ArrayList<>()).stream(), + Stream.of(UploadDocumentCollection.builder().value(UploadDocument.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()).build()) + ).toList() + ).build() + ).build()) + .build()); assertDuplicateFilenameWarning(warnings); } From 3a4ad8aeccf5e8da4ff40e4588aa3864a91edd07 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 10 Jul 2024 16:01:00 +0100 Subject: [PATCH 84/96] typo --- .../UploadDocumentConsentedAboutToSubmitHandlerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java index c76d8a6339..e7c61a2c13 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java @@ -131,7 +131,7 @@ void givenValidCaseData_whenWarningsAreDetected_thenPopulateSortedWarnings(boole assertThat(response.getWarnings()).isEqualTo(hasWarnings ? List.of("1warnings", "2warnings", "Aae", "abc") : List.of()); if (hasWarnings) { assertThat(logs.getInfos()).containsExactly(format( - "Number of warnings encountered when uploading document for a case %s: %s", CASE_ID, 2)); + "Number of warnings encountered when uploading document for a case %s: %s", CASE_ID, 4)); } else { assertThat(logs.getInfos()).isEmpty(); } From c7c535f1273a5c090592a4240ec151b7f791e2e8 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 10 Jul 2024 16:42:12 +0100 Subject: [PATCH 85/96] Revert @Setter annotations. and use @Builder(toBuilder= true) in FinremCaeData. --- .../finrem/caseorchestration/model/ccd/FinremCaseData.java | 3 +-- .../model/ccd/wrapper/ContactDetailsWrapper.java | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/FinremCaseData.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/FinremCaseData.java index 0ad5fce08c..76b8a2d377 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/FinremCaseData.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/FinremCaseData.java @@ -14,7 +14,6 @@ import lombok.Data; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; import org.apache.commons.lang3.StringUtils; import uk.gov.hmcts.reform.bsp.common.model.document.Addressee; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.AllocatedRegionWrapper; @@ -56,7 +55,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_EMPTY) @Data -@SuperBuilder(toBuilder = true) +@Builder(toBuilder = true) @AllArgsConstructor @NoArgsConstructor public class FinremCaseData implements HasCaseDocument { diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/ContactDetailsWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/ContactDetailsWrapper.java index 2a6bcf473f..c9d07856f9 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/ContactDetailsWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/ContactDetailsWrapper.java @@ -7,7 +7,6 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Setter; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.Address; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.NoticeOfChangeParty; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.YesOrNo; @@ -42,10 +41,8 @@ public class ContactDetailsWrapper { @JsonProperty("applicantAddressConfidential") private YesOrNo applicantAddressHiddenFromRespondent; @JsonProperty("respondentFMName") - @Setter private String respondentFmName; @JsonProperty("respondentLName") - @Setter private String respondentLname; @JsonProperty("respondentRepresented") private YesOrNo contestedRespondentRepresented; @@ -78,9 +75,7 @@ public class ContactDetailsWrapper { private String solicitorDxNumber; private YesOrNo solicitorAgreeToReceiveEmails; @JsonProperty("appRespondentFMName") - @Setter private String appRespondentFmName; - @Setter private String appRespondentLName; @JsonProperty("appRespondentRep") private YesOrNo consentedRespondentRepresented; From 28bceb09e41d2dba8735174a5ecc2d36a8d897b2 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 11 Jul 2024 09:40:34 +0100 Subject: [PATCH 86/96] Fixing failed test case. --- .../service/documentreader/DocxDocumentReaderTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReaderTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReaderTest.java index 0cab8f8da8..7589092708 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReaderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentreader/DocxDocumentReaderTest.java @@ -1,6 +1,5 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service.documentreader; -import org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -37,6 +36,6 @@ void testGetContentFromADocxFile() throws IOException { void testGetContent_withError() throws IOException { byte[] document = Files.readAllBytes(getPathFromResources("fixtures/documentcontentvalidation/generalOrder.pdf")); - assertThatThrownBy(() -> underTest.getContent(document)).isInstanceOf(NotOfficeXmlFileException.class); + assertThatThrownBy(() -> underTest.getContent(document)).isInstanceOf(Exception.class); } } From 9b3d3c8e44d90ea1a9474fb660b3a7c89c22028a Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 11 Jul 2024 11:47:06 +0100 Subject: [PATCH 87/96] Revert "Update dependency org.apache.poi:poi-ooxml to v5.3.0 (#1762)" This reverts commit c7365d11082663e580ef9b4fae20be0ac337a061. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 256fe6de90..3251c008cc 100644 --- a/build.gradle +++ b/build.gradle @@ -420,7 +420,7 @@ dependencies { implementation("org.apache.poi:poi:5.2.3") { exclude group: "org.apache.commons", module: "commons-math3" } - implementation("org.apache.poi:poi-ooxml:5.3.0") { + implementation("org.apache.poi:poi-ooxml:5.2.5") { exclude group: "org.apache.commons", module: "commons-math3" } From 534a29139f2dda03dc1c5e6e34e1b1641bc75f0b Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 17 Jul 2024 12:59:35 +0100 Subject: [PATCH 88/96] Log messages improvement. --- .../service/documentchecker/DocumentCheckerService.java | 2 +- .../documentchecker/DuplicateFilenameDocumentChecker.java | 2 -- .../documentchecker/DocumentCheckerServiceTest.java | 8 ++++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java index ce6ad01e5c..3dc7570178 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerService.java @@ -47,7 +47,7 @@ public List getWarnings(CaseDocument caseDocument, FinremCaseDetails bef .caseDetails(caseDetails) .build())); } catch (DocumentContentCheckerException e) { - log.error(format("Unexpected error when getting warnings from %s", dc.getClass().getName()), e); + log.error(format("%s Unexpected error when getting warnings from %s", caseDetails.getId(), dc.getClass().getName()), e); } }); diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index bbc03a0d43..b667979253 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -96,8 +96,6 @@ public List getWarnings(DocumentCheckContext context) throws DocumentCo CaseDocument caseDocument = context.getCaseDocument(); List allDocuments = collectCaseDocumentsFromFinremCaseData(context.getBeforeCaseDetails().getData()); - log.info("Iterating all CaseDocuments with interface HasCaseDocument."); - // Check for duplicate filenames in the collected documents boolean hasDuplicates = allDocuments.stream() .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d))); diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java index fa0a075faf..43f126d44b 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DocumentCheckerServiceTest.java @@ -16,11 +16,13 @@ import java.util.Arrays; import java.util.List; +import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.finrem.caseorchestration.TestConstants.AUTH_TOKEN; +import static uk.gov.hmcts.reform.finrem.caseorchestration.TestConstants.CASE_ID; import static uk.gov.hmcts.reform.finrem.caseorchestration.TestSetUpUtils.caseDocument; @ExtendWith(MockitoExtension.class) @@ -82,8 +84,10 @@ void testIfDocxCheckerThrowDocumentContentCheckerException() throws DocumentCont when(docxDocumentChecker.getWarnings(any())) .thenThrow(new DocumentContentCheckerException(new RuntimeException("test"))); - underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), FinremCaseDetails.builder().build(), AUTH_TOKEN); - assertThat(logs.getErrors()).isNotEmpty().contains("Unexpected error when getting warnings from " + DocxDocumentChecker.class.getName()); + underTest.getWarnings(caseDocument, FinremCaseDetails.builder().build(), FinremCaseDetails.builder().id(Long.valueOf(CASE_ID)).build(), + AUTH_TOKEN); + assertThat(logs.getErrors()).isNotEmpty().contains(format("%s Unexpected error when getting warnings from %s", CASE_ID, + DocxDocumentChecker.class.getName())); } @Test From 49351878c02559c6d9e4f406d60ba69be8e00584 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 17 Jul 2024 18:04:41 +0100 Subject: [PATCH 89/96] DFR-3195 Fixing null documentlink --- .../model/ccd/CaseDocument.java | 4 ++++ .../service/NewUploadedDocumentsService.java | 24 +++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocument.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocument.java index ff2773faae..903accd62e 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/CaseDocument.java @@ -41,4 +41,8 @@ public CaseDocument(CaseDocument caseDocuments) { this.categoryId = caseDocuments.getCategoryId(); this.uploadTimestamp = caseDocuments.getUploadTimestamp(); } + + public String getDocumentUrl() { + return this.documentUrl == null ? "" : this.documentUrl; + } } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsService.java index 2f0e7030e6..b2f880c16b 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsService.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsService.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.service; import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; @@ -9,11 +10,16 @@ import java.util.List; import java.util.function.Function; +import static java.util.Optional.ofNullable; import static org.apache.commons.lang3.ObjectUtils.isEmpty; @Service public class NewUploadedDocumentsService { + private CaseDocument nullSafeCaseDocument(CaseDocument caseDocument) { + return ofNullable(caseDocument).orElse(CaseDocument.builder().build()); + } + public > List getNewUploadDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore, Function> accessor) { List uploadedDocuments = accessor.apply(caseData); @@ -26,13 +32,17 @@ public > List getNewUploadDocuments(Finre } List ret = new ArrayList<>(); - uploadedDocuments.forEach(d -> { - boolean exists = previousDocuments.stream() - .anyMatch(pd -> pd.getValue().getDocumentLink().getDocumentUrl().equals(d.getValue().getDocumentLink().getDocumentUrl())); - if (!exists) { - ret.add(d); - } - }); + uploadedDocuments.stream() + .filter(d -> d.getValue() != null) + .forEach(d -> { + boolean exists = previousDocuments.stream() + .filter(pd -> pd.getValue() != null) + .anyMatch(pd -> nullSafeCaseDocument(pd.getValue().getDocumentLink()).getDocumentUrl().equals( + nullSafeCaseDocument(d.getValue().getDocumentLink()).getDocumentUrl())); + if (!exists) { + ret.add(d); + } + }); return ret; } From 30319d59d570cbefce8326a523604742e1acf642 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Wed, 17 Jul 2024 18:13:24 +0100 Subject: [PATCH 90/96] Test case updated. --- .../NewUploadedDocumentsServiceTest.java | 68 +++++++++++++++++-- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java index 48d1f28984..b281bb44b6 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java @@ -19,7 +19,7 @@ class NewUploadedDocumentsServiceTest { - private NewUploadedDocumentsService underTest = new NewUploadedDocumentsService(); + private final NewUploadedDocumentsService underTest = new NewUploadedDocumentsService(); private static Stream provideArguments() { final List existingUploadGeneralDocument = List.of( @@ -29,6 +29,18 @@ private static Stream provideArguments() { .build()) .build() ); + final List existingUploadGeneralDocumentWithNullValue = List.of( + UploadGeneralDocumentCollection.builder() + .value(null) + .build() + ); + final List existingUploadGeneralDocumentWithNullDocumentLink = List.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(null) + .build()) + .build() + ); final List existingUploadDocument = List.of( UploadDocumentCollection.builder() .value(UploadDocument.builder() @@ -39,7 +51,51 @@ private static Stream provideArguments() { return Stream.of( // 1. uploadGeneralDocuments - // 1.1 with new doc + // 1.1.1 with null value in the existing docs + Arguments.of((Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocumentWithNullValue); + return finremCaseDataBuilder; + }, + (Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(Stream.concat(existingUploadGeneralDocumentWithNullValue.stream(), Stream.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(caseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .build()) + .build() + )).toList()); + return finremCaseDataBuilder; + }, + (Function) FinremCaseData::getUploadGeneralDocuments, + List.of(UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(caseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .build()) + .build()) + ), + // 1.1.2 with null document link in the existing docs + Arguments.of((Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocumentWithNullDocumentLink); + return finremCaseDataBuilder; + }, + (Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(Stream.concat(existingUploadGeneralDocumentWithNullDocumentLink.stream(), Stream.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(caseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .build()) + .build() + )).toList()); + return finremCaseDataBuilder; + }, + (Function) FinremCaseData::getUploadGeneralDocuments, + List.of(UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(caseDocument("newUrl1", "newBinaryUrl1", "newFilename1")) + .build()) + .build()) + ), + // 1.2 with new doc Arguments.of((Function) finremCaseDataBuilder -> { finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); return finremCaseDataBuilder; @@ -61,7 +117,7 @@ private static Stream provideArguments() { .build()) .build()) ), - // 1.2 without new doc - no change + // 1.3 without new doc - no change Arguments.of((Function) finremCaseDataBuilder -> { finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); return finremCaseDataBuilder; @@ -73,7 +129,7 @@ private static Stream provideArguments() { (Function) FinremCaseData::getUploadGeneralDocuments, List.of() ), - // 1.3 with multiple new docs + // 1.4 with multiple new docs Arguments.of((Function) finremCaseDataBuilder -> { finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); return finremCaseDataBuilder; @@ -106,7 +162,7 @@ private static Stream provideArguments() { .build()) .build()) ), - // 1.4 no existing doc with a new doc + // 1.5 no existing doc with a new doc Arguments.of((Function) finremCaseDataBuilder -> finremCaseDataBuilder, (Function) finremCaseDataBuilder -> { @@ -128,7 +184,7 @@ private static Stream provideArguments() { .build() ) ), - // 1.5 removing existing doc + // 1.6 removing existing doc Arguments.of((Function) finremCaseDataBuilder -> { finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); return finremCaseDataBuilder; From 5aed5959c7784553f948e4c5967274b3dd571164 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 18 Jul 2024 12:45:16 +0100 Subject: [PATCH 91/96] resolve merge error unit test --- .../DuplicateFilenameDocumentCheckerTest.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index 5d6fac0216..a7a4a410b2 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -86,6 +86,7 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadOrderCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.VariationDocumentType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.VariationDocumentTypeCollection; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.BulkPrintCoversheetWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ConsentOrderWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.DraftDirectionWrapper; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.GeneralApplicationWrapper; @@ -821,31 +822,31 @@ static Stream testGetWarningsOnExistingCase() { .approvedConsentOrderLetter(DUPLICATED_CASE_DOCUMENT) .build()), Arguments.of(FinremCaseData.builder() - .bulkPrintCoverSheetApp(DUPLICATED_CASE_DOCUMENT) + .bulkPrintCoversheetWrapper(BulkPrintCoversheetWrapper.builder().bulkPrintCoverSheetApp(DUPLICATED_CASE_DOCUMENT).build()) .build()), Arguments.of(FinremCaseData.builder() - .bulkPrintCoverSheetRes(DUPLICATED_CASE_DOCUMENT) + .bulkPrintCoversheetWrapper(BulkPrintCoversheetWrapper.builder().bulkPrintCoverSheetRes(DUPLICATED_CASE_DOCUMENT).build()) .build()), Arguments.of(FinremCaseData.builder() - .bulkPrintCoverSheetIntv1(DUPLICATED_CASE_DOCUMENT) + .bulkPrintCoversheetWrapper(BulkPrintCoversheetWrapper.builder().bulkPrintCoverSheetIntv1(DUPLICATED_CASE_DOCUMENT).build()) .build()), Arguments.of(FinremCaseData.builder() - .bulkPrintCoverSheetIntv2(DUPLICATED_CASE_DOCUMENT) + .bulkPrintCoversheetWrapper(BulkPrintCoversheetWrapper.builder().bulkPrintCoverSheetIntv2(DUPLICATED_CASE_DOCUMENT).build()) .build()), Arguments.of(FinremCaseData.builder() - .bulkPrintCoverSheetIntv3(DUPLICATED_CASE_DOCUMENT) + .bulkPrintCoversheetWrapper(BulkPrintCoversheetWrapper.builder().bulkPrintCoverSheetIntv3(DUPLICATED_CASE_DOCUMENT).build()) .build()), Arguments.of(FinremCaseData.builder() - .bulkPrintCoverSheetIntv4(DUPLICATED_CASE_DOCUMENT) + .bulkPrintCoversheetWrapper(BulkPrintCoversheetWrapper.builder().bulkPrintCoverSheetIntv4(DUPLICATED_CASE_DOCUMENT).build()) .build()), Arguments.of(FinremCaseData.builder() .formA(DUPLICATED_CASE_DOCUMENT) .build()), Arguments.of(FinremCaseData.builder() - .bulkPrintCoverSheetAppConfidential(DUPLICATED_CASE_DOCUMENT) + .bulkPrintCoversheetWrapper(BulkPrintCoversheetWrapper.builder().bulkPrintCoverSheetAppConfidential(DUPLICATED_CASE_DOCUMENT).build()) .build()), Arguments.of(FinremCaseData.builder() - .bulkPrintCoverSheetResConfidential(DUPLICATED_CASE_DOCUMENT) + .bulkPrintCoversheetWrapper(BulkPrintCoversheetWrapper.builder().bulkPrintCoverSheetResConfidential(DUPLICATED_CASE_DOCUMENT).build()) .build()), Arguments.of(FinremCaseData.builder() .divorceUploadPetition(DUPLICATED_CASE_DOCUMENT) From dbe8f6e4d4f04167617f0309de09c5bc3bde0c21 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Thu, 18 Jul 2024 12:59:38 +0100 Subject: [PATCH 92/96] Fix test case --- .../model/ccd/wrapper/BulkPrintCoversheetWrapper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/BulkPrintCoversheetWrapper.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/BulkPrintCoversheetWrapper.java index aabd463609..2eef9dd435 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/BulkPrintCoversheetWrapper.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/model/ccd/wrapper/BulkPrintCoversheetWrapper.java @@ -7,6 +7,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument; @JsonIgnoreProperties(ignoreUnknown = true) @Data @@ -14,7 +15,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class BulkPrintCoversheetWrapper { +public class BulkPrintCoversheetWrapper implements HasCaseDocument { private CaseDocument bulkPrintCoverSheetApp; private CaseDocument bulkPrintCoverSheetRes; private CaseDocument bulkPrintCoverSheetIntv1; From b20fc27a08f4b1a4ac2bab72f8afcf9a9107e90e Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 19 Jul 2024 11:23:27 +0100 Subject: [PATCH 93/96] Wrap the warnings check in an exception block --- ...DocumentConsentedAboutToSubmitHandler.java | 41 ++++++++++++------ ...DocumentContestedAboutToSubmitHandler.java | 39 +++++++++++------ ...mentConsentedAboutToSubmitHandlerTest.java | 42 +++++++++++++++++-- ...mentContestedAboutToSubmitHandlerTest.java | 42 +++++++++++++++++-- 4 files changed, 130 insertions(+), 34 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java index 5b3432ffaf..8ff5016dc2 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandler.java @@ -1,8 +1,8 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.handler; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; @@ -10,12 +10,15 @@ import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData; import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails; +import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.UploadDocumentCollection; import uk.gov.hmcts.reform.finrem.caseorchestration.service.NewUploadedDocumentsService; import uk.gov.hmcts.reform.finrem.caseorchestration.service.documentchecker.DocumentCheckerService; +import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; + +import static java.lang.String.format; @Slf4j @Service @@ -47,21 +50,33 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem FinremCaseDetails finremCaseDetails = callbackRequest.getCaseDetails(); FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); + final Long caseId = finremCaseDetails.getId(); + + List newDocuments = newUploadedDocumentsService.getNewUploadDocuments(caseData, caseDataBefore, + FinremCaseData::getUploadDocuments); + + Set allWarnings = new HashSet<>(); + for (UploadDocumentCollection doc : newDocuments) { + if (doc.getValue() != null && doc.getValue().getDocumentLink() != null) { + try { + List warnings = documentCheckerService.getWarnings(doc.getValue().getDocumentLink(), beforeFinremCaseDetails, + finremCaseDetails, userAuthorisation); + if (!ObjectUtils.isEmpty(warnings)) { + allWarnings.addAll(warnings); + } + } catch (Exception t) { + log.error(format("%s - Exception was caught when checking the warnings", caseId), t); + } + } + } - final Set warnings = newUploadedDocumentsService.getNewUploadDocuments(caseData, caseDataBefore, FinremCaseData::getUploadDocuments) - .stream() - .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), beforeFinremCaseDetails, finremCaseDetails, - userAuthorisation)) - .flatMap(List::stream) - .filter(ObjectUtils::isNotEmpty) - .collect(Collectors.toSet()); - if (!warnings.isEmpty()) { - log.info("Number of warnings encountered when uploading document for a case {}: {}", - finremCaseDetails.getId(), warnings.size()); + if (!allWarnings.isEmpty()) { + log.info(format("%s - Number of warnings encountered when uploading document: %s", + caseId, allWarnings.size())); } return GenericAboutToStartOrSubmitCallbackResponse.builder() - .warnings((warnings.stream().sorted().toList())) + .warnings((allWarnings.stream().sorted().toList())) .data(caseData).build(); } diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java index 55690e4401..c7691d80a3 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandler.java @@ -1,8 +1,8 @@ package uk.gov.hmcts.reform.finrem.caseorchestration.handler; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType; import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper; @@ -18,10 +18,11 @@ import java.util.ArrayList; import java.util.Comparator; +import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; +import static java.lang.String.format; import static java.util.Comparator.comparing; import static java.util.Comparator.nullsLast; import static java.util.Optional.ofNullable; @@ -59,17 +60,29 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem FinremCaseDetails finremCaseDetails = callbackRequest.getCaseDetails(); FinremCaseData caseData = finremCaseDetails.getData(); FinremCaseData caseDataBefore = callbackRequest.getCaseDetailsBefore().getData(); + final Long caseId = finremCaseDetails.getId(); - final Set warnings = newUploadedDocumentsService.getNewUploadDocuments(caseData, caseDataBefore, - FinremCaseData::getUploadGeneralDocuments).stream() - .map(d -> documentCheckerService.getWarnings(d.getValue().getDocumentLink(), beforeFinremCaseDetails, finremCaseDetails, - userAuthorisation)) - .flatMap(List::stream) - .filter(ObjectUtils::isNotEmpty) - .collect(Collectors.toSet()); - if (!warnings.isEmpty()) { - log.info("Number of warnings encountered when uploading general document for a case {}: {}", - finremCaseDetails.getId(), warnings.size()); + List newDocuments = newUploadedDocumentsService.getNewUploadDocuments(caseData, caseDataBefore, + FinremCaseData::getUploadGeneralDocuments); + + Set allWarnings = new HashSet<>(); + for (UploadGeneralDocumentCollection doc : newDocuments) { + if (doc.getValue() != null && doc.getValue().getDocumentLink() != null) { + try { + List warnings = documentCheckerService.getWarnings(doc.getValue().getDocumentLink(), beforeFinremCaseDetails, + finremCaseDetails, userAuthorisation); + if (!ObjectUtils.isEmpty(warnings)) { + allWarnings.addAll(warnings); + } + } catch (Exception t) { + log.error(format("%s - Exception was caught when checking the warnings", caseId), t); + } + } + } + + if (!allWarnings.isEmpty()) { + log.info(format("%s - Number of warnings encountered when uploading general document: %s", + caseId, allWarnings.size())); } // Do sorting @@ -83,7 +96,7 @@ public GenericAboutToStartOrSubmitCallbackResponse handle(Finrem uploadGeneralDocumentsCategoriser.categorise(caseData); return GenericAboutToStartOrSubmitCallbackResponse.builder() - .warnings(warnings.stream().sorted().toList()) + .warnings(allWarnings.stream().sorted().toList()) .data(caseData).build(); } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java index e7c61a2c13..8f1e2981fc 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentConsentedAboutToSubmitHandlerTest.java @@ -63,13 +63,47 @@ void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadDocumentConsen assertCanHandle(underTest, CallbackType.ABOUT_TO_SUBMIT, CaseType.CONSENTED, EventType.UPLOAD_DOCUMENT_CONSENTED); } + @Test + void givenValidCaseDataWithoutDocumentUploaded_thenNoWarningShouldBeReturned() { + when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( + UploadDocumentCollection.builder() + .value(UploadDocument.builder().documentEmailContent("").build()) // no documentLink + .build() + )); + when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenReturn(List.of("whatever")); // never reach + + GenericAboutToStartOrSubmitCallbackResponse response = underTest.handle( + FinremCallbackRequest.builder() + .caseDetails(FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONSENTED).build()) + .caseDetailsBefore(FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONSENTED).build()).build(), + AUTH_TOKEN); + assertThat(response.getWarnings()).isEmpty(); + } + + @Test + void givenValidCaseDataWithDocumentUpload_whenUnexpectedExceptionThrownInWarningChecking_thenNotBlockTheSubmission() { + when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( + UploadDocumentCollection.builder() + .value(UploadDocument.builder().documentLink(caseDocument()).build()) + .build() + )); + when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenThrow(new RuntimeException("unexpected exception")); + + GenericAboutToStartOrSubmitCallbackResponse response = underTest.handle( + FinremCallbackRequest.builder() + .caseDetails(FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONSENTED).build()) + .caseDetailsBefore(FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONSENTED).build()).build(), + AUTH_TOKEN); + assertThat(response.getWarnings()).isEmpty(); + } + @ParameterizedTest @ValueSource(booleans = {true, false}) void givenValidCaseData_whenWarningIsDetected_thenPopulateWarning(boolean hasWarnings) { List expectedWarnings = hasWarnings ? List.of("warnings") : List.of(); when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( UploadDocumentCollection.builder() - .value(UploadDocument.builder().build()) + .value(UploadDocument.builder().documentLink(caseDocument()).build()) .build() )); when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenReturn(expectedWarnings); @@ -94,7 +128,7 @@ void givenValidCaseData_whenWarningIsDetected_thenPopulateWarning(boolean hasWar assertThat(response.getWarnings()).isEqualTo(expectedWarnings); if (hasWarnings) { assertThat(logs.getInfos()).containsExactly(format( - "Number of warnings encountered when uploading document for a case %s: %s", CASE_ID, 1)); + "%s - Number of warnings encountered when uploading document: %s", CASE_ID, 1)); } else { assertThat(logs.getInfos()).isEmpty(); } @@ -105,7 +139,7 @@ void givenValidCaseData_whenWarningIsDetected_thenPopulateWarning(boolean hasWar void givenValidCaseData_whenWarningsAreDetected_thenPopulateSortedWarnings(boolean hasWarnings) { when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( UploadDocumentCollection.builder() - .value(UploadDocument.builder().build()) + .value(UploadDocument.builder().documentLink(caseDocument()).build()) .build() )); when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenReturn(hasWarnings ? List.of("2warnings", "1warnings", "1warnings", @@ -131,7 +165,7 @@ void givenValidCaseData_whenWarningsAreDetected_thenPopulateSortedWarnings(boole assertThat(response.getWarnings()).isEqualTo(hasWarnings ? List.of("1warnings", "2warnings", "Aae", "abc") : List.of()); if (hasWarnings) { assertThat(logs.getInfos()).containsExactly(format( - "Number of warnings encountered when uploading document for a case %s: %s", CASE_ID, 4)); + "%s - Number of warnings encountered when uploading document: %s", CASE_ID, 4)); } else { assertThat(logs.getInfos()).isEmpty(); } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java index dd723e2c8b..384530402f 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/handler/UploadDocumentContestedAboutToSubmitHandlerTest.java @@ -68,13 +68,47 @@ void givenACcdCallbackContestedCase_WhenAnAboutToSubmitEventUploadDocumentContes assertCanHandle(underTest, CallbackType.ABOUT_TO_SUBMIT, CaseType.CONTESTED, EventType.UPLOAD_DOCUMENT_CONTESTED); } + @Test + void givenValidCaseDataWithoutDocumentUploaded_thenNoWarningShouldBeReturned() { + when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder().documentEmailContent("").build()) // no documentLink + .build() + )); + when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenReturn(List.of("whatever")); // never reach + + GenericAboutToStartOrSubmitCallbackResponse response = underTest.handle( + FinremCallbackRequest.builder() + .caseDetails(FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONTESTED).build()) + .caseDetailsBefore(FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONTESTED).build()).build(), + AUTH_TOKEN); + assertThat(response.getWarnings()).isEmpty(); + } + + @Test + void givenValidCaseDataWithDocumentUpload_whenUnexpectedExceptionThrownInWarningChecking_thenNotBlockTheSubmission() { + when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder().documentLink(caseDocument()).build()) + .build() + )); + when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenThrow(new RuntimeException("unexpected exception")); + + GenericAboutToStartOrSubmitCallbackResponse response = underTest.handle( + FinremCallbackRequest.builder() + .caseDetails(FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONTESTED).build()) + .caseDetailsBefore(FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID), CaseType.CONTESTED).build()).build(), + AUTH_TOKEN); + assertThat(response.getWarnings()).isEmpty(); + } + @ParameterizedTest @ValueSource(booleans = {true, false}) void givenValidCaseData_whenWarningIsDetected_thenPopulateWarning(boolean hasWarnings) { List expectedWarnings = hasWarnings ? List.of("warnings") : List.of(); when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( UploadGeneralDocumentCollection.builder() - .value(UploadGeneralDocument.builder().build()) + .value(UploadGeneralDocument.builder().documentLink(caseDocument()).build()) .build() )); when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenReturn(expectedWarnings); @@ -99,7 +133,7 @@ void givenValidCaseData_whenWarningIsDetected_thenPopulateWarning(boolean hasWar assertThat(response.getWarnings()).isEqualTo(expectedWarnings); if (hasWarnings) { assertThat(logs.getInfos()).containsExactly(format( - "Number of warnings encountered when uploading general document for a case %s: %s", CASE_ID, 1)); + "%s - Number of warnings encountered when uploading general document: %s", CASE_ID, 1)); } else { assertThat(logs.getInfos()).isEmpty(); } @@ -110,7 +144,7 @@ void givenValidCaseData_whenWarningIsDetected_thenPopulateWarning(boolean hasWar void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasWarnings) { when(newUploadedDocumentsService.getNewUploadDocuments(any(), any(), any())).thenReturn(List.of( UploadGeneralDocumentCollection.builder() - .value(UploadGeneralDocument.builder().build()) + .value(UploadGeneralDocument.builder().documentLink(caseDocument()).build()) .build() )); when(documentCheckerService.getWarnings(any(), any(), any(), any())).thenReturn(hasWarnings ? List.of("2warnings", "2warnings", "1warnings") @@ -136,7 +170,7 @@ void givenValidCaseData_whenWarningAreDetected_thenPopulateWarnings(boolean hasW assertThat(response.getWarnings()).isEqualTo(hasWarnings ? List.of("1warnings", "2warnings") : List.of()); if (hasWarnings) { assertThat(logs.getInfos()).containsExactly(format( - "Number of warnings encountered when uploading general document for a case %s: %s", CASE_ID, 2)); + "%s - Number of warnings encountered when uploading general document: %s", CASE_ID, 2)); } else { assertThat(logs.getInfos()).isEmpty(); } From 3d8b4752fde58ba07c2a4347dad8e49f366317e4 Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 19 Jul 2024 12:12:51 +0100 Subject: [PATCH 94/96] DFR-3197 - Upload document warnings causes NPE because "hcd" is null --- .../DuplicateFilenameDocumentChecker.java | 44 ++++++++++--------- .../DuplicateFilenameDocumentCheckerTest.java | 25 +++++++++++ 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java index b667979253..8d7d88b4a1 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentChecker.java @@ -56,6 +56,9 @@ private static void processList(List list, List all * @param allDocuments the list to which collected {@link DocumentFileNameProvider} instances will be added */ private static void processHasCaseDocument(HasCaseDocument hcd, List allDocuments) { + if (hcd == null) { + return; + } try { // Collect all fields from HasCaseDocument class Field[] fields = hcd.getClass().getDeclaredFields(); @@ -77,7 +80,7 @@ private static void processHasCaseDocument(HasCaseDocument hcd, List collectCaseDocumentsFromFinremCaseData(Fi @Override public List getWarnings(DocumentCheckContext context) throws DocumentContentCheckerException { CaseDocument caseDocument = context.getCaseDocument(); - List allDocuments = collectCaseDocumentsFromFinremCaseData(context.getBeforeCaseDetails().getData()); + if (caseDocument != null) { + List allDocuments = collectCaseDocumentsFromFinremCaseData(context.getBeforeCaseDetails().getData()); - // Check for duplicate filenames in the collected documents - boolean hasDuplicates = allDocuments.stream() - .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d))); + // Check for duplicate filenames in the collected documents + boolean hasDuplicates = allDocuments.stream() + .anyMatch(d -> isDuplicateFilename(caseDocument, () -> List.of(d))); - if (hasDuplicates) { - return List.of(WARNING); - } + if (hasDuplicates) { + return List.of(WARNING); + } - // check if duplication occurs on uploading documents - FinremCaseData newCaseData = context.getCaseDetails().getData(); - if ( - (newCaseData.isConsentedApplication() - && ofNullable(newCaseData.getUploadDocuments()).orElse(List.of()).stream() + // check if duplication occurs on uploading documents + FinremCaseData newCaseData = context.getCaseDetails().getData(); + if ( + (newCaseData.isConsentedApplication() + && ofNullable(newCaseData.getUploadDocuments()).orElse(List.of()).stream() .map(d -> ofNullable(d.getValue()).orElse(UploadDocument.builder().build()).getDocumentLink()) .filter(Objects::nonNull) .filter(d -> isDuplicateFilename(caseDocument, () -> List.of(d))).count() > 1) - || - (newCaseData.isContestedApplication() - && ofNullable(newCaseData.getUploadGeneralDocuments()).orElse(List.of()).stream() + || + (newCaseData.isContestedApplication() + && ofNullable(newCaseData.getUploadGeneralDocuments()).orElse(List.of()).stream() .map(d -> ofNullable(d.getValue()).orElse(UploadGeneralDocument.builder().build()).getDocumentLink()) .filter(Objects::nonNull) - .filter(d -> isDuplicateFilename(caseDocument, () -> List.of(d))).count() > 1) - ) { - return List.of(WARNING); + .filter(d -> isDuplicateFilename(caseDocument, () -> List.of(d))).count() > 1) + ) { + return List.of(WARNING); + } } - return Collections.emptyList(); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java index a7a4a410b2..8fc0c91fc0 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/DuplicateFilenameDocumentCheckerTest.java @@ -104,6 +104,7 @@ import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; +import static uk.gov.hmcts.reform.finrem.caseorchestration.service.IntervenerServiceTest.CASE_ID; @ExtendWith(MockitoExtension.class) @MockitoSettings(strictness = Strictness.LENIENT) @@ -153,6 +154,30 @@ void testGetWarnings_noDuplication(CaseType caseType) throws DocumentContentChec assertThat(warnings).isEmpty(); } + @ParameterizedTest + @EnumSource(value = CaseType.class, names = {"CONTESTED", "CONSENTED"}) + void givenCaseDocumentIsNull(CaseType caseType) throws DocumentContentCheckerException { + List warnings = underTest.getWarnings(DocumentCheckContext.builder() + .caseDocument(null) + .bytes(new byte[0]) + .beforeCaseDetails(FinremCaseDetailsBuilderFactory.from(CASE_ID, caseType, FinremCaseData.builder() + .uploadGeneralDocuments(List.of(UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder().build()) + .build())) + .additionalDocument(CaseDocument.builder().documentFilename("additionalDocument").build()) + .generalOrderWrapper(GeneralOrderWrapper.builder() + .generalOrderLatestDocument(CaseDocument.builder().documentFilename("generalOrderLatestDocument").build()) + .build())).build()) + .caseDetails(FinremCaseDetailsBuilderFactory.from(CASE_ID, caseType, + FinremCaseData.builder().uploadDocuments(List.of(UploadDocumentCollection.builder().value(UploadDocument.builder() + .documentLink(DUPLICATED_CASE_DOCUMENT) + .build()).build())) + ).build()) + .build()); + + assertThat(warnings).isEmpty(); + } + static Stream testGetWarningsOnExistingCase() { return Stream.of( Arguments.of(FinremCaseData.builder() From e2ea10939af44c49872a1b3217eed230b66a2cae Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 19 Jul 2024 12:40:30 +0100 Subject: [PATCH 95/96] Handling the case when documentLink is null --- .../service/NewUploadedDocumentsService.java | 14 ++++++++++++-- .../NewUploadedDocumentsServiceTest.java | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsService.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsService.java index b2f880c16b..ac8a2eefdb 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsService.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsService.java @@ -20,6 +20,16 @@ private CaseDocument nullSafeCaseDocument(CaseDocument caseDocument) { return ofNullable(caseDocument).orElse(CaseDocument.builder().build()); } + /** + * Retrieves a list of newly uploaded documents by comparing the current case data with the previous case data. + * The existence of caseDocumentLink is the key factor of the comparison. + * + * @param the type parameter extending {@code CaseDocumentCollection} + * @param caseData the current {@code FinremCaseData} + * @param caseDataBefore the previous {@code FinremCaseData} + * @param accessor a function that extracts the list of documents from the {@code FinremCaseData} + * @return a list of newly uploaded documents, or an empty list if no new documents are found + */ public > List getNewUploadDocuments(FinremCaseData caseData, FinremCaseData caseDataBefore, Function> accessor) { List uploadedDocuments = accessor.apply(caseData); @@ -33,10 +43,10 @@ public > List getNewUploadDocuments(Finre List ret = new ArrayList<>(); uploadedDocuments.stream() - .filter(d -> d.getValue() != null) + .filter(d -> d.getValue() != null && d.getValue().getDocumentLink() != null) .forEach(d -> { boolean exists = previousDocuments.stream() - .filter(pd -> pd.getValue() != null) + .filter(pd -> pd.getValue() != null && pd.getValue().getDocumentLink() != null) .anyMatch(pd -> nullSafeCaseDocument(pd.getValue().getDocumentLink()).getDocumentUrl().equals( nullSafeCaseDocument(d.getValue().getDocumentLink()).getDocumentUrl())); if (!exists) { diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java index b281bb44b6..ec4afea53c 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/NewUploadedDocumentsServiceTest.java @@ -95,6 +95,24 @@ private static Stream provideArguments() { .build()) .build()) ), + // 1.1.2 with null document link in the new doc + Arguments.of((Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); + return finremCaseDataBuilder; + }, + (Function) finremCaseDataBuilder -> { + finremCaseDataBuilder.uploadGeneralDocuments(Stream.concat(existingUploadGeneralDocument.stream(), Stream.of( + UploadGeneralDocumentCollection.builder() + .value(UploadGeneralDocument.builder() + .documentLink(null) + .build()) + .build() + )).toList()); + return finremCaseDataBuilder; + }, + (Function) FinremCaseData::getUploadGeneralDocuments, + List.of() + ), // 1.2 with new doc Arguments.of((Function) finremCaseDataBuilder -> { finremCaseDataBuilder.uploadGeneralDocuments(existingUploadGeneralDocument); From 97ebea60ef15ba66377cf5529dec15cf338bc0ff Mon Sep 17 00:00:00 2001 From: Ashley Wong Date: Fri, 19 Jul 2024 13:12:58 +0100 Subject: [PATCH 96/96] DFR-3198 Upload document warnings causes java.lang.NumberFormatException --- .../contentchecker/CaseNumberDocumentContentChecker.java | 8 ++++---- .../CaseNumberDocumentContentCheckerTest.java | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java index 6da1617158..4636151507 100644 --- a/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java +++ b/src/main/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentChecker.java @@ -29,15 +29,15 @@ private boolean containsCaseNumber(String text) { } private boolean contentCaseNumberNotEqualsCaseNumber(FinremCaseDetails caseDetails, String content) { - long caseNumberFromContent = getCaseNumberFromContent(content); + String caseNumberFromContent = getCaseNumberFromContent(content); if (caseDetails.getId() == null) { return false; } - return caseNumberFromContent != caseDetails.getId(); + return !String.valueOf(caseDetails.getId()).equals(caseNumberFromContent); } - private long getCaseNumberFromContent(String text) { - return Long.parseLong(CharMatcher.inRange('0', '9').retainFrom(text)); + private String getCaseNumberFromContent(String text) { + return defaultString(CharMatcher.inRange('0', '9').retainFrom(text)); } } diff --git a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java index a56504ab30..6a13ceeba9 100644 --- a/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/finrem/caseorchestration/service/documentchecker/contentchecker/CaseNumberDocumentContentCheckerTest.java @@ -26,14 +26,16 @@ void givenCaseData_whenContentContainCaseNumber(String validContent) { } @ParameterizedTest - @ValueSource(strings = {"Case number 1234567891", "Case No: 1234567891", "Reference number: 1234567891"}) + @ValueSource(strings = {"Case number 1234567891", "Case No: 1234567891", "Reference number: 1234567891", + "Case number 1701101433943871302024"}) void givenCaseData_whenContentDoesNotMatchCaseNumber(String caseNumber) { assertThat(underTest.getWarning(FinremCaseDetailsBuilderFactory.from(Long.valueOf(CASE_ID)).build(), new String[] {caseNumber})).isEqualTo("Case numbers may not match"); } @ParameterizedTest - @ValueSource(strings = {"Case number 1234567890", "Case No: 1234567890", "Reference number: 1234567890", "whatever", ""}) + @ValueSource(strings = {"Case number 1234567890", "Case No: 1234567890", "Reference number: 1234567890", "whatever", "", + "Case number 1701101433943871302024"}) @NullSource void givenCaseDataWithoutId_whenContentDoesNotMatchCaseNumber(String content) { Arrays.stream(StringDecorator.values()).forEach(contentDecorator ->