Skip to content

Commit

Permalink
Merge branch 'master' into DTSCCI-1323
Browse files Browse the repository at this point in the history
  • Loading branch information
ed14537 authored Dec 13, 2024
2 parents 41238d0 + 25db41f commit d0f70a2
Show file tree
Hide file tree
Showing 4 changed files with 300 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -282,6 +284,13 @@ protected List<Element<?>> checkDraftDocumentsInMainCase(List<Element<?>> civilD

protected boolean canViewClaimant(CaseData civilCaseData, CaseData generalAppCaseData) {
List<Element<GeneralApplicationsDetails>> 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;
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit d0f70a2

Please sign in to comment.