diff --git a/docker/docmosis/templates/CV-CMC-LET-ENG-LIP-SD0002.docx b/docker/docmosis/templates/CV-CMC-LET-ENG-LIP-SD0002.docx index daa130f5db5..292fbd41694 100644 Binary files a/docker/docmosis/templates/CV-CMC-LET-ENG-LIP-SD0002.docx and b/docker/docmosis/templates/CV-CMC-LET-ENG-LIP-SD0002.docx differ diff --git a/docker/docmosis/templates/CV-SPC-GNO-ENG-SD0001.docx b/docker/docmosis/templates/CV-SPC-GNO-ENG-SD0002.docx similarity index 74% rename from docker/docmosis/templates/CV-SPC-GNO-ENG-SD0001.docx rename to docker/docmosis/templates/CV-SPC-GNO-ENG-SD0002.docx index 57158640d18..4561c7718c2 100644 Binary files a/docker/docmosis/templates/CV-SPC-GNO-ENG-SD0001.docx and b/docker/docmosis/templates/CV-SPC-GNO-ENG-SD0002.docx differ diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateDiscontinueClaimCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateDiscontinueClaimCallbackHandler.java index 731ad8d81d5..1d693105bff 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateDiscontinueClaimCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateDiscontinueClaimCallbackHandler.java @@ -13,16 +13,17 @@ import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument; import uk.gov.hmcts.reform.civil.enums.DocCategory; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.model.Party; import uk.gov.hmcts.reform.civil.service.docmosis.settlediscontinue.NoticeOfDiscontinuanceFormGenerator; import uk.gov.hmcts.reform.civil.utils.AssignCategoryId; import java.util.List; import java.util.Map; -import static java.util.Objects.nonNull; import static uk.gov.hmcts.reform.civil.callback.CallbackParams.Params.BEARER_TOKEN; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.GEN_NOTICE_OF_DISCONTINUANCE; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; @Service @RequiredArgsConstructor @@ -57,31 +58,52 @@ private CallbackResponse aboutToSubmit(CallbackParams callbackParams) { CaseData caseData = callbackParams.getCaseData(); updateCamundaVars(caseData); CaseData.CaseDataBuilder caseDataBuilder = caseData.toBuilder(); - buildDocument(callbackParams, caseDataBuilder); - CaseData updatedData = caseDataBuilder.build(); + buildDocuments(callbackParams, caseDataBuilder); - if (nonNull(updatedData.getNoticeOfDiscontinueCWDoc())) { - assignDiscontinuanceCategoryId(updatedData.getNoticeOfDiscontinueCWDoc()); - } else { - assignDiscontinuanceCategoryId(updatedData.getNoticeOfDiscontinueAllParitiesDoc()); - } return AboutToStartOrSubmitCallbackResponse.builder() - .data(updatedData.toMap(objectMapper)) + .data(caseDataBuilder.build().toMap(objectMapper)) .build(); } - private void buildDocument(CallbackParams callbackParams, CaseData.CaseDataBuilder caseDataBuilder) { + private void buildDocuments(CallbackParams callbackParams, CaseData.CaseDataBuilder caseDataBuilder) { CaseData caseData = callbackParams.getCaseData(); - CaseDocument caseDocument = formGenerator.generateDocs( - callbackParams.getCaseData(), - callbackParams.getParams().get(BEARER_TOKEN).toString()); + + CaseDocument applicant1DiscontinueDoc = generateForm(caseData.getApplicant1(), callbackParams); + CaseDocument respondent1DiscontinueDoc = generateForm(caseData.getRespondent1(), callbackParams); + CaseDocument respondent2DiscontinueDoc = null; + + if (YES.equals(caseData.getAddRespondent2()) && caseData.getRespondent2() != null) { + respondent2DiscontinueDoc = generateForm(caseData.getRespondent2(), callbackParams); + } + if (caseData.isJudgeOrderVerificationRequired()) { - caseDataBuilder.noticeOfDiscontinueCWDoc(caseDocument); + caseDataBuilder.applicant1NoticeOfDiscontinueCWViewDoc(applicant1DiscontinueDoc); + caseDataBuilder.respondent1NoticeOfDiscontinueCWViewDoc(respondent1DiscontinueDoc); + assignDiscontinuanceCategoryId(caseDataBuilder.build().getApplicant1NoticeOfDiscontinueCWViewDoc()); + assignDiscontinuanceCategoryId(caseDataBuilder.build().getRespondent1NoticeOfDiscontinueCWViewDoc()); + + if (respondent2DiscontinueDoc != null) { + caseDataBuilder.respondent2NoticeOfDiscontinueCWViewDoc(respondent2DiscontinueDoc); + assignDiscontinuanceCategoryId(caseDataBuilder.build().getRespondent2NoticeOfDiscontinueCWViewDoc()); + } } else { - caseDataBuilder.noticeOfDiscontinueAllParitiesDoc(caseDocument); + caseDataBuilder.applicant1NoticeOfDiscontinueAllPartyViewDoc(applicant1DiscontinueDoc); + caseDataBuilder.respondent1NoticeOfDiscontinueAllPartyViewDoc(respondent1DiscontinueDoc); + assignDiscontinuanceCategoryId(caseDataBuilder.build().getApplicant1NoticeOfDiscontinueAllPartyViewDoc()); + assignDiscontinuanceCategoryId(caseDataBuilder.build().getRespondent1NoticeOfDiscontinueAllPartyViewDoc()); + + if (respondent2DiscontinueDoc != null) { + caseDataBuilder.respondent2NoticeOfDiscontinueAllPartyViewDoc(respondent2DiscontinueDoc); + assignDiscontinuanceCategoryId(caseDataBuilder.build().getRespondent2NoticeOfDiscontinueAllPartyViewDoc()); + } } } + private CaseDocument generateForm(Party party, CallbackParams callbackParams) { + return formGenerator.generateDocs( + callbackParams.getCaseData(), party, callbackParams.getParams().get(BEARER_TOKEN).toString()); + } + private void assignDiscontinuanceCategoryId(CaseDocument caseDocument) { assignCategoryId.assignCategoryIdToCaseDocument(caseDocument, DocCategory.NOTICE_OF_DISCONTINUE.getValue()); } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandler.java index 1e9faecbf94..3bb292d8693 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandler.java @@ -55,10 +55,13 @@ private CallbackResponse updateVisibilityNoticeDiscontinuance(CallbackParams cal updateCamundaVars(caseData); if (ConfirmOrderGivesPermission.YES.equals(caseData.getConfirmOrderGivesPermission())) { CaseData.CaseDataBuilder caseDataBuilder = caseData.toBuilder(); - caseDataBuilder.noticeOfDiscontinueAllParitiesDoc(caseData.getNoticeOfDiscontinueCWDoc()); - caseDataBuilder.noticeOfDiscontinueCWDoc(null); + + updateVisibilityForAllParties(caseData, caseDataBuilder); + removeCaseWorkerViewDocuments(caseDataBuilder); + CaseData updatedData = caseDataBuilder.build(); - assignCategoryId.assignCategoryIdToCaseDocument(updatedData.getNoticeOfDiscontinueAllParitiesDoc(), DocCategory.NOTICE_OF_DISCONTINUE.getValue()); + assignCategoryIdForAllParties(updatedData); + return AboutToStartOrSubmitCallbackResponse.builder() .data(updatedData.toMap(objectMapper)) .build(); @@ -66,6 +69,30 @@ private CallbackResponse updateVisibilityNoticeDiscontinuance(CallbackParams cal return AboutToStartOrSubmitCallbackResponse.builder().build(); } + private void updateVisibilityForAllParties(CaseData caseData, CaseData.CaseDataBuilder caseDataBuilder) { + caseDataBuilder + .applicant1NoticeOfDiscontinueAllPartyViewDoc(caseData.getApplicant1NoticeOfDiscontinueCWViewDoc()) + .respondent1NoticeOfDiscontinueAllPartyViewDoc(caseData.getRespondent1NoticeOfDiscontinueCWViewDoc()); + + if (caseData.getRespondent2NoticeOfDiscontinueCWViewDoc() != null) { + caseDataBuilder + .respondent2NoticeOfDiscontinueAllPartyViewDoc(caseData.getRespondent2NoticeOfDiscontinueCWViewDoc()); + } + } + + private void removeCaseWorkerViewDocuments(CaseData.CaseDataBuilder caseDataBuilder) { + caseDataBuilder + .applicant1NoticeOfDiscontinueCWViewDoc(null) + .respondent1NoticeOfDiscontinueCWViewDoc(null) + .respondent2NoticeOfDiscontinueCWViewDoc(null); + } + + private void assignCategoryIdForAllParties(CaseData caseData) { + assignCategoryId.assignCategoryIdToCaseDocument(caseData.getApplicant1NoticeOfDiscontinueAllPartyViewDoc(), DocCategory.NOTICE_OF_DISCONTINUE.getValue()); + assignCategoryId.assignCategoryIdToCaseDocument(caseData.getRespondent1NoticeOfDiscontinueAllPartyViewDoc(), DocCategory.NOTICE_OF_DISCONTINUE.getValue()); + assignCategoryId.assignCategoryIdToCaseDocument(caseData.getRespondent2NoticeOfDiscontinueAllPartyViewDoc(), DocCategory.NOTICE_OF_DISCONTINUE.getValue()); + } + private void updateCamundaVars(CaseData caseData) { runTimeService.setVariable( caseData.getBusinessProcess().getProcessInstanceId(), diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java b/src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java index edf9416f8df..0849282a6af 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java @@ -722,8 +722,13 @@ public boolean hasNoOngoingBusinessProcess() { private SettlementReason settleReason; private final MarkPaidConsentList markPaidConsent; private YesOrNo claimantsConsentToDiscontinuance; - private CaseDocument noticeOfDiscontinueCWDoc; - private CaseDocument noticeOfDiscontinueAllParitiesDoc; + private CaseDocument applicant1NoticeOfDiscontinueCWViewDoc; + private CaseDocument respondent1NoticeOfDiscontinueCWViewDoc; + private CaseDocument respondent2NoticeOfDiscontinueCWViewDoc; + private CaseDocument applicant1NoticeOfDiscontinueAllPartyViewDoc; + private CaseDocument respondent1NoticeOfDiscontinueAllPartyViewDoc; + private CaseDocument respondent2NoticeOfDiscontinueAllPartyViewDoc; + @JsonUnwrapped private FeePaymentOutcomeDetails feePaymentOutcomeDetails; private LocalDate coscSchedulerDeadline; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/settleanddiscontinue/NoticeOfDiscontinuanceForm.java b/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/settleanddiscontinue/NoticeOfDiscontinuanceForm.java index b96f0c17b3c..e4f7288d260 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/settleanddiscontinue/NoticeOfDiscontinuanceForm.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/settleanddiscontinue/NoticeOfDiscontinuanceForm.java @@ -37,4 +37,16 @@ public class NoticeOfDiscontinuanceForm implements MappableObject { private String typeOfDiscontinuance; private String typeOfDiscontinuanceTxt; private String partOfDiscontinuanceTxt; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd MMMM yyyy") + @JsonSerialize(using = LocalDateSerializer.class) + private final LocalDate letterIssueDate; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd MMMM yyyy") + @JsonSerialize(using = LocalDateSerializer.class) + private final LocalDate dateOfEvent; + private final String coverLetterName; + private final String addressLine1; + private final String addressLine2; + private final String addressLine3; + private final String postCode; + private final String claimReferenceNumber; } 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 5017db97707..04258258334 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 @@ -99,7 +99,7 @@ public enum DocmosisTemplates { JUDGMENT_BY_ADMISSION_DEFENDANT("CV-SPC-DEC-ENG-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-SD0001.docx", "notice_of_discontinuance_%s.pdf"), + NOTICE_OF_DISCONTINUANCE_PDF("CV-SPC-GNO-ENG-SD0002.docx", "notice_of_discontinuance_%s.pdf"), CERTIFICATE_OF_DEBT_PAYMENT("CV-SPC-STD-ENG-N441A.docx", "Certificate_of_debt_payment_%s.pdf"), COVER_LETTER("CV-SPC-LET-ENG-COVER-LETTER.docx", "cover_letter.pdf"); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceFormGenerator.java b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceFormGenerator.java index 079fa6e8a34..bcb91319b34 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceFormGenerator.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceFormGenerator.java @@ -10,12 +10,13 @@ import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.enums.settlediscontinue.SettleDiscontinueYesOrNoList; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.model.Party; import uk.gov.hmcts.reform.civil.model.docmosis.DocmosisDocument; import uk.gov.hmcts.reform.civil.model.docmosis.settleanddiscontinue.NoticeOfDiscontinuanceForm; 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 java.time.LocalDate; import static java.util.Objects.nonNull; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.NOTICE_OF_DISCONTINUANCE_PDF; @@ -27,8 +28,8 @@ public class NoticeOfDiscontinuanceFormGenerator implements TemplateDataGenerato private final DocumentManagementService documentManagementService; private final DocumentGeneratorService documentGeneratorService; - public CaseDocument generateDocs(CaseData caseData, String authorisation) { - NoticeOfDiscontinuanceForm templateData = getNoticeOfDiscontinueData(caseData); + public CaseDocument generateDocs(CaseData caseData, Party party, String authorisation) { + NoticeOfDiscontinuanceForm templateData = getNoticeOfDiscontinueData(caseData, party); DocmosisTemplates docmosisTemplate = NOTICE_OF_DISCONTINUANCE_PDF; DocmosisDocument docmosisDocument = documentGeneratorService.generateDocmosisDocument(templateData, docmosisTemplate); @@ -47,9 +48,17 @@ private String getFileName(CaseData caseData, DocmosisTemplates docmosisTemplate return String.format(docmosisTemplate.getDocumentTitle(), caseData.getLegacyCaseReference()); } - private NoticeOfDiscontinuanceForm getNoticeOfDiscontinueData(CaseData caseData) { + private NoticeOfDiscontinuanceForm getNoticeOfDiscontinueData(CaseData caseData, Party party) { var noticeOfDiscontinueBuilder = NoticeOfDiscontinuanceForm.builder() .caseNumber(caseData.getLegacyCaseReference()) + .claimReferenceNumber(caseData.getLegacyCaseReference()) + .letterIssueDate(LocalDate.now()) + .dateOfEvent(LocalDate.now()) + .coverLetterName(party.getPartyName()) + .addressLine1(party.getPrimaryAddress().getAddressLine1()) + .addressLine2(party.getPrimaryAddress().getAddressLine2()) + .addressLine3(party.getPrimaryAddress().getAddressLine3()) + .postCode(party.getPrimaryAddress().getPostCode()) .claimant1Name(caseData.getApplicant1().getPartyName()) .claimant2Name(nonNull(caseData.getApplicant2()) ? caseData.getApplicant2().getPartyName() : null) .defendant1Name(caseData.getRespondent1().getPartyName()) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceLiPLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceLiPLetterGenerator.java index dd42ef72208..74e7a8e389a 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceLiPLetterGenerator.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceLiPLetterGenerator.java @@ -24,7 +24,7 @@ public class NoticeOfDiscontinuanceLiPLetterGenerator { private static final String NOTICE_OF_DISCONTINUANCE_LETTER = "notice-of-discontinuance"; public void printNoticeOfDiscontinuanceLetter(CaseData caseData, String authorisation) { - CaseDocument discontinuanceCaseDocument = caseData.getNoticeOfDiscontinueAllParitiesDoc(); + CaseDocument discontinuanceCaseDocument = caseData.getRespondent1NoticeOfDiscontinueAllPartyViewDoc(); if (nonNull(discontinuanceCaseDocument)) { String documentUrl = discontinuanceCaseDocument.getDocumentLink().getDocumentUrl(); String documentId = documentUrl.substring(documentUrl.lastIndexOf("/") + 1); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateDiscontinueClaimCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateDiscontinueClaimCallbackHandlerTest.java index 778f0d6db78..44be7dd0ae0 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateDiscontinueClaimCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateDiscontinueClaimCallbackHandlerTest.java @@ -33,6 +33,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; @@ -78,11 +79,11 @@ void shouldUpdateCamundaVariables_whenInvoked(Boolean toggleState) { @Test void shouldGenerateNoticeOfDiscontinueDocForCW_whenCourtPermissionRequired() { - when(formGenerator.generateDocs(any(CaseData.class), anyString())).thenReturn(getCaseDocument()); + when(formGenerator.generateDocs(any(CaseData.class), any(Party.class), anyString())).thenReturn(getCaseDocument()); CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() - .respondent1(getPartyDetails()) - .applicant1(getPartyDetails()) + .respondent1(getRespondent1PartyDetails()) + .applicant1(getApplicant1PartyDetails()) .courtPermissionNeeded(SettleDiscontinueYesOrNoList.YES) .isPermissionGranted(SettleDiscontinueYesOrNoList.YES) .businessProcess(BusinessProcess.builder().processInstanceId(PROCESS_INSTANCE_ID).build()) @@ -93,19 +94,20 @@ void shouldGenerateNoticeOfDiscontinueDocForCW_whenCourtPermissionRequired() { var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - verify(formGenerator).generateDocs(any(CaseData.class), eq("BEARER_TOKEN")); + verify(formGenerator, times(2)).generateDocs(any(CaseData.class), any(Party.class), eq("BEARER_TOKEN")); CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); - assertThat(updatedData.getNoticeOfDiscontinueCWDoc()).isNotNull(); + assertThat(updatedData.getApplicant1NoticeOfDiscontinueCWViewDoc()).isNotNull(); + assertThat(updatedData.getRespondent1NoticeOfDiscontinueCWViewDoc()).isNotNull(); } @Test void shouldGenerateNoticeOfDiscontinueDocForAllParties_whenNoCourtPermissionRequired() { - when(formGenerator.generateDocs(any(CaseData.class), anyString())).thenReturn(getCaseDocument()); + when(formGenerator.generateDocs(any(CaseData.class), any(Party.class), anyString())).thenReturn(getCaseDocument()); CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() - .respondent1(getPartyDetails()) - .applicant1(getPartyDetails()) + .respondent1(getRespondent1PartyDetails()) + .applicant1(getApplicant1PartyDetails()) .courtPermissionNeeded(SettleDiscontinueYesOrNoList.NO) .typeOfDiscontinuance(DiscontinuanceTypeList.PART_DISCONTINUANCE) .businessProcess(BusinessProcess.builder().processInstanceId(PROCESS_INSTANCE_ID).build()) @@ -115,10 +117,11 @@ void shouldGenerateNoticeOfDiscontinueDocForAllParties_whenNoCourtPermissionRequ var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - verify(formGenerator).generateDocs(any(CaseData.class), eq("BEARER_TOKEN")); + verify(formGenerator, times(2)).generateDocs(any(CaseData.class), any(Party.class), eq("BEARER_TOKEN")); CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); - assertThat(updatedData.getNoticeOfDiscontinueAllParitiesDoc()).isNotNull(); + assertThat(updatedData.getApplicant1NoticeOfDiscontinueAllPartyViewDoc()).isNotNull(); + assertThat(updatedData.getRespondent1NoticeOfDiscontinueAllPartyViewDoc()).isNotNull(); } } @@ -134,13 +137,27 @@ void handleEventsReturnsTheExpectedCallbackEvent() { assertThat(handler.handledEvents()).contains(GEN_NOTICE_OF_DISCONTINUANCE); } - private Party getPartyDetails() { + private Party getRespondent1PartyDetails() { return PartyBuilder.builder().individual().build().toBuilder() .individualFirstName("John") .individualLastName("Doe") .build(); } + private Party getRespondent2PartyDetails() { + return PartyBuilder.builder().individual().build().toBuilder() + .individualFirstName("Jane") + .individualLastName("Doe") + .build(); + } + + private Party getApplicant1PartyDetails() { + return PartyBuilder.builder().individual().build().toBuilder() + .individualFirstName("Carl") + .individualLastName("Foster") + .build(); + } + private CaseDocument getCaseDocument() { return CaseDocument.builder() .createdBy("John") diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/PostNoticeOfDiscontinuanceLetterLiPDefendant1HandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/PostNoticeOfDiscontinuanceLetterLiPDefendant1HandlerTest.java index 7a7dd2e4f37..7d1159f1f18 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/PostNoticeOfDiscontinuanceLetterLiPDefendant1HandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/PostNoticeOfDiscontinuanceLetterLiPDefendant1HandlerTest.java @@ -55,7 +55,7 @@ void shouldDownloadDocumentAndPrintLetterSuccessfully() { CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .respondent1Represented(YesOrNo.NO) .courtPermissionNeeded(SettleDiscontinueYesOrNoList.NO) - .noticeOfDiscontinueAllParitiesDoc(caseDocument).build(); + .respondent1NoticeOfDiscontinueAllPartyViewDoc(caseDocument).build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); params.getRequest().setEventId(SEND_DISCONTINUANCE_LETTER_LIP_DEFENDANT1.name()); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandlerTest.java index 559a61a6aeb..36970bb0393 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/UpdateVisibilityNoticeOfDiscontinuanceHandlerTest.java @@ -53,7 +53,8 @@ void shouldUpdateCamundaVariables_whenInvoked(Boolean toggleState) { .businessProcess(BusinessProcess.builder().processInstanceId(processId).build()).build(); caseData.setConfirmOrderGivesPermission( toggleState ? ConfirmOrderGivesPermission.YES : ConfirmOrderGivesPermission.NO); - caseData.setNoticeOfDiscontinueCWDoc(caseDocument); + caseData.setRespondent1NoticeOfDiscontinueCWViewDoc(caseDocument); + caseData.setApplicant1NoticeOfDiscontinueCWViewDoc(caseDocument); CallbackParams params = CallbackParams.builder() .caseData(caseData) @@ -67,6 +68,6 @@ void shouldUpdateCamundaVariables_whenInvoked(Boolean toggleState) { //Then verify(runTimeService).setVariable(processId, "discontinuanceValidationSuccess", toggleState); } - } + } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceFormGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceFormGeneratorTest.java index 368c8296334..f53187155e1 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceFormGeneratorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceFormGeneratorTest.java @@ -46,7 +46,7 @@ class NoticeOfDiscontinuanceFormGeneratorTest { private NoticeOfDiscontinuanceFormGenerator formGenerator; @Test - void shouldGenerateNoticeOfDiscontinuanceDoc_whenValidDataIsProvided() { + void shouldGenerateRespondent1NoticeOfDiscontinuanceDoc_whenValidDataIsProvided() { String fileName = String.format( NOTICE_OF_DISCONTINUANCE_PDF.getDocumentTitle(), REFERENCE_NUMBER); @@ -64,7 +64,59 @@ void shouldGenerateNoticeOfDiscontinuanceDoc_whenValidDataIsProvided() { CaseData caseData = getCaseData(); - CaseDocument caseDoc = formGenerator.generateDocs(caseData, BEARER_TOKEN); + CaseDocument caseDoc = formGenerator.generateDocs(caseData, caseData.getRespondent1(), BEARER_TOKEN); + assertThat(caseDoc).isNotNull(); + + verify(documentManagementService) + .uploadDocument(BEARER_TOKEN, new PDF(fileName, bytes, NOTICE_OF_DISCONTINUANCE)); + } + + @Test + void shouldGenerateApplicant1NoticeOfDiscontinuanceDoc_whenValidDataIsProvided() { + String fileName = String.format( + NOTICE_OF_DISCONTINUANCE_PDF.getDocumentTitle(), REFERENCE_NUMBER); + + CaseDocument caseDocument = CaseDocumentBuilder.builder() + .documentName(fileName) + .documentType(NOTICE_OF_DISCONTINUANCE) + .build(); + + when(documentGeneratorService.generateDocmosisDocument(any(NoticeOfDiscontinuanceForm.class), eq(NOTICE_OF_DISCONTINUANCE_PDF))) + .thenReturn(new DocmosisDocument(NOTICE_OF_DISCONTINUANCE_PDF.getDocumentTitle(), bytes)); + + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileName, bytes, NOTICE_OF_DISCONTINUANCE))) + .thenReturn(caseDocument); + + CaseData caseData = getCaseData(); + + CaseDocument caseDoc = formGenerator.generateDocs(caseData, caseData.getApplicant1(), BEARER_TOKEN); + assertThat(caseDoc).isNotNull(); + + verify(documentManagementService) + .uploadDocument(BEARER_TOKEN, new PDF(fileName, bytes, NOTICE_OF_DISCONTINUANCE)); + } + + @Test + void shouldGenerateRespondent2NoticeOfDiscontinuanceDoc_whenValidDataIsProvided() { + String fileName = String.format( + NOTICE_OF_DISCONTINUANCE_PDF.getDocumentTitle(), REFERENCE_NUMBER); + + CaseDocument caseDocument = CaseDocumentBuilder.builder() + .documentName(fileName) + .documentType(NOTICE_OF_DISCONTINUANCE) + .build(); + + when(documentGeneratorService.generateDocmosisDocument(any(NoticeOfDiscontinuanceForm.class), eq(NOTICE_OF_DISCONTINUANCE_PDF))) + .thenReturn(new DocmosisDocument(NOTICE_OF_DISCONTINUANCE_PDF.getDocumentTitle(), bytes)); + + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileName, bytes, NOTICE_OF_DISCONTINUANCE))) + .thenReturn(caseDocument); + + CaseData caseData = getCaseData(); + + CaseDocument caseDoc = formGenerator.generateDocs(caseData, caseData.getRespondent2(), BEARER_TOKEN); assertThat(caseDoc).isNotNull(); verify(documentManagementService) @@ -75,6 +127,7 @@ private CaseData getCaseData() { return CaseDataBuilder.builder().atStateClaimIssued().build().toBuilder() .legacyCaseReference(REFERENCE_NUMBER) .respondent1(PartyBuilder.builder().individual().build().toBuilder().individualFirstName("John").individualLastName("Doe").build()) + .respondent2(PartyBuilder.builder().individual().build().toBuilder().individualFirstName("Lily").individualLastName("Potter").build()) .applicant1(PartyBuilder.builder().individual().build().toBuilder().individualFirstName("James").individualLastName("White").build()) .applicant2(PartyBuilder.builder().individual().build().toBuilder().individualFirstName("Jan").individualLastName("Black").build()) .claimantWhoIsDiscontinuing(DynamicList.builder() diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceLiPLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceLiPLetterGeneratorTest.java index 5527a2eba50..269a8623aff 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceLiPLetterGeneratorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/settlediscontinue/NoticeOfDiscontinuanceLiPLetterGeneratorTest.java @@ -52,7 +52,8 @@ void shouldDownloadDocumentAndPrintLetterSuccessfully() { .respondent1Represented(YesOrNo.NO) .applicant1(applicant) .respondent1(defendant) - .noticeOfDiscontinueAllParitiesDoc(caseDocument).build(); + .respondent1NoticeOfDiscontinueAllPartyViewDoc(caseDocument + ).build(); given(documentDownloadService.downloadDocument( any(), @@ -78,7 +79,7 @@ void shouldNotDownloadDocumentAndPrintLetterSuccessfully() { .respondent1Represented(YesOrNo.NO) .applicant1(applicant) .respondent1(defendant) - .noticeOfDiscontinueAllParitiesDoc(null).build(); + .respondent1NoticeOfDiscontinueAllPartyViewDoc(null).build(); liPLetterGenerator.printNoticeOfDiscontinuanceLetter(caseData, BEARER_TOKEN);