diff --git a/build.gradle b/build.gradle index a7f70e37bc3..a6c47658b95 100644 --- a/build.gradle +++ b/build.gradle @@ -405,7 +405,7 @@ dependencies { implementation group: 'org.apache.commons', name: 'commons-text', version: '1.12.0' implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.98' implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-websocket', version: '10.1.34' - implementation group: 'org.elasticsearch', name: 'elasticsearch', version: '7.17.25' + implementation group: 'org.elasticsearch', name: 'elasticsearch', version: '7.17.26' implementation group: 'com.networknt', name: 'json-schema-validator', version: '1.5.4' implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-kotlin', version: versions.jackson diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/tasks/UpdateFromGACaseEventTaskHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/tasks/UpdateFromGACaseEventTaskHandler.java index 91190b35c12..ff9fa2a9c6b 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/tasks/UpdateFromGACaseEventTaskHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/tasks/UpdateFromGACaseEventTaskHandler.java @@ -12,6 +12,7 @@ import uk.gov.hmcts.reform.ccd.client.model.StartEventResponse; import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument; import uk.gov.hmcts.reform.civil.documentmanagement.model.Document; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.exceptions.InvalidCaseDataException; import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; import uk.gov.hmcts.reform.civil.model.CaseData; @@ -35,6 +36,7 @@ import static java.lang.Long.parseLong; import static java.util.Objects.isNull; import static java.util.Optional.ofNullable; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; @RequiredArgsConstructor @Component @@ -282,6 +284,13 @@ protected List> checkDraftDocumentsInMainCase(List> civilD protected boolean canViewClaimant(CaseData civilCaseData, CaseData generalAppCaseData) { List> gaAppDetails = civilCaseData.getClaimantGaAppDetails(); + + if (generalAppCaseData.getParentClaimantIsApplicant() == YesOrNo.NO + && ((generalAppCaseData.getGeneralAppInformOtherParty()) != null && YES.equals(generalAppCaseData.getGeneralAppInformOtherParty().getIsWithNotice()) + || (generalAppCaseData.getGeneralAppRespondentAgreement() != null && generalAppCaseData.getGeneralAppRespondentAgreement().getHasAgreed().equals(YES)))) { + return true; + } + if (isNull(gaAppDetails)) { return false; } @@ -298,6 +307,13 @@ protected boolean canViewResp(CaseData civilCaseData, CaseData generalAppCaseDat } else { gaAppDetails = civilCaseData.getRespondentSolGaAppDetails(); } + + if (generalAppCaseData.getParentClaimantIsApplicant() == YesOrNo.YES + && ((generalAppCaseData.getGeneralAppInformOtherParty()) != null && YES.equals(generalAppCaseData.getGeneralAppInformOtherParty().getIsWithNotice()) + || (generalAppCaseData.getGeneralAppRespondentAgreement() != null && generalAppCaseData.getGeneralAppRespondentAgreement().getHasAgreed().equals(YES)))) { + return true; + } + if (isNull(gaAppDetails)) { return false; } 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 a5c64021f28..6f737b12905 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 @@ -177,6 +177,7 @@ public class CaseData extends CaseDataParent implements MappableObject { private final YesOrNo generalAppVaryJudgementType; private final YesOrNo generalAppParentClaimantIsApplicant; + private final YesOrNo parentClaimantIsApplicant; private final GAHearingDateGAspec generalAppHearingDate; private final Document generalAppN245FormUpload; diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/tasks/UpdateFromGACaseEventTaskHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/tasks/UpdateFromGACaseEventTaskHandlerTest.java index 717a851390b..c6b0fdffd29 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/tasks/UpdateFromGACaseEventTaskHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/tasks/UpdateFromGACaseEventTaskHandlerTest.java @@ -24,6 +24,8 @@ import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.common.Element; +import uk.gov.hmcts.reform.civil.model.genapplication.GAInformOtherParty; +import uk.gov.hmcts.reform.civil.model.genapplication.GARespondentOrderAgreement; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.sampledata.CaseDetailsBuilder; import uk.gov.hmcts.reform.civil.sampledata.GeneralApplicationDetailsBuilder; @@ -609,6 +611,286 @@ void testShouldAddGaDraftApplicationDocument_LipApplicantGANotEnabled() { verify(externalTaskService).complete(mockExternalTask, null); } + @Test + void testShouldAddGaDraftApplicationDocument_LipDefendantIsApplicant_withNotice() { + when(mockExternalTask.getTopicName()).thenReturn("test"); + when(featureToggleService.isGaForLipsEnabled()).thenReturn(false); + when(mockExternalTask.getAllVariables()) + .thenReturn(Map.of( + "caseId", GENERAL_APP_CASE_ID, + "caseEvent", ADD_PDF_TO_MAIN_CASE, + "generalAppParentCaseLink", CIVIL_CASE_ID + )); + + CaseData caseData = new CaseDataBuilder().atStateClaimDraftLip() + .applicant1Represented(YesOrNo.NO) + .businessProcess(BusinessProcess.builder().status(BusinessProcessStatus.READY).build()) + .build(); + + CaseDetails caseDetails = CaseDetailsBuilder.builder().data(caseData).build(); + StartEventResponse startEventResponse = startEventResponse(caseDetails); + + CaseData generalCaseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDraftApplicationPDFDocumentLip(CaseData.builder().build()); + generalCaseData = generalCaseData.toBuilder() + .parentClaimantIsApplicant(YesOrNo.NO) + .generalAppInformOtherParty(GAInformOtherParty.builder() + .isWithNotice(YesOrNo.YES).build()) + .build(); + + CaseData updatedCaseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDraftStaffPDFDocument(CaseData.builder().build()); + + when(caseDetailsConverter.toGACaseData(coreCaseDataService.getCase(parseLong(GENERAL_APP_CASE_ID)))) + .thenReturn(generalCaseData); + + when(coreCaseDataService.startUpdate(CIVIL_CASE_ID, ADD_PDF_TO_MAIN_CASE)).thenReturn(startEventResponse); + + when(caseDetailsConverter.toCaseData(startEventResponse.getCaseDetails())).thenReturn(caseData); + + when(coreCaseDataService.submitUpdate(eq(CIVIL_CASE_ID), any(CaseDataContent.class))).thenReturn(updatedCaseData); + + handler.execute(mockExternalTask, externalTaskService); + + verify(coreCaseDataService).startUpdate(CIVIL_CASE_ID, ADD_PDF_TO_MAIN_CASE); + verify(coreCaseDataService).submitUpdate(eq(CIVIL_CASE_ID), any(CaseDataContent.class)); + verify(externalTaskService).complete(mockExternalTask, null); + } + + @Test + void testShouldAddGaDraftApplicationDocument_LipDefendantIsApplicant_withConsent() { + when(mockExternalTask.getTopicName()).thenReturn("test"); + when(featureToggleService.isGaForLipsEnabled()).thenReturn(false); + when(mockExternalTask.getAllVariables()) + .thenReturn(Map.of( + "caseId", GENERAL_APP_CASE_ID, + "caseEvent", ADD_PDF_TO_MAIN_CASE, + "generalAppParentCaseLink", CIVIL_CASE_ID + )); + + CaseData caseData = new CaseDataBuilder().atStateClaimDraftLip() + .applicant1Represented(YesOrNo.NO) + .businessProcess(BusinessProcess.builder().status(BusinessProcessStatus.READY).build()) + .build(); + + CaseDetails caseDetails = CaseDetailsBuilder.builder().data(caseData).build(); + StartEventResponse startEventResponse = startEventResponse(caseDetails); + + CaseData generalCaseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDraftApplicationPDFDocumentLip(CaseData.builder().build()); + generalCaseData = generalCaseData.toBuilder() + .parentClaimantIsApplicant(YesOrNo.NO) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder() + .hasAgreed(YesOrNo.YES).build()) + .build(); + + CaseData updatedCaseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDraftStaffPDFDocument(CaseData.builder().build()); + + when(caseDetailsConverter.toGACaseData(coreCaseDataService.getCase(parseLong(GENERAL_APP_CASE_ID)))) + .thenReturn(generalCaseData); + + when(coreCaseDataService.startUpdate(CIVIL_CASE_ID, ADD_PDF_TO_MAIN_CASE)).thenReturn(startEventResponse); + + when(caseDetailsConverter.toCaseData(startEventResponse.getCaseDetails())).thenReturn(caseData); + + when(coreCaseDataService.submitUpdate(eq(CIVIL_CASE_ID), any(CaseDataContent.class))).thenReturn(updatedCaseData); + + handler.execute(mockExternalTask, externalTaskService); + + verify(coreCaseDataService).startUpdate(CIVIL_CASE_ID, ADD_PDF_TO_MAIN_CASE); + verify(coreCaseDataService).submitUpdate(eq(CIVIL_CASE_ID), any(CaseDataContent.class)); + verify(externalTaskService).complete(mockExternalTask, null); + } + + @Test + void testShouldAddGaDraftApplicationDocument_LipDefendantIsApplicant_withoutNoticeWithoutConsent() { + when(mockExternalTask.getTopicName()).thenReturn("test"); + when(featureToggleService.isGaForLipsEnabled()).thenReturn(false); + when(mockExternalTask.getAllVariables()) + .thenReturn(Map.of( + "caseId", GENERAL_APP_CASE_ID, + "caseEvent", ADD_PDF_TO_MAIN_CASE, + "generalAppParentCaseLink", CIVIL_CASE_ID + )); + + CaseData caseData = new CaseDataBuilder().atStateClaimDraftLip() + .applicant1Represented(YesOrNo.NO) + .businessProcess(BusinessProcess.builder().status(BusinessProcessStatus.READY).build()) + .build(); + + CaseDetails caseDetails = CaseDetailsBuilder.builder().data(caseData).build(); + StartEventResponse startEventResponse = startEventResponse(caseDetails); + + CaseData generalCaseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDraftApplicationPDFDocumentLip(CaseData.builder().build()); + generalCaseData = generalCaseData.toBuilder() + .parentClaimantIsApplicant(YesOrNo.NO) + .generalAppInformOtherParty(GAInformOtherParty.builder() + .isWithNotice(YesOrNo.NO).build()) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder() + .hasAgreed(YesOrNo.NO).build()) + .build(); + + CaseData updatedCaseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDraftStaffPDFDocument(CaseData.builder().build()); + + when(caseDetailsConverter.toGACaseData(coreCaseDataService.getCase(parseLong(GENERAL_APP_CASE_ID)))) + .thenReturn(generalCaseData); + + when(coreCaseDataService.startUpdate(CIVIL_CASE_ID, ADD_PDF_TO_MAIN_CASE)).thenReturn(startEventResponse); + + when(caseDetailsConverter.toCaseData(startEventResponse.getCaseDetails())).thenReturn(caseData); + + when(coreCaseDataService.submitUpdate(eq(CIVIL_CASE_ID), any(CaseDataContent.class))).thenReturn(updatedCaseData); + + handler.execute(mockExternalTask, externalTaskService); + + verify(coreCaseDataService).startUpdate(CIVIL_CASE_ID, ADD_PDF_TO_MAIN_CASE); + verify(coreCaseDataService).submitUpdate(eq(CIVIL_CASE_ID), any(CaseDataContent.class)); + verify(externalTaskService).complete(mockExternalTask, null); + } + + @Test + void testShouldAddGaDraftApplicationDocument_LipClaimantIsApplicant_withNotice() { + when(mockExternalTask.getTopicName()).thenReturn("test"); + when(featureToggleService.isGaForLipsEnabled()).thenReturn(false); + when(mockExternalTask.getAllVariables()) + .thenReturn(Map.of( + "caseId", GENERAL_APP_CASE_ID, + "caseEvent", ADD_PDF_TO_MAIN_CASE, + "generalAppParentCaseLink", CIVIL_CASE_ID + )); + + CaseData caseData = new CaseDataBuilder().atStateClaimDraftLip() + .applicant1Represented(YesOrNo.NO) + .businessProcess(BusinessProcess.builder().status(BusinessProcessStatus.READY).build()) + .build(); + + CaseDetails caseDetails = CaseDetailsBuilder.builder().data(caseData).build(); + StartEventResponse startEventResponse = startEventResponse(caseDetails); + + CaseData generalCaseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDraftApplicationPDFDocumentLip(CaseData.builder().build()); + generalCaseData = generalCaseData.toBuilder() + .parentClaimantIsApplicant(YesOrNo.YES) + .generalAppInformOtherParty(GAInformOtherParty.builder() + .isWithNotice(YesOrNo.YES).build()) + .build(); + + CaseData updatedCaseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDraftStaffPDFDocument(CaseData.builder().build()); + + when(caseDetailsConverter.toGACaseData(coreCaseDataService.getCase(parseLong(GENERAL_APP_CASE_ID)))) + .thenReturn(generalCaseData); + + when(coreCaseDataService.startUpdate(CIVIL_CASE_ID, ADD_PDF_TO_MAIN_CASE)).thenReturn(startEventResponse); + + when(caseDetailsConverter.toCaseData(startEventResponse.getCaseDetails())).thenReturn(caseData); + + when(coreCaseDataService.submitUpdate(eq(CIVIL_CASE_ID), any(CaseDataContent.class))).thenReturn(updatedCaseData); + + handler.execute(mockExternalTask, externalTaskService); + + verify(coreCaseDataService).startUpdate(CIVIL_CASE_ID, ADD_PDF_TO_MAIN_CASE); + verify(coreCaseDataService).submitUpdate(eq(CIVIL_CASE_ID), any(CaseDataContent.class)); + verify(externalTaskService).complete(mockExternalTask, null); + } + + @Test + void testShouldAddGaDraftApplicationDocument_LipClaimantIsApplicant_withConsent() { + when(mockExternalTask.getTopicName()).thenReturn("test"); + when(featureToggleService.isGaForLipsEnabled()).thenReturn(false); + when(mockExternalTask.getAllVariables()) + .thenReturn(Map.of( + "caseId", GENERAL_APP_CASE_ID, + "caseEvent", ADD_PDF_TO_MAIN_CASE, + "generalAppParentCaseLink", CIVIL_CASE_ID + )); + + CaseData caseData = new CaseDataBuilder().atStateClaimDraftLip() + .applicant1Represented(YesOrNo.NO) + .businessProcess(BusinessProcess.builder().status(BusinessProcessStatus.READY).build()) + .build(); + + CaseDetails caseDetails = CaseDetailsBuilder.builder().data(caseData).build(); + StartEventResponse startEventResponse = startEventResponse(caseDetails); + + CaseData generalCaseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDraftApplicationPDFDocumentLip(CaseData.builder().build()); + generalCaseData = generalCaseData.toBuilder() + .parentClaimantIsApplicant(YesOrNo.YES) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder() + .hasAgreed(YesOrNo.YES).build()) + .build(); + + CaseData updatedCaseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDraftStaffPDFDocument(CaseData.builder().build()); + + when(caseDetailsConverter.toGACaseData(coreCaseDataService.getCase(parseLong(GENERAL_APP_CASE_ID)))) + .thenReturn(generalCaseData); + + when(coreCaseDataService.startUpdate(CIVIL_CASE_ID, ADD_PDF_TO_MAIN_CASE)).thenReturn(startEventResponse); + + when(caseDetailsConverter.toCaseData(startEventResponse.getCaseDetails())).thenReturn(caseData); + + when(coreCaseDataService.submitUpdate(eq(CIVIL_CASE_ID), any(CaseDataContent.class))).thenReturn(updatedCaseData); + + handler.execute(mockExternalTask, externalTaskService); + + verify(coreCaseDataService).startUpdate(CIVIL_CASE_ID, ADD_PDF_TO_MAIN_CASE); + verify(coreCaseDataService).submitUpdate(eq(CIVIL_CASE_ID), any(CaseDataContent.class)); + verify(externalTaskService).complete(mockExternalTask, null); + } + + @Test + void testShouldAddGaDraftApplicationDocument_LipClaimantIsApplicant_withoutNoticeWithoutConsent() { + when(mockExternalTask.getTopicName()).thenReturn("test"); + when(featureToggleService.isGaForLipsEnabled()).thenReturn(false); + when(mockExternalTask.getAllVariables()) + .thenReturn(Map.of( + "caseId", GENERAL_APP_CASE_ID, + "caseEvent", ADD_PDF_TO_MAIN_CASE, + "generalAppParentCaseLink", CIVIL_CASE_ID + )); + + CaseData caseData = new CaseDataBuilder().atStateClaimDraftLip() + .applicant1Represented(YesOrNo.NO) + .businessProcess(BusinessProcess.builder().status(BusinessProcessStatus.READY).build()) + .build(); + + CaseDetails caseDetails = CaseDetailsBuilder.builder().data(caseData).build(); + StartEventResponse startEventResponse = startEventResponse(caseDetails); + + CaseData generalCaseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDraftApplicationPDFDocumentLip(CaseData.builder().build()); + generalCaseData = generalCaseData.toBuilder() + .parentClaimantIsApplicant(YesOrNo.YES) + .generalAppInformOtherParty(GAInformOtherParty.builder() + .isWithNotice(YesOrNo.NO).build()) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder() + .hasAgreed(YesOrNo.NO).build()) + .build(); + + CaseData updatedCaseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDraftStaffPDFDocument(CaseData.builder().build()); + + when(caseDetailsConverter.toGACaseData(coreCaseDataService.getCase(parseLong(GENERAL_APP_CASE_ID)))) + .thenReturn(generalCaseData); + + when(coreCaseDataService.startUpdate(CIVIL_CASE_ID, ADD_PDF_TO_MAIN_CASE)).thenReturn(startEventResponse); + + when(caseDetailsConverter.toCaseData(startEventResponse.getCaseDetails())).thenReturn(caseData); + + when(coreCaseDataService.submitUpdate(eq(CIVIL_CASE_ID), any(CaseDataContent.class))).thenReturn(updatedCaseData); + + handler.execute(mockExternalTask, externalTaskService); + + verify(coreCaseDataService).startUpdate(CIVIL_CASE_ID, ADD_PDF_TO_MAIN_CASE); + verify(coreCaseDataService).submitUpdate(eq(CIVIL_CASE_ID), any(CaseDataContent.class)); + verify(externalTaskService).complete(mockExternalTask, null); + } + @Test void testShouldAddGaDraftApplicationDocument_LipRespondent() { when(mockExternalTask.getTopicName()).thenReturn("test");