diff --git a/docker/docmosis/templates/CV-SPC-DEC-WEL-00915.docx b/docker/docmosis/templates/CV-SPC-DEC-WEL-00915.docx new file mode 100644 index 00000000000..e8598dfdd5c Binary files /dev/null and b/docker/docmosis/templates/CV-SPC-DEC-WEL-00915.docx differ diff --git a/docker/docmosis/templates/CV-SPC-DEC-WEL-00916.docx b/docker/docmosis/templates/CV-SPC-DEC-WEL-00916.docx new file mode 100644 index 00000000000..00dbbf3e919 Binary files /dev/null and b/docker/docmosis/templates/CV-SPC-DEC-WEL-00916.docx differ diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/claimantresponse/JudgmentByAdmissionOrDetermination.java b/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/claimantresponse/JudgmentByAdmissionOrDetermination.java index 831a8b22b4f..2961c98bede 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/claimantresponse/JudgmentByAdmissionOrDetermination.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/claimantresponse/JudgmentByAdmissionOrDetermination.java @@ -16,7 +16,7 @@ import java.time.LocalDate; import java.util.List; -@Builder +@Builder(toBuilder = true) @Getter @EqualsAndHashCode public class JudgmentByAdmissionOrDetermination implements MappableObject { @@ -61,4 +61,9 @@ public class JudgmentByAdmissionOrDetermination implements MappableObject { private final String installmentAmount; private final String payByDate; private final String applicantReference; + private final String welshDate; + private final String welshPayByDate; + private final String welshRepaymentDate; + private final String welshRepaymentFrequency; + private final String welshPaymentStr; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/claimantresponse/JudgmentByAdmissionOrDeterminationMapper.java b/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/claimantresponse/JudgmentByAdmissionOrDeterminationMapper.java index ecdda3807c7..58f710380f3 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/claimantresponse/JudgmentByAdmissionOrDeterminationMapper.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/claimantresponse/JudgmentByAdmissionOrDeterminationMapper.java @@ -28,6 +28,7 @@ import java.util.Optional; import static uk.gov.hmcts.reform.civil.enums.RespondentResponsePartAdmissionPaymentTimeLRspec.IMMEDIATELY; +import static uk.gov.hmcts.reform.civil.utils.DateUtils.formatDateInWelsh; import static uk.gov.hmcts.reform.civil.utils.JudgmentOnlineUtils.getApplicant; import static uk.gov.hmcts.reform.civil.utils.JudgmentOnlineUtils.getApplicantSolicitorRef; import static uk.gov.hmcts.reform.civil.utils.JudgmentOnlineUtils.getOrgDetails; @@ -43,6 +44,7 @@ public class JudgmentByAdmissionOrDeterminationMapper { private final JudgementService judgementService; private final OrganisationService organisationService; private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d MMMM yyyy 'at' h:mma"); + private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy"); public JudgmentByAdmissionOrDetermination toClaimantResponseForm(CaseData caseData, CaseEvent caseEvent) { Optional caseDataLip = Optional.ofNullable(caseData.getCaseDataLiP()); @@ -236,6 +238,34 @@ public JudgmentByAdmissionOrDetermination toNonDivergentDocs(CaseData caseData) .build(); } + public JudgmentByAdmissionOrDetermination toNonDivergentWelshDocs(CaseData caseData, JudgmentByAdmissionOrDetermination builder) { + return builder.toBuilder() + .welshDate(formatDateInWelsh(LocalDate.now())) + .welshPayByDate(getWelshPayByDate(caseData)) + .welshRepaymentDate(getWelshRepaymentDate(caseData)) + .welshRepaymentFrequency(caseData.isPayByInstallment() + ? getRepaymentFrequencyInWelsh(caseData.getRespondent1RepaymentPlan().getRepaymentFrequency()) : null) + .welshPaymentStr(caseData.isPayByInstallment() ? getRepaymentWelshString(caseData.getRespondent1RepaymentPlan().getRepaymentFrequency()) : null) + .build(); + } + + private String getWelshPayByDate(CaseData caseData) { + return caseData.getRespondToClaimAdmitPartLRspec() != null + ? formatDateInWelsh(LocalDate.parse( + DateFormatHelper.formatLocalDate( + caseData.getRespondToClaimAdmitPartLRspec().getWhenWillThisAmountBePaid(), + DateFormatHelper.DATE + ), dateTimeFormatter)) : null; + } + + private String getWelshRepaymentDate(CaseData caseData) { + return caseData.isPayByInstallment() + ? formatDateInWelsh(LocalDate.parse(DateFormatHelper.formatLocalDate( + caseData.getRespondent1RepaymentPlan().getFirstRepaymentDate(), + DateFormatHelper.DATE + ), dateTimeFormatter)) : null; + } + private String getRepaymentString(PaymentFrequencyLRspec repaymentFrequency) { switch (repaymentFrequency) { case ONCE_ONE_WEEK : return "each week"; @@ -245,6 +275,15 @@ private String getRepaymentString(PaymentFrequencyLRspec repaymentFrequency) { } } + private String getRepaymentWelshString(PaymentFrequencyLRspec repaymentFrequency) { + switch (repaymentFrequency) { + case ONCE_ONE_WEEK : return "pob mis"; + case ONCE_ONE_MONTH: return "pob mis"; + case ONCE_TWO_WEEKS: return "pob 2 wythnos"; + default: return null; + } + } + private String getRepaymentFrequency(PaymentFrequencyLRspec repaymentFrequency) { switch (repaymentFrequency) { case ONCE_ONE_WEEK : return "per week"; @@ -254,6 +293,15 @@ private String getRepaymentFrequency(PaymentFrequencyLRspec repaymentFrequency) } } + private String getRepaymentFrequencyInWelsh(PaymentFrequencyLRspec repaymentFrequency) { + switch (repaymentFrequency) { + case ONCE_ONE_WEEK : return "yr wythnos"; + case ONCE_ONE_MONTH: return "y mis"; + case ONCE_TWO_WEEKS: return "bob pythefnos"; + default: return null; + } + } + private String getPaymentTypeForNonDivergent(CaseData caseData) { if (caseData.getDefenceAdmitPartPaymentTimeRouteRequired() != null && caseData.getDefenceAdmitPartPaymentTimeRouteRequired() == IMMEDIATELY) { diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/DocmosisTemplates.java b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/DocmosisTemplates.java index a0ccdb369fc..7d533c1ef63 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/DocmosisTemplates.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/DocmosisTemplates.java @@ -95,6 +95,8 @@ public enum DocmosisTemplates { DEFAULT_JUDGMENT_COVER_LETTER_DEFENDANT_LEGAL_ORG("CV-CMC-LET-ENG-LR-JO0002.docx", "cover_letter.pdf"), JUDGMENT_BY_ADMISSION_CLAIMANT("CV-SPC-DEC-ENG-00916.docx", "Judgment_by_admission_claimant.pdf"), JUDGMENT_BY_ADMISSION_DEFENDANT("CV-SPC-DEC-ENG-00915.docx", "Judgment_by_admission_defendant.pdf"), + JUDGMENT_BY_ADMISSION_CLAIMANT_BILINGUAL("CV-SPC-DEC-WEL-00916.docx", "Judgment_by_admission_claimant.pdf"), + JUDGMENT_BY_ADMISSION_DEFENDANT_BILINGUAL("CV-SPC-DEC-WEL-00915.docx", "Judgment_by_admission_defendant.pdf"), JUDGMENT_BY_DETERMINATION_CLAIMANT("CV-SPC-DEC-ENG-00982.docx", "Judgment_by_determination_claimant.pdf"), JUDGMENT_BY_DETERMINATION_DEFENDANT("CV-SPC-DEC-ENG-00981.docx", "Judgment_by_determination_defendant.pdf"), NOTICE_OF_DISCONTINUANCE_PDF("CV-SPC-GNO-ENG-SD0002.docx", "notice_of_discontinuance_%s.pdf"), diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/claimantresponse/RequestJudgmentByAdmissionOrDeterminationResponseDocGenerator.java b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/claimantresponse/RequestJudgmentByAdmissionOrDeterminationResponseDocGenerator.java index 01432ce2a26..72c8165219e 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/claimantresponse/RequestJudgmentByAdmissionOrDeterminationResponseDocGenerator.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/claimantresponse/RequestJudgmentByAdmissionOrDeterminationResponseDocGenerator.java @@ -12,18 +12,23 @@ import uk.gov.hmcts.reform.civil.model.docmosis.DocmosisDocument; import uk.gov.hmcts.reform.civil.model.docmosis.claimantresponse.JudgmentByAdmissionOrDetermination; import uk.gov.hmcts.reform.civil.model.docmosis.claimantresponse.JudgmentByAdmissionOrDeterminationMapper; +import uk.gov.hmcts.reform.civil.model.documents.DocumentMetaData; import uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates; import uk.gov.hmcts.reform.civil.service.docmosis.DocumentGeneratorService; import uk.gov.hmcts.reform.civil.service.docmosis.TemplateDataGenerator; +import uk.gov.hmcts.reform.civil.stitch.service.CivilStitchService; import uk.gov.hmcts.reform.civil.utils.AssignCategoryId; +import java.time.LocalDate; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import static uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType.CCJ_REQUEST_ADMISSION; import static uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType.CCJ_REQUEST_DETERMINATION; import static uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType.JUDGMENT_BY_ADMISSION_CLAIMANT; import static uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType.JUDGMENT_BY_ADMISSION_DEFENDANT; +import static uk.gov.hmcts.reform.civil.helpers.hearingsmappings.HearingDetailsMapper.isWelshHearingSelected; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.JUDGMENT_BY_ADMISSION_OR_DETERMINATION; @Service @@ -34,6 +39,7 @@ public class RequestJudgmentByAdmissionOrDeterminationResponseDocGenerator imple private final JudgmentByAdmissionOrDeterminationMapper judgmentByAdmissionOrDeterminationMapper; private final DocumentManagementService documentManagementService; private final DocumentGeneratorService documentGeneratorService; + private final CivilStitchService civilStitchService; private final AssignCategoryId assignCategoryId; public CaseDocument generate(CaseEvent caseEvent, CaseData caseData, String authorisation) { @@ -75,29 +81,40 @@ private DocumentType getDocumentType(CaseEvent caseEvent) { }; } - private DocmosisTemplates getTemplateName(CaseEvent caseEvent) { + private DocmosisTemplates getTemplateName(CaseEvent caseEvent, boolean isBilingual) { if (caseEvent.name().equals(CaseEvent.GEN_JUDGMENT_BY_ADMISSION_DOC_CLAIMANT.name())) { - return DocmosisTemplates.JUDGMENT_BY_ADMISSION_CLAIMANT; + return isBilingual ? DocmosisTemplates.JUDGMENT_BY_ADMISSION_CLAIMANT_BILINGUAL : DocmosisTemplates.JUDGMENT_BY_ADMISSION_CLAIMANT; } else { - return DocmosisTemplates.JUDGMENT_BY_ADMISSION_DEFENDANT; + return isBilingual ? DocmosisTemplates.JUDGMENT_BY_ADMISSION_DEFENDANT_BILINGUAL : DocmosisTemplates.JUDGMENT_BY_ADMISSION_DEFENDANT; } } public List generateNonDivergentDocs(CaseData caseData, String authorisation, CaseEvent caseEvent) { List list = new ArrayList<>(); + JudgmentByAdmissionOrDetermination templateData = getTemplateDataForNonDivergentDocs(caseData); DocmosisDocument docmosisDocument = documentGeneratorService.generateDocmosisDocument( - getTemplateDataForNonDivergentDocs(caseData), - getTemplateName(caseEvent) + templateData, + getTemplateName(caseEvent, false) ); - CaseDocument uploadedDocument = documentManagementService.uploadDocument( + CaseDocument engDocument = documentManagementService.uploadDocument( authorisation, new PDF( - getTemplateName(caseEvent).getDocumentTitle(), + getTemplateName(caseEvent, false).getDocumentTitle(), docmosisDocument.getBytes(), getDocumentType(caseEvent) ) ); + CaseDocument uploadedDocument = engDocument; + if (caseData.isClaimantBilingual() || isWelshHearingSelected(caseData) || caseData.isRespondentResponseBilingual()) { + uploadedDocument = generateNonDivergentWelshDocs( + caseData, + authorisation, + caseEvent, + templateData, + engDocument + ); + } assignCategoryId.assignCategoryIdToCaseDocument(uploadedDocument, "judgments"); list.add(uploadedDocument); @@ -107,4 +124,52 @@ public List generateNonDivergentDocs(CaseData caseData, String aut private JudgmentByAdmissionOrDetermination getTemplateDataForNonDivergentDocs(CaseData caseData) { return judgmentByAdmissionOrDeterminationMapper.toNonDivergentDocs(caseData); } + + private CaseDocument generateNonDivergentWelshDocs(CaseData caseData, String auth, CaseEvent caseEvent, + JudgmentByAdmissionOrDetermination templateData, CaseDocument englishDoc) { + JudgmentByAdmissionOrDetermination welshTemplateData = + judgmentByAdmissionOrDeterminationMapper.toNonDivergentWelshDocs(caseData, templateData); + + DocmosisDocument welshDocument = documentGeneratorService.generateDocmosisDocument( + welshTemplateData, + getTemplateName(caseEvent, true) + ); + + CaseDocument welshCaseDoc = documentManagementService.uploadDocument( + auth, + new PDF( + getTemplateName(caseEvent, true).getDocumentTitle(), + welshDocument.getBytes(), + getDocumentType(caseEvent) + ) + ); + + List documentMetaDataList = appendWelshDocToDocument(englishDoc, welshCaseDoc); + Long caseId = caseData.getCcdCaseReference(); + return civilStitchService.generateStitchedCaseDocument( + documentMetaDataList, + welshCaseDoc.getDocumentName(), + caseId, + getDocumentType(caseEvent), + auth + ); + } + + private List appendWelshDocToDocument(CaseDocument englishDoc, CaseDocument... welshDocuments) { + List documentMetaDataList = new ArrayList<>(); + + documentMetaDataList.add(new DocumentMetaData( + englishDoc.getDocumentLink(), + "Welsh Document", + LocalDate.now().toString() + )); + + Arrays.stream(welshDocuments).forEach(caseDocument -> documentMetaDataList.add(new DocumentMetaData( + caseDocument.getDocumentLink(), + "Welsh Doc to attach", + LocalDate.now().toString() + ))); + + return documentMetaDataList; + } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/claimantresponse/RequestJudgmentByAdmissionOrDeterminationResponseDocGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/claimantresponse/RequestJudgmentByAdmissionOrDeterminationResponseDocGeneratorTest.java index 9952ac0fad0..577ec1809f0 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/claimantresponse/RequestJudgmentByAdmissionOrDeterminationResponseDocGeneratorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/claimantresponse/RequestJudgmentByAdmissionOrDeterminationResponseDocGeneratorTest.java @@ -16,15 +16,20 @@ import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.sampledata.CaseDocumentBuilder; import uk.gov.hmcts.reform.civil.service.docmosis.DocumentGeneratorService; +import uk.gov.hmcts.reform.civil.stitch.service.CivilStitchService; import uk.gov.hmcts.reform.civil.utils.AssignCategoryId; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.times; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.GEN_JUDGMENT_BY_ADMISSION_DOC_CLAIMANT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.GEN_JUDGMENT_BY_ADMISSION_DOC_DEFENDANT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.GENERATE_JUDGMENT_BY_DETERMINATION_RESPONSE_DOC; @@ -34,6 +39,8 @@ import static uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType.CCJ_REQUEST_DETERMINATION; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.JUDGMENT_BY_ADMISSION_CLAIMANT; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.JUDGMENT_BY_ADMISSION_DEFENDANT; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.JUDGMENT_BY_ADMISSION_CLAIMANT_BILINGUAL; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.JUDGMENT_BY_ADMISSION_DEFENDANT_BILINGUAL; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.JUDGMENT_BY_ADMISSION_OR_DETERMINATION; @ExtendWith(MockitoExtension.class) @@ -55,6 +62,9 @@ class RequestJudgmentByAdmissionOrDeterminationResponseDocGeneratorTest { @Mock private AssignCategoryId assignCategoryId; + @Mock + private CivilStitchService civilStitchService; + @InjectMocks private RequestJudgmentByAdmissionOrDeterminationResponseDocGenerator generator; @@ -197,4 +207,91 @@ BEARER_TOKEN, new PDF(fileName, bytes, DocumentType.JUDGMENT_BY_ADMISSION_DEFEND .uploadDocument(BEARER_TOKEN, new PDF(fileName, bytes, DocumentType.JUDGMENT_BY_ADMISSION_DEFENDANT)); assertThat(actual).contains(caseDocument); } + + @Test + void shouldGenerateClaimantJudgementByAdmissionWelshDocument() { + // Given + String fileName = String.format(JUDGMENT_BY_ADMISSION_CLAIMANT.getDocumentTitle(), REFERENCE_NUMBER, "admission"); + CaseDocument caseDocument = CaseDocumentBuilder.builder() + .documentName(fileName) + .documentType(DocumentType.JUDGMENT_BY_ADMISSION_CLAIMANT) + .build(); + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged() + .claimantBilingualLanguagePreference("BOTH") + .build(); + JudgmentByAdmissionOrDetermination builder = JudgmentByAdmissionOrDetermination.builder().build(); + + when(documentGeneratorService.generateDocmosisDocument(any(JudgmentByAdmissionOrDetermination.class), eq(JUDGMENT_BY_ADMISSION_CLAIMANT))) + .thenReturn(new DocmosisDocument(JUDGMENT_BY_ADMISSION_CLAIMANT.getDocumentTitle(), bytes)); + + when(documentGeneratorService.generateDocmosisDocument(any(JudgmentByAdmissionOrDetermination.class), eq(JUDGMENT_BY_ADMISSION_CLAIMANT_BILINGUAL))) + .thenReturn(new DocmosisDocument(JUDGMENT_BY_ADMISSION_CLAIMANT_BILINGUAL.getDocumentTitle(), bytes)); + + when(documentManagementService.uploadDocument( + BEARER_TOKEN, new PDF(fileName, bytes, DocumentType.JUDGMENT_BY_ADMISSION_CLAIMANT)) + ).thenReturn(caseDocument); + + when(judgmentByAdmissionOrDeterminationMapper.toNonDivergentDocs(caseData)) + .thenReturn(JudgmentByAdmissionOrDetermination.builder().build()); + + when(judgmentByAdmissionOrDeterminationMapper.toNonDivergentWelshDocs(caseData, builder)) + .thenReturn(JudgmentByAdmissionOrDetermination.builder().build()); + + when(civilStitchService.generateStitchedCaseDocument(anyList(), any(), anyLong(), eq(DocumentType.JUDGMENT_BY_ADMISSION_CLAIMANT), + anyString())).thenReturn(caseDocument); + + // When + // When + List actual = generator.generateNonDivergentDocs(caseData, BEARER_TOKEN, + GEN_JUDGMENT_BY_ADMISSION_DOC_CLAIMANT); + // Then + verify(documentManagementService, times(2)) + .uploadDocument(BEARER_TOKEN, new PDF(fileName, bytes, DocumentType.JUDGMENT_BY_ADMISSION_CLAIMANT)); + + verify(assignCategoryId) + .assignCategoryIdToCaseDocument(caseDocument, "judgments"); + assertThat(actual).contains(caseDocument); + } + + @Test + void shouldGenerateDefendantJudgementByAdmissionWelshDocument() { + // Given + String fileName = String.format(JUDGMENT_BY_ADMISSION_DEFENDANT.getDocumentTitle(), REFERENCE_NUMBER, "admission"); + CaseDocument caseDocument = CaseDocumentBuilder.builder() + .documentName(fileName) + .documentType(DocumentType.JUDGMENT_BY_ADMISSION_DEFENDANT) + .build(); + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged() + .claimantBilingualLanguagePreference("BOTH") + .build(); + JudgmentByAdmissionOrDetermination builder = JudgmentByAdmissionOrDetermination.builder().build(); + + when(documentGeneratorService.generateDocmosisDocument(any(JudgmentByAdmissionOrDetermination.class), eq(JUDGMENT_BY_ADMISSION_DEFENDANT))) + .thenReturn(new DocmosisDocument(JUDGMENT_BY_ADMISSION_DEFENDANT.getDocumentTitle(), bytes)); + + when(documentGeneratorService.generateDocmosisDocument(any(JudgmentByAdmissionOrDetermination.class), eq(JUDGMENT_BY_ADMISSION_DEFENDANT_BILINGUAL))) + .thenReturn(new DocmosisDocument(JUDGMENT_BY_ADMISSION_DEFENDANT_BILINGUAL.getDocumentTitle(), bytes)); + + when(documentManagementService.uploadDocument( + BEARER_TOKEN, new PDF(fileName, bytes, DocumentType.JUDGMENT_BY_ADMISSION_DEFENDANT)) + ).thenReturn(caseDocument); + + when(judgmentByAdmissionOrDeterminationMapper.toNonDivergentDocs(caseData)) + .thenReturn(JudgmentByAdmissionOrDetermination.builder().build()); + + when(judgmentByAdmissionOrDeterminationMapper.toNonDivergentWelshDocs(caseData, builder)) + .thenReturn(JudgmentByAdmissionOrDetermination.builder().build()); + + when(civilStitchService.generateStitchedCaseDocument(anyList(), any(), anyLong(), eq(DocumentType.JUDGMENT_BY_ADMISSION_DEFENDANT), + anyString())).thenReturn(caseDocument); + + // When + List actual = generator.generateNonDivergentDocs(caseData, BEARER_TOKEN, + GEN_JUDGMENT_BY_ADMISSION_DOC_DEFENDANT); + + // Then + verify(documentManagementService, times(2)) + .uploadDocument(BEARER_TOKEN, new PDF(fileName, bytes, DocumentType.JUDGMENT_BY_ADMISSION_DEFENDANT)); + assertThat(actual).contains(caseDocument); + } }