diff --git a/build.gradle b/build.gradle index 6a518150b2d..7035befae45 100644 --- a/build.gradle +++ b/build.gradle @@ -369,7 +369,7 @@ configurations.all { } dependencies { - implementation 'com.github.hmcts:civil-commons:1.0.31' + implementation 'com.github.hmcts:civil-commons:1.0.33' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop' diff --git a/src/main/java/uk/gov/hmcts/reform/civil/enums/caseprogression/BundleFileNameList.java b/src/main/java/uk/gov/hmcts/reform/civil/enums/caseprogression/BundleFileNameList.java index 9847205b2b4..ec628a0643f 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/enums/caseprogression/BundleFileNameList.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/enums/caseprogression/BundleFileNameList.java @@ -26,7 +26,8 @@ public enum BundleFileNameList { QUESTIONS_TO("Questions to %s %s"), REPLIES_FROM("Replies from %s %s"), JOINT_STATEMENTS_OF_EXPERTS("Joint statement of experts %s %s %s"), - SKELETON_ARGUMENT("%s Skeleton argument %s"); + SKELETON_ARGUMENT("%s Skeleton argument %s"), + PARTICULARS_OF_CLAIM("Particulars Of Claim %s"); String displayName; public String getDisplayName() { diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantResponseConfirmsToProceedRespondentNotificationHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantResponseConfirmsToProceedRespondentNotificationHandler.java index fb660ca4694..3f80be153d4 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantResponseConfirmsToProceedRespondentNotificationHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantResponseConfirmsToProceedRespondentNotificationHandler.java @@ -9,14 +9,20 @@ import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.callback.CaseEvent; import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; +import uk.gov.hmcts.reform.civil.enums.RespondentResponseTypeSpec; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.model.SmallClaimMedicalLRspec; import uk.gov.hmcts.reform.civil.notify.NotificationService; -import uk.gov.hmcts.reform.civil.service.OrganisationService; +import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; import uk.gov.hmcts.reform.civil.prd.model.Organisation; +import uk.gov.hmcts.reform.civil.service.OrganisationService; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; +import java.util.stream.Stream; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED; @@ -70,7 +76,7 @@ public List handledEvents() { private CallbackResponse notifyRespondentSolicitorForClaimantConfirmsToProceed(CallbackParams callbackParams) { CaseData caseData = callbackParams.getCaseData(); - String template = null; + String template; var recipient = isCcNotification(callbackParams) ? caseData.getApplicantSolicitor1UserDetails().getEmail() : caseData.getRespondentSolicitor1EmailAddress(); @@ -103,9 +109,7 @@ private CallbackResponse notifyRespondentSolicitorForClaimantConfirmsToProceed(C return AboutToStartOrSubmitCallbackResponse.builder().build(); } if (SPEC_CLAIM.equals(caseData.getCaseAccessCategory())) { - template = isCcNotification(callbackParams) - ? notificationsProperties.getClaimantSolicitorConfirmsToProceedSpec() - : notificationsProperties.getRespondentSolicitorNotifyToProceedSpec(); + template = getSpecTemplate(callbackParams, caseData); } else { template = notificationsProperties.getClaimantSolicitorConfirmsToProceed(); } @@ -123,6 +127,50 @@ private CallbackResponse notifyRespondentSolicitorForClaimantConfirmsToProceed(C return AboutToStartOrSubmitCallbackResponse.builder().build(); } + private String getSpecTemplate(CallbackParams callbackParams, CaseData caseData) { + String template; + if (isCcNotification(callbackParams)) { + if (rejectedAll(caseData) && mediationRejected(caseData)) { + template = notificationsProperties.getClaimantSolicitorConfirmsToProceedSpecWithAction(); + } else { + template = notificationsProperties.getClaimantSolicitorConfirmsToProceedSpec(); + } + } else { + if (rejectedAll(caseData) && mediationRejected(caseData)) { + template = notificationsProperties.getRespondentSolicitorNotifyToProceedSpecWithAction(); + } else { + template = notificationsProperties.getRespondentSolicitorNotifyToProceedSpec(); + } + } + return template; + } + + /** + * Consider that reject all is true if any respondent rejected all the claim. + * + * @param caseData the case data of a spec claim + * @return true if and only if at least one respondent rejected all the claim + */ + private boolean rejectedAll(CaseData caseData) { + return caseData.getRespondent1ClaimResponseTypeForSpec() == RespondentResponseTypeSpec.FULL_DEFENCE + || caseData.getRespondent2ClaimResponseTypeForSpec() == RespondentResponseTypeSpec.FULL_DEFENCE; + } + + /** + * Mediation is applicable only when all parties are willing to try it. + * + * @param caseData a spec claim + * @return true if and only if at least one party did not agree to mediation + */ + private boolean mediationRejected(CaseData caseData) { + return Stream.of( + caseData.getResponseClaimMediationSpecRequired(), + caseData.getResponseClaimMediationSpec2Required(), + Optional.ofNullable(caseData.getApplicant1ClaimMediationSpecRequired()) + .map(SmallClaimMedicalLRspec::getHasAgreedFreeMediation).orElse(null) + ).filter(Objects::nonNull).anyMatch(YesOrNo.NO::equals); + } + @Override public Map addProperties(CaseData caseData) { return Map.of( @@ -158,12 +206,12 @@ private boolean isRespondentSolicitor2Notification(CallbackParams callbackParams } //finding legal org name - private String getLegalOrganisationName(CaseData caseData, CaseEvent caseEvent) { + private String getLegalOrganisationName(CaseData caseData, CaseEvent caseEvent) { String organisationID; if (caseEvent.equals(NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED_CC)) { organisationID = caseData.getApplicant1OrganisationPolicy().getOrganisation().getOrganisationID(); } else { - organisationID = caseEvent.equals(NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED) + organisationID = caseEvent.equals(NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED) ? caseData.getRespondent1OrganisationPolicy().getOrganisation().getOrganisationID() : caseData.getRespondent2OrganisationPolicy().getOrganisation().getOrganisationID(); } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/DefendantResponseApplicantNotificationHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/DefendantResponseApplicantNotificationHandler.java index b047d927cf9..cf52061b65c 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/DefendantResponseApplicantNotificationHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/DefendantResponseApplicantNotificationHandler.java @@ -33,7 +33,9 @@ import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.ONE_V_TWO_TWO_LEGAL_REP; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.TWO_V_ONE; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.getMultiPartyScenario; +import static uk.gov.hmcts.reform.civil.enums.RespondentResponsePartAdmissionPaymentTimeLRspec.BY_SET_DATE; import static uk.gov.hmcts.reform.civil.enums.RespondentResponsePartAdmissionPaymentTimeLRspec.IMMEDIATELY; +import static uk.gov.hmcts.reform.civil.enums.RespondentResponsePartAdmissionPaymentTimeLRspec.SUGGESTION_OF_REPAYMENT_PLAN; import static uk.gov.hmcts.reform.civil.utils.PartyUtils.buildPartiesReferences; import static uk.gov.hmcts.reform.civil.utils.PartyUtils.getPartyNameBasedOnType; @@ -159,7 +161,11 @@ private void sendNotificationToSolicitorSpec(CaseData caseData, String recipient String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference()) ); } else if (caseEvent.equals(NOTIFY_APPLICANT_SOLICITOR1_FOR_DEFENDANT_RESPONSE_CC)) { - emailTemplate = notificationsProperties.getRespondentSolicitorDefendantResponseForSpec(); + if (MultiPartyScenario.getMultiPartyScenario(caseData).equals(ONE_V_TWO_TWO_LEGAL_REP)) { + emailTemplate = notificationsProperties.getRespondentSolicitorDefendantResponseForSpec(); + } else { + emailTemplate = getTemplateForSpecOtherThan1v2DS(caseData); + } if (caseData.getRespondent1ResponseDate() == null || !MultiPartyScenario.getMultiPartyScenario(caseData) .equals(ONE_V_TWO_TWO_LEGAL_REP)) { notificationService.sendMail( @@ -171,7 +177,11 @@ private void sendNotificationToSolicitorSpec(CaseData caseData, String recipient } } else { - emailTemplate = notificationsProperties.getRespondentSolicitorDefendantResponseForSpec(); + if (MultiPartyScenario.getMultiPartyScenario(caseData).equals(ONE_V_TWO_TWO_LEGAL_REP)) { + emailTemplate = notificationsProperties.getRespondentSolicitorDefendantResponseForSpec(); + } else { + emailTemplate = getTemplateForSpecOtherThan1v2DS(caseData); + } notificationService.sendMail( recipient, emailTemplate, @@ -181,6 +191,23 @@ private void sendNotificationToSolicitorSpec(CaseData caseData, String recipient } } + private String getTemplateForSpecOtherThan1v2DS(CaseData caseData) { + + String emailTemplate; + if ((caseData.getDefenceAdmitPartPaymentTimeRouteRequired() == IMMEDIATELY + || caseData.getDefenceAdmitPartPaymentTimeRouteRequired() == BY_SET_DATE + || caseData.getDefenceAdmitPartPaymentTimeRouteRequired() == SUGGESTION_OF_REPAYMENT_PLAN) + && + (RespondentResponseTypeSpec.PART_ADMISSION.equals(caseData.getRespondent1ClaimResponseTypeForSpec())) + ) { + emailTemplate = notificationsProperties.getRespondentSolicitorDefResponseSpecWithClaimantAction(); + } else { + emailTemplate = notificationsProperties.getRespondentSolicitorDefendantResponseForSpec(); + } + + return emailTemplate; + } + @Override public Map addProperties(CaseData caseData) { if (getMultiPartyScenario(caseData).equals(ONE_V_ONE) || getMultiPartyScenario(caseData).equals(TWO_V_ONE)) { @@ -216,10 +243,10 @@ public Map addPropertiesSpec(CaseData caseData, CaseEvent caseEv + " " + caseData.getRespondToClaimAdmitPartLRspec().getWhenWillThisAmountBePaid().getMonth() + " " + caseData.getRespondToClaimAdmitPartLRspec().getWhenWillThisAmountBePaid().getYear(); return Map.of( - CLAIM_LEGAL_ORG_NAME_SPEC, getLegalOrganisationName(caseData, caseEvent), - CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(), - RESPONDENT_NAME, getPartyNameBasedOnType(caseData.getApplicant1()), - WHEN_WILL_BE_PAID_IMMEDIATELY, shouldBePaidBy + CLAIM_LEGAL_ORG_NAME_SPEC, getLegalOrganisationName(caseData, caseEvent), + CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(), + RESPONDENT_NAME, getPartyNameBasedOnType(caseData.getApplicant1()), + WHEN_WILL_BE_PAID_IMMEDIATELY, shouldBePaidBy ); } else { return Map.of( diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandler.java index 8ae14dc9eee..e00acfdeb49 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandler.java @@ -13,6 +13,7 @@ import uk.gov.hmcts.reform.civil.enums.CaseState; import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.service.citizenui.ResponseOneVOneShowTagService; import java.time.LocalDateTime; import java.util.Collections; @@ -31,12 +32,14 @@ public class ClaimantResponseCuiCallbackHandler extends CallbackHandler { private static final List EVENTS = Collections.singletonList(CLAIMANT_RESPONSE_CUI); + private final ResponseOneVOneShowTagService responseOneVOneService; + private final ObjectMapper objectMapper; @Override protected Map callbacks() { return Map.of( - callbackKey(ABOUT_TO_START), this::emptyCallbackResponse, + callbackKey(ABOUT_TO_START), this::populateCaseData, callbackKey(ABOUT_TO_SUBMIT), this::aboutToSubmit, callbackKey(SUBMITTED), this::emptySubmittedCallbackResponse ); @@ -47,6 +50,16 @@ public List handledEvents() { return EVENTS; } + private CallbackResponse populateCaseData(CallbackParams callbackParams) { + var caseData = callbackParams.getCaseData(); + CaseData.CaseDataBuilder updatedCaseData = caseData.toBuilder(); + updatedCaseData.showResponseOneVOneFlag(responseOneVOneService.setUpOneVOneFlow(caseData)); + + return AboutToStartOrSubmitCallbackResponse.builder() + .data(updatedCaseData.build().toMap(objectMapper)) + .build(); + } + private CallbackResponse aboutToSubmit(CallbackParams callbackParams) { CaseData caseData = callbackParams.getCaseData(); CaseData updatedData = caseData.toBuilder() @@ -64,11 +77,13 @@ private CallbackResponse aboutToSubmit(CallbackParams callbackParams) { } private void updateClaimEndState(AboutToStartOrSubmitCallbackResponse.AboutToStartOrSubmitCallbackResponseBuilder response, CaseData updatedData) { - if (updatedData.hasClaimantAgreedToFreeMediation()) { response.state(CaseState.IN_MEDIATION.name()); + } else if (updatedData.hasApplicantRejectedRepaymentPlan() && updatedData.getRespondent1().isCompanyOROrganisation()) { + response.state(CaseState.PROCEEDS_IN_HERITAGE_SYSTEM.name()); } else { response.state(CaseState.JUDICIAL_REFERRAL.name()); } } + } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateSDOCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateSDOCallbackHandler.java index 6aae628746a..32770c5f47a 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateSDOCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateSDOCallbackHandler.java @@ -98,6 +98,9 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED; import static uk.gov.hmcts.reform.civil.callback.CallbackVersion.V_1; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_SDO; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; +import static uk.gov.hmcts.reform.civil.enums.sdo.OrderDetailsPagesSectionsToggle.SHOW; +import static uk.gov.hmcts.reform.civil.enums.sdo.OrderType.DISPOSAL; import static uk.gov.hmcts.reform.civil.helpers.DateFormatHelper.DATE; import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element; import static uk.gov.hmcts.reform.civil.utils.HearingUtils.getHearingNotes; @@ -219,7 +222,7 @@ private CallbackResponse prePopulateOrderDetailsPages(CallbackParams callbackPar updatedData.fastTrackMethodInPerson(locationsList); updatedData.smallClaimsMethodInPerson(locationsList); - List checkList = List.of(OrderDetailsPagesSectionsToggle.SHOW); + List checkList = List.of(SHOW); setCheckList(updatedData, checkList); DisposalHearingJudgesRecital tempDisposalHearingJudgesRecital = DisposalHearingJudgesRecital.builder() @@ -711,17 +714,21 @@ private DynamicList getLocationList(CallbackParams callbackParams, )); DynamicList locationsList; if (matchingLocation.isPresent()) { - locationsList = DynamicList.fromList(locations, LocationRefDataService::getDisplayEntry, + locationsList = DynamicList.fromList(locations, this::getLocationEpimms, LocationRefDataService::getDisplayEntry, matchingLocation.get(), true ); } else { - locationsList = DynamicList.fromList(locations, LocationRefDataService::getDisplayEntry, + locationsList = DynamicList.fromList(locations, this::getLocationEpimms, LocationRefDataService::getDisplayEntry, null, true ); } return locationsList; } + private String getLocationEpimms(LocationRefData location) { + return location.getEpimmsId(); + } + private CallbackResponse setOrderDetailsFlags(CallbackParams callbackParams) { CaseData caseData = callbackParams.getCaseData(); CaseData.CaseDataBuilder updatedData = caseData.toBuilder(); @@ -732,9 +739,9 @@ private CallbackResponse setOrderDetailsFlags(CallbackParams callbackParams) { updatedData.setFastTrackFlag(YesOrNo.NO).build(); if (SdoHelper.isSmallClaimsTrack(caseData)) { - updatedData.setSmallClaimsFlag(YesOrNo.YES).build(); + updatedData.setSmallClaimsFlag(YES).build(); } else if (SdoHelper.isFastTrack(caseData)) { - updatedData.setFastTrackFlag(YesOrNo.YES).build(); + updatedData.setFastTrackFlag(YES).build(); } return AboutToStartOrSubmitCallbackResponse.builder() @@ -836,18 +843,38 @@ private CallbackResponse submitSDO(CallbackParams callbackParams) { dataBuilder.hearingNotes(getHearingNotes(caseData)); - if (featureToggleService.isLocationWhiteListedForCaseProgression( - caseData.getCaseManagementLocation().getBaseLocation())) { - log.info("Case {} is whitelisted for case progression.", caseData.getCcdCaseReference()); - } else { - log.info("Case {} is NOT whitelisted for case progression.", caseData.getCcdCaseReference()); + if (featureToggleService.isEarlyAdoptersEnabled()) { + if (featureToggleService.isLocationWhiteListedForCaseProgression( + getEpimmsId(caseData))) { + log.info("Case {} is whitelisted for case progression.", caseData.getCcdCaseReference()); + dataBuilder.eaCourtLocation(YES); + } else { + log.info("Case {} is NOT whitelisted for case progression.", caseData.getCcdCaseReference()); + dataBuilder.eaCourtLocation(YesOrNo.NO); + } } + System.out.println("before about to submit"); + return AboutToStartOrSubmitCallbackResponse.builder() .data(dataBuilder.build().toMap(objectMapper)) .build(); } + private String getEpimmsId(CaseData caseData) { + + if (caseData.getOrderType() != null && caseData.getOrderType().equals(DISPOSAL)) { + return caseData.getDisposalHearingMethodInPerson().getValue().getCode(); + } + if (SdoHelper.isFastTrack(caseData)) { + return caseData.getFastTrackMethodInPerson().getValue().getCode(); + } + if (SdoHelper.isSmallClaimsTrack(caseData)) { + return caseData.getSmallClaimsMethodInPerson().getValue().getCode(); + } + throw new IllegalArgumentException("Could not determine claim track"); + } + private boolean nonNull(Object object) { if (object != null) { return true; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandler.java index d41aacdabc6..12ca69bdb86 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandler.java @@ -14,6 +14,8 @@ import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.CaseNote; import uk.gov.hmcts.reform.civil.model.common.Element; +import uk.gov.hmcts.reform.civil.model.documents.DocumentAndNote; +import uk.gov.hmcts.reform.civil.model.documents.DocumentWithName; import uk.gov.hmcts.reform.civil.service.CaseNoteService; import java.util.Collections; @@ -59,7 +61,11 @@ private AboutToStartOrSubmitCallbackResponse removeCaseNoteType(CallbackParams c var caseData = callbackParams.getCaseData(); CaseData.CaseDataBuilder caseDataBuilder = caseData.toBuilder(); - caseDataBuilder.caseNoteType(null).build(); + caseDataBuilder + .caseNoteType(null) + .documentAndNameToAdd(null) + .documentAndNoteToAdd(null) + .build(); return AboutToStartOrSubmitCallbackResponse.builder() .data(caseDataBuilder.build().toMap(objectMapper)) @@ -84,6 +90,39 @@ private AboutToStartOrSubmitCallbackResponse populateSubmittedDateTime(CallbackP .build(); } + if (caseData.getCaseNoteType().equals(CaseNoteType.DOCUMENT_ONLY)) { + List> documentAndNameToAdd = caseData.getDocumentAndNameToAdd(); + List> documentAndNameCurrent = caseData.getDocumentAndName(); + + if (documentAndNameCurrent == null) { + documentAndNameCurrent = documentAndNameToAdd; + } else { + for (Element document : documentAndNameToAdd) { + documentAndNameCurrent.add(document); + } + } + caseDataBuilder + .documentAndName(documentAndNameCurrent) + .build(); + } + + if (caseData.getCaseNoteType().equals(CaseNoteType.DOCUMENT_AND_NOTE)) { + List> documentAndNoteToAdd = caseData.getDocumentAndNoteToAdd(); + List> documentAndNoteCurrent = caseData.getDocumentAndNote(); + + if (documentAndNoteCurrent == null) { + documentAndNoteCurrent = documentAndNoteToAdd; + } else { + for (Element document : documentAndNoteToAdd) { + documentAndNoteCurrent.add(document); + } + } + caseDataBuilder + .documentAndNote(documentAndNoteCurrent) + .build(); + + } + return AboutToStartOrSubmitCallbackResponse.builder() .data(caseDataBuilder.build().toMap(objectMapper)) .build(); @@ -115,16 +154,16 @@ private String getHeader(CaseData caseData) { private String getBody(CaseData caseData) { StringBuilder stringBuilder = new StringBuilder(); if (null != caseData.getCaseNoteType() && caseData.getCaseNoteType().equals(CaseNoteType.DOCUMENT_ONLY)) { - IntStream.range(0, caseData.getDocumentAndName() + IntStream.range(0, caseData.getDocumentAndNameToAdd() .size()).forEachOrdered(i -> stringBuilder.append("* ").append( - caseData.getDocumentAndName().get(i).getValue().getDocument().getDocumentFileName()).append("\n")); + caseData.getDocumentAndNameToAdd().get(i).getValue().getDocument().getDocumentFileName()).append("\n")); return format(EVIDENCE_UPLOAD_BODY_ONE, stringBuilder); } if (caseData.getCaseNoteType().equals(CaseNoteType.DOCUMENT_AND_NOTE)) { - IntStream.range(0, caseData.getDocumentAndNote() + IntStream.range(0, caseData.getDocumentAndNoteToAdd() .size()).forEachOrdered(i -> stringBuilder.append("* ").append( - caseData.getDocumentAndNote().get(i) + caseData.getDocumentAndNoteToAdd().get(i) .getValue() .getDocument() .getDocumentFileName()).append("\n")); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToDefenceCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToDefenceCallbackHandler.java index add98412f45..7b1599b7eb8 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToDefenceCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToDefenceCallbackHandler.java @@ -14,12 +14,10 @@ import uk.gov.hmcts.reform.civil.config.ToggleConfiguration; import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument; import uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType; -import uk.gov.hmcts.reform.civil.enums.AllocatedTrack; import uk.gov.hmcts.reform.civil.enums.CaseCategory; import uk.gov.hmcts.reform.civil.enums.CaseState; import uk.gov.hmcts.reform.civil.enums.DocCategory; import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario; -import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.helpers.LocationHelper; import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.CaseData; @@ -36,6 +34,7 @@ import uk.gov.hmcts.reform.civil.service.Time; import uk.gov.hmcts.reform.civil.utils.AssignCategoryId; import uk.gov.hmcts.reform.civil.utils.CaseFlagsInitialiser; +import uk.gov.hmcts.reform.civil.utils.JudicialReferralUtils; import uk.gov.hmcts.reform.civil.utils.LocationRefDataUtil; import uk.gov.hmcts.reform.civil.utils.UnavailabilityDatesUtils; import uk.gov.hmcts.reform.civil.validation.UnavailableDateValidator; @@ -56,7 +55,6 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.MID; import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CLAIMANT_RESPONSE; -import static uk.gov.hmcts.reform.civil.enums.AllocatedTrack.getAllocatedTrack; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.ONE_V_TWO_ONE_LEGAL_REP; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.ONE_V_TWO_TWO_LEGAL_REP; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.TWO_V_ONE; @@ -288,57 +286,12 @@ private CallbackResponse aboutToSubmit(CallbackParams callbackParams) { return AboutToStartOrSubmitCallbackResponse.builder() .data(builder.build().toMap(objectMapper)) - .state((shouldMoveToJudicialReferral(caseData) + .state((JudicialReferralUtils.shouldMoveToJudicialReferral(caseData) ? CaseState.JUDICIAL_REFERRAL : CaseState.PROCEEDS_IN_HERITAGE_SYSTEM).name()) .build(); } - /** - * Computes whether the case data should move to judicial referral or not. - * - * @param caseData a case data such that defendants rejected the claim, and claimant(s) wants to proceed - * vs all the defendants - * @return true if and only if the case should move to judicial referral - */ - public static boolean shouldMoveToJudicialReferral(CaseData caseData) { - CaseCategory caseCategory = caseData.getCaseAccessCategory(); - - if (CaseCategory.SPEC_CLAIM.equals(caseCategory)) { - MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData); - boolean addRespondent2 = YES.equals(caseData.getAddRespondent2()); - - return switch (multiPartyScenario) { - case ONE_V_ONE -> caseData.getApplicant1ProceedWithClaim() == YesOrNo.YES; - case TWO_V_ONE -> caseData.getApplicant1ProceedWithClaimSpec2v1() == YesOrNo.YES; - case ONE_V_TWO_ONE_LEGAL_REP -> addRespondent2 - && YES.equals(caseData.getRespondentResponseIsSame()); - case ONE_V_TWO_TWO_LEGAL_REP -> addRespondent2 - && caseData.getRespondentResponseIsSame() == null; - }; - } else { - AllocatedTrack allocatedTrack = - getAllocatedTrack( - CaseCategory.UNSPEC_CLAIM.equals(caseCategory) - ? caseData.getClaimValue().toPounds() - : caseData.getTotalClaimAmount(), - caseData.getClaimType() - ); - if (AllocatedTrack.MULTI_CLAIM.equals(allocatedTrack)) { - return false; - } - MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData); - return switch (multiPartyScenario) { - case ONE_V_ONE -> caseData.getApplicant1ProceedWithClaim() == YesOrNo.YES; - case TWO_V_ONE -> caseData.getApplicant1ProceedWithClaimMultiParty2v1() == YES - && caseData.getApplicant2ProceedWithClaimMultiParty2v1() == YES; - case ONE_V_TWO_ONE_LEGAL_REP, ONE_V_TWO_TWO_LEGAL_REP -> - caseData.getApplicant1ProceedWithClaimAgainstRespondent1MultiParty1v2() == YES - && caseData.getApplicant1ProceedWithClaimAgainstRespondent2MultiParty1v2() == YES; - }; - } - } - private void updateApplicants(CaseData caseData, CaseData.CaseDataBuilder builder, StatementOfTruth statementOfTruth) { if (caseData.getApplicant1DQ() != null && caseData.getApplicant1DQ().getApplicant1DQFileDirectionsQuestionnaire() != null) { diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToDefenceSpecCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToDefenceSpecCallbackHandler.java index 121a605dc71..bc39dbf86fe 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToDefenceSpecCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToDefenceSpecCallbackHandler.java @@ -22,7 +22,6 @@ import uk.gov.hmcts.reform.civil.handler.callback.user.spec.RespondToResponseConfirmationHeaderGenerator; import uk.gov.hmcts.reform.civil.handler.callback.user.spec.RespondToResponseConfirmationTextGenerator; import uk.gov.hmcts.reform.civil.handler.callback.user.spec.show.DefendantResponseShowTag; -import uk.gov.hmcts.reform.civil.handler.callback.user.spec.show.ResponseOneVOneShowTag; import uk.gov.hmcts.reform.civil.helpers.LocationHelper; import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.CaseData; @@ -41,8 +40,10 @@ import uk.gov.hmcts.reform.civil.service.PaymentDateService; import uk.gov.hmcts.reform.civil.service.Time; import uk.gov.hmcts.reform.civil.service.citizenui.RespondentMediationService; +import uk.gov.hmcts.reform.civil.service.citizenui.ResponseOneVOneShowTagService; import uk.gov.hmcts.reform.civil.utils.CaseFlagsInitialiser; import uk.gov.hmcts.reform.civil.utils.CourtLocationUtils; +import uk.gov.hmcts.reform.civil.utils.JudicialReferralUtils; import uk.gov.hmcts.reform.civil.utils.MonetaryConversions; import uk.gov.hmcts.reform.civil.utils.UnavailabilityDatesUtils; import uk.gov.hmcts.reform.civil.validation.UnavailableDateValidator; @@ -71,7 +72,6 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackVersion.V_1; import static uk.gov.hmcts.reform.civil.callback.CallbackVersion.V_2; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CLAIMANT_RESPONSE_SPEC; -import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.ONE_V_ONE; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.TWO_V_ONE; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.getMultiPartyScenario; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.isOneVOne; @@ -109,6 +109,7 @@ public class RespondToDefenceSpecCallbackHandler extends CallbackHandler private static final String datePattern = "dd MMMM yyyy"; private final RespondentMediationService respondentMediationService; private final PaymentDateService paymentDateService; + private final ResponseOneVOneShowTagService responseOneVOneShowTagService; @Override public List handledEvents() { @@ -384,7 +385,7 @@ private void updateDQCourtLocations(CallbackParams callbackParams, CaseData case private void putCaseStateInJudicialReferral(CaseData caseData, AboutToStartOrSubmitCallbackResponse.AboutToStartOrSubmitCallbackResponseBuilder response) { if (caseData.isRespondentResponseFullDefence() - && RespondToDefenceCallbackHandler.shouldMoveToJudicialReferral(caseData)) { + && JudicialReferralUtils.shouldMoveToJudicialReferral(caseData)) { response.state(CaseState.JUDICIAL_REFERRAL.name()); } } @@ -415,7 +416,7 @@ private CallbackResponse populateCaseData(CallbackParams callbackParams) { if (isDefendantFullAdmitPayImmediately(caseData)) { LocalDate whenBePaid = paymentDateService.getPaymentDateAdmittedClaim(caseData); - updatedCaseData.showResponseOneVOneFlag(setUpOneVOneFlow(caseData)); + updatedCaseData.showResponseOneVOneFlag(responseOneVOneShowTagService.setUpOneVOneFlow(caseData)); updatedCaseData.whenToBePaidText(formatLocalDate(whenBePaid, DATE)); } @@ -431,7 +432,7 @@ private CallbackResponse populateCaseData(CallbackParams callbackParams) { ).build()); if (V_2.equals(callbackParams.getVersion()) && featureToggleService.isPinInPostEnabled()) { - updatedCaseData.showResponseOneVOneFlag(setUpOneVOneFlow(caseData)); + updatedCaseData.showResponseOneVOneFlag(responseOneVOneShowTagService.setUpOneVOneFlow(caseData)); updatedCaseData.respondent1PaymentDateToStringSpec(setUpPayDateToString(caseData)); Optional howMuchWasPaid = Optional.ofNullable(caseData.getRespondToAdmittedClaim()) @@ -553,27 +554,6 @@ private String getDefaultConfirmationHeader(CaseData caseData) { } } - private ResponseOneVOneShowTag setUpOneVOneFlow(CaseData caseData) { - if (ONE_V_ONE.equals(getMultiPartyScenario(caseData))) { - if (caseData.getRespondent1ClaimResponseTypeForSpec() == null) { - return null; - } - switch (caseData.getRespondent1ClaimResponseTypeForSpec()) { - case FULL_DEFENCE: - return ResponseOneVOneShowTag.ONE_V_ONE_FULL_DEFENCE; - case FULL_ADMISSION: - return setUpOneVOneFlowForFullAdmit(caseData); - case PART_ADMISSION: - return setUpOneVOneFlowForPartAdmit(caseData); - case COUNTER_CLAIM: - return ResponseOneVOneShowTag.ONE_V_ONE_COUNTER_CLAIM; - default: - return null; - } - } - return null; - } - private String setUpPayDateToString(CaseData caseData) { if (caseData.getRespondToClaimAdmitPartLRspec() != null && caseData.getRespondToClaimAdmitPartLRspec().getWhenWillThisAmountBePaid() != null) { @@ -592,38 +572,6 @@ private String setUpPayDateToString(CaseData caseData) { return null; } - private ResponseOneVOneShowTag setUpOneVOneFlowForPartAdmit(CaseData caseData) { - if (YES.equals(caseData.getSpecDefenceAdmittedRequired())) { - return ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT_HAS_PAID; - } - switch (caseData.getDefenceAdmitPartPaymentTimeRouteRequired()) { - case IMMEDIATELY: - return ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT_PAY_IMMEDIATELY; - case BY_SET_DATE: - return ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT_PAY_BY_SET_DATE; - case SUGGESTION_OF_REPAYMENT_PLAN: - return ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT_PAY_INSTALMENT; - default: - return ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT; - } - } - - private ResponseOneVOneShowTag setUpOneVOneFlowForFullAdmit(CaseData caseData) { - if (YES.equals(caseData.getSpecDefenceFullAdmittedRequired())) { - return ResponseOneVOneShowTag.ONE_V_ONE_FULL_ADMIT_HAS_PAID; - } - switch (caseData.getDefenceAdmitPartPaymentTimeRouteRequired()) { - case IMMEDIATELY: - return ResponseOneVOneShowTag.ONE_V_ONE_FULL_ADMIT_PAY_IMMEDIATELY; - case BY_SET_DATE: - return ResponseOneVOneShowTag.ONE_V_ONE_FULL_ADMIT_PAY_BY_SET_DATE; - case SUGGESTION_OF_REPAYMENT_PLAN: - return ResponseOneVOneShowTag.ONE_V_ONE_FULL_ADMIT_PAY_INSTALMENT; - default: - return ResponseOneVOneShowTag.ONE_V_ONE_FULL_ADMIT; - } - } - private CallbackResponse validatePaymentDate(CallbackParams callbackParams) { CaseData caseData = callbackParams.getCaseData(); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/StandardDirectionOrderDJ.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/StandardDirectionOrderDJ.java index e5202ab4def..70020cfb326 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/StandardDirectionOrderDJ.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/StandardDirectionOrderDJ.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; @@ -17,6 +18,7 @@ import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument; import uk.gov.hmcts.reform.civil.enums.CaseCategory; import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.enums.dj.DisposalAndTrialHearingDJToggle; import uk.gov.hmcts.reform.civil.enums.dj.DisposalHearingMethodDJ; import uk.gov.hmcts.reform.civil.enums.sdo.DateToShowToggle; @@ -57,6 +59,7 @@ import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; import uk.gov.hmcts.reform.civil.service.CategoryService; import uk.gov.hmcts.reform.civil.service.DeadlinesCalculator; +import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.service.docmosis.dj.DefaultJudgmentOrderFormGenerator; import uk.gov.hmcts.reform.civil.utils.AssignCategoryId; import uk.gov.hmcts.reform.civil.utils.HearingMethodUtils; @@ -88,6 +91,7 @@ import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element; import static uk.gov.hmcts.reform.civil.utils.HearingUtils.getHearingNotes; +@Slf4j @Service @RequiredArgsConstructor public class StandardDirectionOrderDJ extends CallbackHandler { @@ -99,6 +103,7 @@ public class StandardDirectionOrderDJ extends CallbackHandler { private final ObjectMapper objectMapper; private final DefaultJudgmentOrderFormGenerator defaultJudgmentOrderFormGenerator; private final LocationRefDataService locationRefDataService; + private final FeatureToggleService featureToggleService; String participantString; public static final String DISPOSAL_HEARING = "DISPOSAL_HEARING"; public static final String ORDER_1_CLAI = "The directions order has been sent to: " @@ -628,9 +633,22 @@ private DynamicList getLocationList(CallbackParams callbackParams, ); Optional matchingLocation = Optional.ofNullable(preferredCourt) .flatMap(requestedCourt -> locationHelper.getMatching(locations, preferredCourt)); - return DynamicList.fromList(locations, LocationRefDataService::getDisplayEntry, - matchingLocation.orElse(null), true - ); + + DynamicList locationsList; + if (matchingLocation.isPresent()) { + locationsList = DynamicList.fromList(locations, this::getLocationEpimms, LocationRefDataService::getDisplayEntry, + matchingLocation.get(), true + ); + } else { + locationsList = DynamicList.fromList(locations, this::getLocationEpimms, LocationRefDataService::getDisplayEntry, + null, true + ); + } + return locationsList; + } + + private String getLocationEpimms(LocationRefData location) { + return location.getEpimmsId(); } private CallbackResponse generateSDONotifications(CallbackParams callbackParams) { @@ -643,7 +661,6 @@ private CallbackResponse generateSDONotifications(CallbackParams callbackParams) caseDataBuilder.orderSDODocumentDJ(null); assignCategoryId.assignCategoryIdToCollection(caseData.getOrderSDODocumentDJCollection(), document -> document.getValue().getDocumentLink(), "sdo"); caseDataBuilder.businessProcess(BusinessProcess.ready(STANDARD_DIRECTION_ORDER_DJ)); - var state = "CASE_PROGRESSION"; String authToken = callbackParams.getParams().get(BEARER_TOKEN).toString(); List locations = (locationRefDataService .getCourtLocationsForDefaultJudgments(authToken)); @@ -655,15 +672,35 @@ private CallbackResponse generateSDONotifications(CallbackParams callbackParams) .ifPresent(caseDataBuilder::locationName); } - + var state = "CASE_PROGRESSION"; caseDataBuilder.hearingNotes(getHearingNotes(caseData)); + if (featureToggleService.isEarlyAdoptersEnabled()) { + if (featureToggleService.isLocationWhiteListedForCaseProgression( + getEpimmsId(caseData))) { + log.info("Case {} is whitelisted for case progression.", caseData.getCcdCaseReference()); + caseDataBuilder.eaCourtLocation(YesOrNo.YES); + } else { + log.info("Case {} is NOT whitelisted for case progression.", caseData.getCcdCaseReference()); + caseDataBuilder.eaCourtLocation(YesOrNo.NO); + } + } + return AboutToStartOrSubmitCallbackResponse.builder() .data(caseDataBuilder.build().toMap(objectMapper)) .state(state) .build(); } + private String getEpimmsId(CaseData caseData) { + if (caseData.getTrialHearingMethodInPersonDJ() != null) { + return caseData.getTrialHearingMethodInPersonDJ().getValue().getCode(); + } else if (caseData.getDisposalHearingMethodInPersonDJ() != null) { + return caseData.getDisposalHearingMethodInPersonDJ().getValue().getCode(); + } + throw new IllegalArgumentException("Epimms Id is not provided"); + } + private SubmittedCallbackResponse buildConfirmation(CallbackParams callbackParams) { var caseData = callbackParams.getCaseData(); return SubmittedCallbackResponse.builder() diff --git a/src/main/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapper.java b/src/main/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapper.java index 549965f3176..717887a0472 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapper.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapper.java @@ -35,6 +35,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.TreeMap; @@ -43,6 +44,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; +import static uk.gov.hmcts.reform.civil.enums.CaseCategory.SPEC_CLAIM; import static uk.gov.hmcts.reform.civil.helpers.bundle.BundleFileNameHelper.getEvidenceUploadDocsByPartyAndDocType; import static uk.gov.hmcts.reform.civil.helpers.bundle.BundleFileNameHelper.getExpertDocsByPartyAndDocType; import static uk.gov.hmcts.reform.civil.helpers.bundle.BundleFileNameHelper.getWitnessDocsByPartyAndDocType; @@ -116,6 +118,32 @@ private BundlingCaseData mapCaseData(CaseData caseData, String bundleConfigFileN return bundlingCaseData; } + private List mapParticularsOfClaimDocs(CaseData caseData) { + List bundlingRequestDocuments = new ArrayList<>(); + if (Objects.nonNull(caseData.getServedDocumentFiles()) + && Objects.nonNull((caseData.getServedDocumentFiles().getParticularsOfClaimDocument()))) { + caseData.getServedDocumentFiles() + .getParticularsOfClaimDocument() + .forEach(poc -> bundlingRequestDocuments.add( + buildBundlingRequestDoc(getParticularsOfClaimName(caseData), + poc.getValue(), ""))); + } + return bundlingRequestDocuments; + } + + private String getParticularsOfClaimName(CaseData caseData) { + LocalDate pocDate; + if (SPEC_CLAIM.equals(caseData.getCaseAccessCategory())) { + pocDate = caseData.getIssueDate(); + } else if (Objects.nonNull(caseData.getClaimDetailsNotificationDate())) { + pocDate = caseData.getClaimDetailsNotificationDate().toLocalDate(); + } else { + pocDate = caseData.getSubmittedDate().toLocalDate(); + } + return generateDocName(BundleFileNameList.PARTICULARS_OF_CLAIM.getDisplayName(), + null, null, pocDate); + } + private List> mapJointStatementOfExperts(CaseData caseData) { List bundlingRequestDocuments = new ArrayList<>(); Arrays.stream(PartyType.values()).toList().forEach(partyType -> { @@ -518,6 +546,7 @@ private List> mapStatementOfcaseDocs(CaseData c && caseDocumentElement.getValue().getDocumentLink().getCategoryID().equals("detailsOfClaim")) .collect(Collectors.toList()), BundleFileNameList.CLAIM_FORM.getDisplayName())); + bundlingRequestDocuments.addAll(mapParticularsOfClaimDocs(caseData)); List> clAndDfDocList = caseData.getDefendantResponseDocuments(); clAndDfDocList.addAll(caseData.getClaimantResponseDocuments()); List> sortedDefendantDefenceAndClaimantReply = 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 c8b8a40bc85..7a65369a8b0 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 @@ -572,7 +572,9 @@ public boolean hasNoOngoingBusinessProcess() { //case progression private final List> documentAndName; + private final List> documentAndNameToAdd; private final List> documentAndNote; + private final List> documentAndNoteToAdd; private final CaseNoteType caseNoteType; private final String caseNoteTA; private final List> caseNotesTA; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java b/src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java index 4c06a057441..9e490085485 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java @@ -311,6 +311,8 @@ public class CaseDataParent implements MappableObject { private CaseDocument sdoOrderDocument; + private final YesOrNo eaCourtLocation; + // sdo ui flags private final YesOrNo setSmallClaimsFlag; private final YesOrNo setFastTrackFlag; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/Party.java b/src/main/java/uk/gov/hmcts/reform/civil/model/Party.java index 48edc3146ae..32382122fad 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/Party.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/Party.java @@ -103,6 +103,11 @@ public boolean isOrganisation() { return ORGANISATION.equals(getType()); } + @JsonIgnore + public boolean isCompanyOROrganisation() { + return this.isCompany() || this.isOrganisation(); + } + @JsonIgnore public LocalDate getDateOfBirth() { return Optional.ofNullable(individualDateOfBirth).orElse(soleTraderDateOfBirth); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/bundle/BundlingCaseData.java b/src/main/java/uk/gov/hmcts/reform/civil/model/bundle/BundlingCaseData.java index 80340c02507..f37439ded9c 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/bundle/BundlingCaseData.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/bundle/BundlingCaseData.java @@ -22,6 +22,8 @@ public class BundlingCaseData { private final List> trialDocuments; @JsonProperty("statementsOfCaseDocuments") private final List> statementsOfCaseDocuments; + @JsonProperty("particularsOfClaim") + private final List> particularsOfClaim; @JsonProperty("ordersDocuments") private final List> ordersDocuments; @JsonProperty("claimant1WitnessStatements") diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/common/DynamicList.java b/src/main/java/uk/gov/hmcts/reform/civil/model/common/DynamicList.java index 1fe3e01a3f6..075db0e94a5 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/common/DynamicList.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/common/DynamicList.java @@ -16,7 +16,7 @@ */ @Data @Jacksonized -@Builder +@Builder(toBuilder = true) public class DynamicList { /** @@ -39,18 +39,20 @@ public static DynamicList fromList(List list) { } /** - * Sometimes a dynamic list can be prepopulated with a value. + * A dynamic list can be pre-populated with a code and value. * * @param list the original list of items + * @param toCode (optional) how to populate the DynamicListElement code, defaults to random UUID * @param toLabel how to create the label * @param value (optional) value to be selected * @param type of element * @return dynamic list, possibly with value set */ - public static DynamicList fromList(List list, Function toLabel, T value, boolean sort) { + public static DynamicList fromList(List list, Function toCode, Function toLabel, T value, boolean sort) { List items = list.stream() - .map(toLabel) - .map(DynamicListElement::dynamicElement) + .map(item -> toCode != null + ? DynamicListElement.dynamicElementFromCode(toCode.apply(item), toLabel.apply(item)) + : DynamicListElement.dynamicElement(toLabel.apply(item))) .collect(toList()); int index = value != null ? list.indexOf(value) : -1; @@ -68,6 +70,19 @@ public static DynamicList fromList(List list, Function toLabel return DynamicList.builder().listItems(items).value(chosen).build(); } + /** + * Sometimes a dynamic list can be pre-populated with a value. + * + * @param list the original list of items + * @param toLabel how to create the label + * @param value (optional) value to be selected + * @param type of element + * @return dynamic list, possibly with value set + */ + public static DynamicList fromList(List list, Function toLabel, T value, boolean sort) { + return fromList(list, null, toLabel, value, sort); + } + public static DynamicList fromDynamicListElementList(List list) { return DynamicList.builder().listItems(list).value(DynamicListElement.EMPTY).build(); } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentAndNote.java b/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentAndNote.java index 33cb4c343cf..fee4c6e850a 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentAndNote.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentAndNote.java @@ -7,6 +7,7 @@ import uk.gov.hmcts.reform.civil.documentmanagement.model.Document; import java.time.LocalDateTime; +import java.time.ZoneId; @Data @Builder(toBuilder = true) @@ -18,6 +19,6 @@ public class DocumentAndNote { private Document document; private String documentNote; @Builder.Default - private LocalDateTime createdDateTime = LocalDateTime.now(); + private LocalDateTime createdDateTime = LocalDateTime.now(ZoneId.of("Europe/London")); } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentWithName.java b/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentWithName.java index 3538f61d331..9aabf622994 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentWithName.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentWithName.java @@ -7,6 +7,7 @@ import uk.gov.hmcts.reform.civil.documentmanagement.model.Document; import java.time.LocalDateTime; +import java.time.ZoneId; @Data @Builder(toBuilder = true) @@ -17,5 +18,5 @@ public class DocumentWithName { private Document document; private String documentName; @Builder.Default - private LocalDateTime createdDateTime = LocalDateTime.now(); + private LocalDateTime createdDateTime = LocalDateTime.now(ZoneId.of("Europe/London")); } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/citizenui/ResponseOneVOneShowTagService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/citizenui/ResponseOneVOneShowTagService.java new file mode 100644 index 00000000000..f639722d4b1 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/citizenui/ResponseOneVOneShowTagService.java @@ -0,0 +1,55 @@ +package uk.gov.hmcts.reform.civil.service.citizenui; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.civil.handler.callback.user.spec.show.ResponseOneVOneShowTag; +import uk.gov.hmcts.reform.civil.model.CaseData; + +import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.ONE_V_ONE; +import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.getMultiPartyScenario; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; + +@Service +@RequiredArgsConstructor +public class ResponseOneVOneShowTagService { + + public ResponseOneVOneShowTag setUpOneVOneFlow(CaseData caseData) { + if (ONE_V_ONE.equals(getMultiPartyScenario(caseData))) { + if (caseData.getRespondent1ClaimResponseTypeForSpec() == null) { + return null; + } + return switch (caseData.getRespondent1ClaimResponseTypeForSpec()) { + case FULL_DEFENCE -> ResponseOneVOneShowTag.ONE_V_ONE_FULL_DEFENCE; + case FULL_ADMISSION -> setUpOneVOneFlowForFullAdmit(caseData); + case PART_ADMISSION -> setUpOneVOneFlowForPartAdmit(caseData); + case COUNTER_CLAIM -> ResponseOneVOneShowTag.ONE_V_ONE_COUNTER_CLAIM; + default -> null; + }; + } + return null; + } + + private ResponseOneVOneShowTag setUpOneVOneFlowForPartAdmit(CaseData caseData) { + if (YES.equals(caseData.getSpecDefenceAdmittedRequired())) { + return ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT_HAS_PAID; + } + return switch (caseData.getDefenceAdmitPartPaymentTimeRouteRequired()) { + case IMMEDIATELY -> ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT_PAY_IMMEDIATELY; + case BY_SET_DATE -> ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT_PAY_BY_SET_DATE; + case SUGGESTION_OF_REPAYMENT_PLAN -> ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT_PAY_INSTALMENT; + default -> ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT; + }; + } + + private ResponseOneVOneShowTag setUpOneVOneFlowForFullAdmit(CaseData caseData) { + if (YES.equals(caseData.getSpecDefenceFullAdmittedRequired())) { + return ResponseOneVOneShowTag.ONE_V_ONE_FULL_ADMIT_HAS_PAID; + } + return switch (caseData.getDefenceAdmitPartPaymentTimeRouteRequired()) { + case IMMEDIATELY -> ResponseOneVOneShowTag.ONE_V_ONE_FULL_ADMIT_PAY_IMMEDIATELY; + case BY_SET_DATE -> ResponseOneVOneShowTag.ONE_V_ONE_FULL_ADMIT_PAY_BY_SET_DATE; + case SUGGESTION_OF_REPAYMENT_PLAN -> ResponseOneVOneShowTag.ONE_V_ONE_FULL_ADMIT_PAY_INSTALMENT; + default -> ResponseOneVOneShowTag.ONE_V_ONE_FULL_ADMIT; + }; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventService.java index f38fd3c46ce..2b39e00bdd3 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventService.java @@ -6,7 +6,6 @@ import uk.gov.hmcts.reform.civil.callback.CaseEvent; import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; import uk.gov.hmcts.reform.civil.model.CaseData; -import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.stateflow.StateFlow; import java.util.List; @@ -29,68 +28,69 @@ import static uk.gov.hmcts.reform.civil.callback.CaseEvent.APPLICATION_OFFLINE_UPDATE_CLAIM; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.APPLY_NOC_DECISION; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.BUNDLE_CREATION_NOTIFICATION; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.LIP_CLAIM_SETTLED; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CLAIMANT_RESPONSE_CUI; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_CLAIM_SPEC_AFTER_PAYMENT; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_CLAIM_AFTER_PAYMENT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CASE_PROCEEDS_IN_CASEMAN; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CHANGE_SOLICITOR_EMAIL; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CLAIMANT_RESPONSE; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CLAIMANT_RESPONSE_CUI; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CLAIMANT_RESPONSE_SPEC; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_CLAIM; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_CLAIM_AFTER_PAYMENT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_CLAIM_SPEC; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_CLAIM_SPEC_AFTER_PAYMENT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_LIP_CLAIM; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_SDO; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DEFAULT_JUDGEMENT; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.MANAGE_CONTACT_INFORMATION; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_HEARING_PARTIES; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.REQUEST_JUDGEMENT_ADMISSION_SPEC; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DEFAULT_JUDGEMENT_SPEC; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DEFENDANT_RESPONSE; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DEFENDANT_RESPONSE_CUI; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DEFENDANT_RESPONSE_SPEC; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DISCONTINUE_CLAIM; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DISMISS_CLAIM; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.ENTER_BREATHING_SPACE_SPEC; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.ENTER_BREATHING_SPACE_LIP; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.ENTER_BREATHING_SPACE_SPEC; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.EVIDENCE_UPLOAD_APPLICANT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.EVIDENCE_UPLOAD_JUDGE; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.EVIDENCE_UPLOAD_RESPONDENT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.EXTEND_RESPONSE_DEADLINE; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.HEARING_FEE_UNPAID; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.GENERATE_DIRECTIONS_ORDER; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.HEARING_FEE_PAID; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.HEARING_FEE_UNPAID; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.HEARING_SCHEDULED; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.INFORM_AGREED_EXTENSION_DATE; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.INFORM_AGREED_EXTENSION_DATE_SPEC; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.INITIATE_GENERAL_APPLICATION; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.JUDGMENT_PAID_IN_FULL; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.LIFT_BREATHING_SPACE_SPEC; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.LIP_CLAIM_SETTLED; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.MANAGE_CONTACT_INFORMATION; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.MEDIATION_SUCCESSFUL; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.MEDIATION_UNSUCCESSFUL; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.RESET_PIN; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIAL_READINESS; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.UPLOAD_TRANSLATED_DOCUMENT; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.migrateCase; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.MOVE_TO_DECISION_OUTCOME; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOC_REQUEST; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_DEFENDANT_CUI_FOR_DEADLINE_EXTENSION; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_CLAIMANT_CUI_FOR_DEADLINE_EXTENSION; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_DEFENDANT_CUI_FOR_DEADLINE_EXTENSION; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_DEFENDANT_OF_CLAIM; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_DEFENDANT_OF_CLAIM_DETAILS; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_HEARING_PARTIES; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NotSuitable_SDO; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.RECORD_JUDGMENT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.REFER_TO_JUDGE; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.REQUEST_JUDGEMENT_ADMISSION_SPEC; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.RESET_PIN; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.RESUBMIT_CLAIM; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.SERVICE_REQUEST_RECEIVED; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.SET_ASIDE_JUDGMENT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.STANDARD_DIRECTION_ORDER_DJ; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TAKE_CASE_OFFLINE; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIAL_READY_NOTIFICATION; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRANSFER_ONLINE_CASE; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIAL_READINESS; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIAL_READY_CHECK; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.GENERATE_DIRECTIONS_ORDER; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIAL_READY_NOTIFICATION; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.UPLOAD_TRANSLATED_DOCUMENT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.WITHDRAW_CLAIM; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.SET_ASIDE_JUDGMENT; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.JUDGMENT_PAID_IN_FULL; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.RECORD_JUDGMENT; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRANSFER_ONLINE_CASE; -import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PREPARE_FOR_HEARING_CONDUCT_HEARING; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.asyncStitchingComplete; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.migrateCase; +import static uk.gov.hmcts.reform.civil.enums.CaseCategory.SPEC_CLAIM; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.AWAITING_RESPONSES_FULL_DEFENCE_RECEIVED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.AWAITING_RESPONSES_NOT_FULL_DEFENCE_RECEIVED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.CLAIM_DETAILS_NOTIFIED; @@ -123,17 +123,18 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PAST_CLAIM_DISMISSED_DEADLINE_AWAITING_CAMUNDA; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PAST_CLAIM_NOTIFICATION_DEADLINE_AWAITING_CAMUNDA; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PREPARE_FOR_HEARING_CONDUCT_HEARING; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.RESPONDENT_RESPONSE_LANGUAGE_IS_BILINGUAL; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.SPEC_DRAFT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_AFTER_CLAIM_DETAILS_NOTIFIED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_AFTER_CLAIM_NOTIFIED; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_AFTER_SDO; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_BY_STAFF; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_PAST_APPLICANT_RESPONSE_DEADLINE; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_SDO_NOT_DRAWN; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_UNREGISTERED_DEFENDANT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_UNREPRESENTED_UNREGISTERED_DEFENDANT; -import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_AFTER_SDO; @Service @RequiredArgsConstructor @@ -141,7 +142,6 @@ public class FlowStateAllowedEventService { private final StateFlowEngine stateFlowEngine; private final CaseDetailsConverter caseDetailsConverter; - private final FeatureToggleService toggleService; private static final Map> ALLOWED_EVENTS_ON_FLOW_STATE = Map.ofEntries( entry( @@ -1335,6 +1335,76 @@ public class FlowStateAllowedEventService { List.of( asyncStitchingComplete ) + ), + entry( + TAKEN_OFFLINE_BY_STAFF.fullName(), + List.of( + ADD_CASE_NOTE, + APPLICATION_OFFLINE_UPDATE_CLAIM, + migrateCase + ) + ), + entry( + TAKEN_OFFLINE_UNREGISTERED_DEFENDANT.fullName(), + List.of( + ADD_CASE_NOTE, + APPLICATION_OFFLINE_UPDATE_CLAIM, + migrateCase + ) + ), + entry( + TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT.fullName(), + List.of( + ADD_CASE_NOTE, + APPLICATION_OFFLINE_UPDATE_CLAIM, + migrateCase + ) + ), + entry( + TAKEN_OFFLINE_UNREPRESENTED_UNREGISTERED_DEFENDANT.fullName(), + List.of( + ADD_CASE_NOTE, + APPLICATION_OFFLINE_UPDATE_CLAIM, + migrateCase + ) + ), + entry( + TAKEN_OFFLINE_PAST_APPLICANT_RESPONSE_DEADLINE.fullName(), + List.of( + ADD_CASE_NOTE, + APPLICATION_OFFLINE_UPDATE_CLAIM, + migrateCase + ) + ), + entry( + TAKEN_OFFLINE_AFTER_CLAIM_DETAILS_NOTIFIED.fullName(), + List.of( + ADD_CASE_NOTE, + APPLICATION_OFFLINE_UPDATE_CLAIM, + migrateCase + ) + ), + entry( + TAKEN_OFFLINE_AFTER_CLAIM_NOTIFIED.fullName(), + List.of( + ADD_CASE_NOTE, + APPLICATION_OFFLINE_UPDATE_CLAIM, + migrateCase + ) + ), + entry( + TAKEN_OFFLINE_SDO_NOT_DRAWN.fullName(), + List.of( + ADD_CASE_NOTE, + migrateCase + ) + ), + entry( + TAKEN_OFFLINE_AFTER_SDO.fullName(), + List.of( + ADD_CASE_NOTE, + AMEND_PARTY_DETAILS + ) ) ); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngine.java b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngine.java index 03ad14f2cee..39f82bb7088 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngine.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngine.java @@ -3,13 +3,13 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.ccd.client.model.CaseDetails; -import uk.gov.hmcts.reform.civil.handler.callback.user.RespondToDefenceCallbackHandler; import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.stateflow.StateFlow; import uk.gov.hmcts.reform.civil.stateflow.StateFlowBuilder; import uk.gov.hmcts.reform.civil.stateflow.model.State; +import uk.gov.hmcts.reform.civil.utils.JudicialReferralUtils; import java.util.Map; @@ -18,8 +18,8 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowFlag.BULK_CLAIM_ENABLED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowFlag.GENERAL_APPLICATION_ENABLED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.agreedToMediation; -import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.declinedMediation; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.ccjRequestJudgmentByAdmission; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.declinedMediation; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.isLipCase; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.isTranslatedDocumentUploaded; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.partAdmitPayImmediately; @@ -40,9 +40,9 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.caseDismissedAfterDetailNotifiedExtension; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.caseDismissedPastHearingFeeDue; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.casemanMarksMediationUnsuccessful; -import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimDismissalOutOfTime; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.certificateOfServiceEnabled; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimDetailsNotified; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimDismissalOutOfTime; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimDismissedByCamunda; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimIssued; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimNotified; @@ -72,8 +72,8 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.fullDefenceSpec; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.isClaimantNotSettlePartAdmitClaim; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.isInHearingReadiness; -import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.isRespondentResponseLangIsBilingual; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.isPayImmediately; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.isRespondentResponseLangIsBilingual; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.multipartyCase; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.noticeOfChangeEnabled; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.notificationAcknowledged; @@ -137,11 +137,11 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FLOW_NAME; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_ADMISSION; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_ADMIT_AGREE_REPAYMENT; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_ADMIT_JUDGMENT_ADMISSION; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_ADMIT_NOT_PROCEED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_ADMIT_PAY_IMMEDIATELY; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_ADMIT_PROCEED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_ADMIT_REJECT_REPAYMENT; -import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_ADMIT_JUDGMENT_ADMISSION; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_DEFENCE; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_DEFENCE_NOT_PROCEED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_DEFENCE_PROCEED; @@ -153,9 +153,9 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PART_ADMISSION; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PART_ADMIT_AGREE_REPAYMENT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PART_ADMIT_AGREE_SETTLE; -import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PART_ADMIT_PAY_IMMEDIATELY; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PART_ADMIT_NOT_PROCEED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PART_ADMIT_NOT_SETTLED_NO_MEDIATION; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PART_ADMIT_PAY_IMMEDIATELY; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PART_ADMIT_PROCEED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PART_ADMIT_REJECT_REPAYMENT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PAST_APPLICANT_RESPONSE_DEADLINE_AWAITING_CAMUNDA; @@ -507,20 +507,20 @@ public StateFlow build(FlowState.Main initialState) { .onlyIf(fullDefenceProceed.and(allAgreedToLrMediationSpec).and(agreedToMediation.negate()).and(declinedMediation.negate())) .set((c, flags) -> { flags.put(FlowFlag.AGREED_TO_MEDIATION.name(), true); - flags.put(FlowFlag.SDO_ENABLED.name(), RespondToDefenceCallbackHandler.shouldMoveToJudicialReferral(c)); + flags.put(FlowFlag.SDO_ENABLED.name(), JudicialReferralUtils.shouldMoveToJudicialReferral(c)); }) .transitionTo(FULL_DEFENCE_PROCEED) .onlyIf(fullDefenceProceed.and(allAgreedToLrMediationSpec.negate().and(agreedToMediation.negate())) .or(declinedMediation).and(applicantOutOfTime.negate()).and(demageMultiClaim)) .set((c, flags) -> { flags.put(FlowFlag.IS_MULTI_TRACK.name(), true); - flags.put(FlowFlag.SDO_ENABLED.name(), RespondToDefenceCallbackHandler.shouldMoveToJudicialReferral(c)); + flags.put(FlowFlag.SDO_ENABLED.name(), JudicialReferralUtils.shouldMoveToJudicialReferral(c)); }) .transitionTo(FULL_DEFENCE_PROCEED) .onlyIf(fullDefenceProceed.and(allAgreedToLrMediationSpec.negate().and(agreedToMediation.negate())) .or(declinedMediation).and(applicantOutOfTime.negate()).and(demageMultiClaim.negate())) .setDynamic(Map.of(FlowFlag.SDO_ENABLED.name(), - RespondToDefenceCallbackHandler::shouldMoveToJudicialReferral)) + JudicialReferralUtils::shouldMoveToJudicialReferral)) .transitionTo(FULL_DEFENCE_NOT_PROCEED).onlyIf(fullDefenceNotProceed) .transitionTo(TAKEN_OFFLINE_BY_STAFF).onlyIf(takenOfflineByStaffAfterDefendantResponse) .transitionTo(PAST_APPLICANT_RESPONSE_DEADLINE_AWAITING_CAMUNDA) @@ -554,7 +554,7 @@ public StateFlow build(FlowState.Main initialState) { .transitionTo(PART_ADMIT_NOT_SETTLED_NO_MEDIATION) .onlyIf(isClaimantNotSettlePartAdmitClaim.and(not(agreedToMediation))) .setDynamic(Map.of(FlowFlag.SDO_ENABLED.name(), - RespondToDefenceCallbackHandler::shouldMoveToJudicialReferral)) + JudicialReferralUtils::shouldMoveToJudicialReferral)) .transitionTo(PART_ADMIT_PROCEED).onlyIf(fullDefenceProceed) .transitionTo(PART_ADMIT_NOT_PROCEED).onlyIf(fullDefenceNotProceed) .transitionTo(PART_ADMIT_PAY_IMMEDIATELY).onlyIf(partAdmitPayImmediately) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchService.java index d23f38cf85b..b418a6a16fd 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchService.java @@ -13,6 +13,7 @@ import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.index.query.QueryBuilders.rangeQuery; +import static uk.gov.hmcts.reform.civil.enums.CaseState.HEARING_READINESS; import static uk.gov.hmcts.reform.civil.enums.CaseState.PREPARE_FOR_HEARING_CONDUCT_HEARING; @Service @@ -30,7 +31,10 @@ public Query query(int startIndex) { .must(rangeQuery("data.hearingDate").lt(LocalDate.now() .atTime(LocalTime.MIN).plusWeeks(3) .toString())) - .must(beState(PREPARE_FOR_HEARING_CONDUCT_HEARING)) + .must(boolQuery() + .minimumShouldMatch(1) + .should(beState(PREPARE_FOR_HEARING_CONDUCT_HEARING)) + .should(beState(HEARING_READINESS))) .mustNot(matchQuery("data.allocatedTrack", "SMALL_CLAIM")) .mustNot(matchQuery("data.trialReadyChecked", "Yes"))), List.of("reference"), diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchService.java index 878b2f73638..53a26cd55e1 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchService.java @@ -15,6 +15,7 @@ import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.index.query.QueryBuilders.rangeQuery; +import static uk.gov.hmcts.reform.civil.enums.CaseState.HEARING_READINESS; import static uk.gov.hmcts.reform.civil.enums.CaseState.PREPARE_FOR_HEARING_CONDUCT_HEARING; @Service @@ -32,10 +33,13 @@ public Query query(int startIndex) { .must(rangeQuery("data.hearingDate").lt(LocalDate.now() .atTime(LocalTime.MIN) .plusWeeks(6).toString())) - .must(beState(PREPARE_FOR_HEARING_CONDUCT_HEARING))) + .must(boolQuery() + .minimumShouldMatch(1) + .should(beState(PREPARE_FOR_HEARING_CONDUCT_HEARING)) + .should(beState(HEARING_READINESS))) .mustNot(matchQuery("data.allocatedTrack", "SMALL_CLAIM")) .mustNot(matchQuery("data.listingOrRelisting", ListingOrRelisting.RELISTING)) - .mustNot(matchQuery("data.trialReadyNotified", YesOrNo.YES)), + .mustNot(matchQuery("data.trialReadyNotified", YesOrNo.YES))), List.of("reference"), startIndex ); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/utils/JudicialReferralUtils.java b/src/main/java/uk/gov/hmcts/reform/civil/utils/JudicialReferralUtils.java new file mode 100644 index 00000000000..2df4c2c08f1 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/utils/JudicialReferralUtils.java @@ -0,0 +1,58 @@ +package uk.gov.hmcts.reform.civil.utils; + +import uk.gov.hmcts.reform.civil.enums.AllocatedTrack; +import uk.gov.hmcts.reform.civil.enums.CaseCategory; +import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; +import uk.gov.hmcts.reform.civil.model.CaseData; + +import static uk.gov.hmcts.reform.civil.enums.AllocatedTrack.getAllocatedTrack; +import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.getMultiPartyScenario; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; + +public class JudicialReferralUtils { + + private JudicialReferralUtils() { + //NO-OP + } + + /** + * Computes whether the case data should move to judicial referral or not. + * + * @param caseData a case data such that defendants rejected the claim, and claimant(s) wants to proceed + * vs all the defendants + * @return true if and only if the case should move to judicial referral + */ + public static boolean shouldMoveToJudicialReferral(CaseData caseData) { + CaseCategory caseCategory = caseData.getCaseAccessCategory(); + + if (CaseCategory.SPEC_CLAIM.equals(caseCategory)) { + MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData); + + return switch (multiPartyScenario) { + case ONE_V_ONE, ONE_V_TWO_ONE_LEGAL_REP, ONE_V_TWO_TWO_LEGAL_REP -> caseData.getApplicant1ProceedWithClaim() == YesOrNo.YES; + case TWO_V_ONE -> caseData.getApplicant1ProceedWithClaimSpec2v1() == YesOrNo.YES; + }; + } else { + AllocatedTrack allocatedTrack = + getAllocatedTrack( + CaseCategory.UNSPEC_CLAIM.equals(caseCategory) + ? caseData.getClaimValue().toPounds() + : caseData.getTotalClaimAmount(), + caseData.getClaimType() + ); + if (AllocatedTrack.MULTI_CLAIM.equals(allocatedTrack)) { + return false; + } + MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData); + return switch (multiPartyScenario) { + case ONE_V_ONE -> caseData.getApplicant1ProceedWithClaim() == YesOrNo.YES; + case TWO_V_ONE -> caseData.getApplicant1ProceedWithClaimMultiParty2v1() == YES + && caseData.getApplicant2ProceedWithClaimMultiParty2v1() == YES; + case ONE_V_TWO_ONE_LEGAL_REP, ONE_V_TWO_TWO_LEGAL_REP -> + caseData.getApplicant1ProceedWithClaimAgainstRespondent1MultiParty1v2() == YES + && caseData.getApplicant1ProceedWithClaimAgainstRespondent2MultiParty1v2() == YES; + }; + } + } +} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 485b2ee98f1..187c0e2b2f9 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -215,6 +215,7 @@ notifications: claimantSolicitorDefendantResponseForSpec: "28ea1d53-93b1-4e48-a7e5-7a876f910f86" claimantSolicitorImmediatelyDefendantResponseForSpec: "263d7737-933d-4d0b-9f08-23847613f6a4" respondentSolicitorDefendantResponseForSpec: "9527f77e-b346-4527-b93c-c2affd39fa51" + respondentSolicitorDefResponseSpecWithClaimantAction: "efbd38e8-3fe7-4db6-ad55-b751b96477b1" respondentDefendantResponseForSpec: "94c71894-9590-4995-aae0-edea94fc4594" sdoOrdered: "90667080-6b20-48f2-b9ea-349fa8ec78e4" sdoOrderedSpec: "1c1a200c-b3c1-45eb-9768-aeea56857420" @@ -228,6 +229,8 @@ notifications: respondentSolicitorNotifyNotToProceedSpec: "4dc0b5bb-674f-401e-8a39-05686dc0302e" claimantSolicitorConfirmsToProceedSpec: "99786d26-ab90-43c7-aa20-9d450d8ce4eb" respondentSolicitorNotifyToProceedSpec: "ea6cb18e-ebba-4759-8df3-426e00f2f09c" + claimantSolicitorConfirmsToProceedSpecWithAction: "d454e5a9-8c56-4a1d-acce-53a1686376bc" + respondentSolicitorNotifyToProceedSpecWithAction: "c1bb435e-0300-4e51-89ec-56dd7f77ef27" applicantSolicitor1DefaultJudgmentReceived: "14a43ad4-e337-490a-bf8b-1288520dc9eb" claimantSolicitorCounterClaimForSpec: "256b6cf4-6201-48f0-bf1e-88a187712196" respondentSolicitorCounterClaimForSpec: "6cb3b3d5-f1aa-4236-ad03-685605a9235e" diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantResponseConfirmsToProceedRespondentNotificationHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantResponseConfirmsToProceedRespondentNotificationHandlerTest.java index c9cf92fd0e1..9f67e39cac1 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantResponseConfirmsToProceedRespondentNotificationHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantResponseConfirmsToProceedRespondentNotificationHandlerTest.java @@ -12,17 +12,17 @@ import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.callback.CaseEvent; import uk.gov.hmcts.reform.civil.enums.CaseCategory; -import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; +import uk.gov.hmcts.reform.civil.enums.RespondentResponseTypeSpec; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; -import uk.gov.hmcts.reform.civil.sampledata.PartyBuilder; -import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.notify.NotificationService; +import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; +import uk.gov.hmcts.reform.civil.prd.model.Organisation; import uk.gov.hmcts.reform.civil.sampledata.CallbackParamsBuilder; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; -import uk.gov.hmcts.reform.civil.notify.NotificationService; +import uk.gov.hmcts.reform.civil.sampledata.PartyBuilder; import uk.gov.hmcts.reform.civil.service.OrganisationService; -import uk.gov.hmcts.reform.civil.prd.model.Organisation; import java.util.Map; import java.util.Optional; @@ -60,8 +60,6 @@ class ClaimantResponseConfirmsToProceedRespondentNotificationHandlerTest extends private NotificationsProperties notificationsProperties; @Autowired private ClaimantResponseConfirmsToProceedRespondentNotificationHandler handler; - @MockBean - private FeatureToggleService featureToggleService; @Nested class AboutToSubmitCallback { @@ -72,6 +70,8 @@ void setup() { when(notificationsProperties.getClaimantSolicitorConfirmsNotToProceed()).thenReturn("template-id"); when(notificationsProperties.getRespondentSolicitorNotifyToProceedSpec()).thenReturn("spec-template-id"); when(notificationsProperties.getClaimantSolicitorConfirmsToProceedSpec()).thenReturn("spec-template-id"); + when(notificationsProperties.getRespondentSolicitorNotifyToProceedSpecWithAction()).thenReturn("spec-template-no-mediation"); + when(notificationsProperties.getClaimantSolicitorConfirmsToProceedSpecWithAction()).thenReturn("spec-template-no-mediation"); when(notificationsProperties.getRespondent1LipClaimUpdatedTemplate()).thenReturn("spec-template-id"); } @@ -113,6 +113,30 @@ void shouldNotifyRespondentSolicitor_whenInvoked_spec() { ); } + @Test + void shouldNotifyRespondentSolicitor_whenSpecRejectAllNoMediation() { + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimDetailsNotified() + .setClaimTypeToSpecClaim() + .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE) + .build().toBuilder() + .responseClaimMediationSpecRequired(YesOrNo.NO) + .build(); + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( + CallbackRequest.builder().eventId("NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED") + .build()).build(); + + handler.handle(params); + + verify(notificationService).sendMail( + "respondentsolicitor@example.com", + "spec-template-no-mediation", + getNotificationDataMapSpec(caseData, + CaseEvent.NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED), + "claimant-confirms-to-proceed-respondent-notification-000DC001" + ); + } + @Test void shouldNotifyRespondentSolicitor2_whenInvoked_spec() { CaseData caseData = CaseDataBuilder.builder() @@ -155,6 +179,30 @@ void shouldNotifyApplicantSolicitor_whenInvoked_spec() { ); } + @Test + void shouldNotifyApplicantSolicitor_whenSpecRejectAllNoMediation() { + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimDetailsNotified() + .setClaimTypeToSpecClaim() + .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE) + .build().toBuilder() + .responseClaimMediationSpecRequired(YesOrNo.NO) + .build(); + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( + CallbackRequest.builder().eventId("NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED_CC") + .build()).build(); + + handler.handle(params); + + verify(notificationService).sendMail( + "applicantsolicitor@example.com", + "spec-template-no-mediation", + getNotificationDataMapSpec(caseData, + CaseEvent.NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED_CC), + "claimant-confirms-to-proceed-respondent-notification-000DC001" + ); + } + @Test void shouldNotifyRespondentSolicitor2withNoIntentionToProceed_whenInvoked() { CaseData caseData = CaseDataBuilder.builder() @@ -316,11 +364,11 @@ void shouldReturnCorrectCamundaActivityId_whenInvoked() { "NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED").build()).build())).isEqualTo(TASK_ID); assertThat(handler.camundaActivityId(CallbackParamsBuilder.builder().request(CallbackRequest.builder().eventId( - "NOTIFY_RESPONDENT_SOLICITOR2_FOR_CLAIMANT_CONFIRMS_TO_PROCEED").build()) + "NOTIFY_RESPONDENT_SOLICITOR2_FOR_CLAIMANT_CONFIRMS_TO_PROCEED").build()) .build())).isEqualTo(Task_ID_RESPONDENT_SOL2); assertThat(handler.camundaActivityId(CallbackParamsBuilder.builder().request(CallbackRequest.builder().eventId( "NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED_CC").build()).build())).isEqualTo( - TASK_ID_CC); + TASK_ID_CC); } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/DefendantResponseApplicantNotificationHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/DefendantResponseApplicantNotificationHandlerTest.java index b0f44a92d31..b9c5d6e3dee 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/DefendantResponseApplicantNotificationHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/DefendantResponseApplicantNotificationHandlerTest.java @@ -85,7 +85,7 @@ void setup() { when(organisationService.findOrganisationById(anyString())) .thenReturn(Optional.of(Organisation.builder().name("Signer Name").build())); when(notificationsProperties.getClaimantSolicitorImmediatelyDefendantResponseForSpec()).thenReturn("templateImm-id"); - + when(notificationsProperties.getRespondentSolicitorDefResponseSpecWithClaimantAction()).thenReturn("spec-respondent-template-id-action"); } @Nested @@ -168,17 +168,17 @@ void shouldNotifyApplicantSolicitorSpec_whenInvoked() { LocalDate whenWillPay = LocalDate.now().plusMonths(1); CaseData caseData = CaseDataBuilder.builder() - .atStateNotificationAcknowledged() - .build().toBuilder() - .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.PART_ADMISSION) + .atStateNotificationAcknowledged() + .build().toBuilder() + .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.PART_ADMISSION) .respondent2ClaimResponseTypeForSpec(RespondentResponseTypeSpec.PART_ADMISSION) .defenceAdmitPartPaymentTimeRouteRequired(RespondentResponsePartAdmissionPaymentTimeLRspec.BY_SET_DATE) - .respondToClaimAdmitPartLRspec( - RespondToClaimAdmitPartLRspec.builder() + .respondToClaimAdmitPartLRspec( + RespondToClaimAdmitPartLRspec.builder() .whenWillThisAmountBePaid(whenWillPay) .build() - ) - .build(); + ) + .build(); caseData = caseData.toBuilder().caseAccessCategory(SPEC_CLAIM).build(); CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( CallbackRequest.builder().eventId("NOTIFY_APPLICANT_SOLICITOR1_FOR_DEFENDANT_RESPONSE").build()) @@ -341,6 +341,29 @@ void shouldNotifyRespondentSolicitorSpecDef1_whenInvokedWithCcEvent() { handler.handle(params); + verify(notificationService).sendMail( + "respondentsolicitor@example.com", + "spec-respondent-template-id", + getNotificationDataMapPartAdmissionSpec(caseData), + "defendant-response-applicant-notification-000DC001" + ); + } + + @Test + void sendNotificationToSolicitorSpec_shouldNotifyRespondentSolicitorSpecDef1v1() { + CaseData caseData = CaseDataBuilder.builder() + .atStateNotificationAcknowledged().build(); + caseData = caseData.toBuilder().caseAccessCategory(SPEC_CLAIM) + .respondent1DQ(Respondent1DQ.builder().build()) + .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE) + .build(); + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( + CallbackRequest.builder().eventId("NOTIFY_APPLICANT_SOLICITOR1_FOR_DEFENDANT_RESPONSE_CC") + .build()) + .build(); + + handler.handle(params); + verify(notificationService).sendMail( "respondentsolicitor@example.com", "spec-respondent-template-id", @@ -349,6 +372,30 @@ void shouldNotifyRespondentSolicitorSpecDef1_whenInvokedWithCcEvent() { ); } + @Test + void sendNotificationToSolicitorSpecPart_shouldNotifyRespondentSolicitorSpecDef1v1() { + CaseData caseData = CaseDataBuilder.builder() + .atStateNotificationAcknowledged().build(); + caseData = caseData.toBuilder().caseAccessCategory(SPEC_CLAIM) + .respondent1DQ(Respondent1DQ.builder().build()) + .defenceAdmitPartPaymentTimeRouteRequired(RespondentResponsePartAdmissionPaymentTimeLRspec.IMMEDIATELY) + .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.PART_ADMISSION) + .build(); + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( + CallbackRequest.builder().eventId("NOTIFY_APPLICANT_SOLICITOR1_FOR_DEFENDANT_RESPONSE_CC") + .build()) + .build(); + + handler.handle(params); + + verify(notificationService).sendMail( + "respondentsolicitor@example.com", + "spec-respondent-template-id-action", + getNotificationDataMapSpec(caseData), + "defendant-response-applicant-notification-000DC001" + ); + } + @Test void shouldNotifyRespondentSolicitorSpecDef1SecondScenerio_whenInvokedWithCcEvent() { CaseData caseData = CaseDataBuilder.builder() @@ -546,6 +593,15 @@ private Map getNotificationDataMapImmediatelySpec(CaseData caseD ); } + + private Map getNotificationDataMapPartAdmissionSpec(CaseData caseData) { + return Map.of( + "defendantName", "Mr. Sole Trader", + CLAIM_LEGAL_ORG_NAME_SPEC, "Signer Name", + CLAIM_REFERENCE_NUMBER, LEGACY_CASE_REFERENCE + ); + } + } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandlerTest.java index 787f6d63f1f..d2dfccfe6ee 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandlerTest.java @@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.civil.callback.CallbackParams; @@ -14,20 +15,25 @@ import uk.gov.hmcts.reform.civil.enums.MediationDecision; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.model.Party; import uk.gov.hmcts.reform.civil.model.citizenui.CaseDataLiP; import uk.gov.hmcts.reform.civil.model.citizenui.ClaimantMediationLip; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; +import uk.gov.hmcts.reform.civil.service.citizenui.ResponseOneVOneShowTagService; import static org.assertj.core.api.Assertions.assertThat; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CLAIMANT_RESPONSE_CUI; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; +import static uk.gov.hmcts.reform.civil.model.Party.Type.COMPANY; +import static uk.gov.hmcts.reform.civil.model.Party.Type.ORGANISATION; @ExtendWith(SpringExtension.class) @SpringBootTest(classes = { ClaimantResponseCuiCallbackHandler.class, - JacksonAutoConfiguration.class + JacksonAutoConfiguration.class, + ResponseOneVOneShowTagService.class }) class ClaimantResponseCuiCallbackHandlerTest extends BaseCallbackHandlerTest { @@ -37,6 +43,9 @@ class ClaimantResponseCuiCallbackHandlerTest extends BaseCallbackHandlerTest { @Autowired private final ObjectMapper mapper = new ObjectMapper(); + @MockBean + private ResponseOneVOneShowTagService responseOneVOneShowTagService; + @Nested class AboutToStartCallback { @@ -120,5 +129,39 @@ void shouldChangeCaseState_whenApplicantRejectClaimSettlementAndAgreeToMediation assertThat(response.getState()).isEqualTo(CaseState.IN_MEDIATION.name()); } + + @Test + void shouldChangeCaseState_whenApplicantRejectRepaymentPlanAndIsCompany_toAllFinalOrdersIssued() { + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimIssued() + .applicant1AcceptPartAdmitPaymentPlanSpec(NO) + .respondent1(Party.builder() + .type(COMPANY) + .companyName("Test Inc") + .build()) + .build(); + + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + assertThat(response.getState()).isEqualTo(CaseState.PROCEEDS_IN_HERITAGE_SYSTEM.name()); + } + + @Test + void shouldChangeCaseState_whenApplicantRejectRepaymentPlanAndIsOrganisation_toAllFinalOrdersIssued() { + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimIssued() + .applicant1AcceptPartAdmitPaymentPlanSpec(NO) + .respondent1(Party.builder() + .type(ORGANISATION) + .companyName("Test Inc") + .build()) + .build(); + + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + assertThat(response.getState()).isEqualTo(CaseState.PROCEEDS_IN_HERITAGE_SYSTEM.name()); + } } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateSDOCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateSDOCallbackHandlerTest.java index 208f29cbf58..505d72475f1 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateSDOCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateSDOCallbackHandlerTest.java @@ -1,9 +1,12 @@ package uk.gov.hmcts.reform.civil.handler.callback.user; import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; @@ -65,9 +68,11 @@ import java.util.stream.Collectors; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; @@ -76,6 +81,8 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_SDO; import static uk.gov.hmcts.reform.civil.enums.CaseCategory.SPEC_CLAIM; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; import static uk.gov.hmcts.reform.civil.handler.callback.user.CreateSDOCallbackHandler.CONFIRMATION_HEADER; import static uk.gov.hmcts.reform.civil.handler.callback.user.CreateSDOCallbackHandler.CONFIRMATION_SUMMARY_1v1; import static uk.gov.hmcts.reform.civil.handler.callback.user.CreateSDOCallbackHandler.CONFIRMATION_SUMMARY_1v2; @@ -142,6 +149,49 @@ void setup() { .thenReturn(LocalDate.now().plusDays(7)); } + @Test + void shouldPopulateLocationListsWithPreselectedCourt() { + Category category = Category.builder().categoryKey("HearingChannel").key("INTER").valueEn("In Person").activeFlag("Y").build(); + CategorySearchResult categorySearchResult = CategorySearchResult.builder().categories(List.of(category)).build(); + String preSelectedCourt = "214320"; + List locations = List.of( + LocationRefData.builder().epimmsId("00001").courtLocationCode("00001") + .siteName("court 1").courtAddress("1 address").postcode("Y01 7RB").build(), + LocationRefData.builder().epimmsId(preSelectedCourt).courtLocationCode(preSelectedCourt) + .siteName("court 2").courtAddress("2 address").postcode("Y02 7RB").build(), + LocationRefData.builder().epimmsId("00003").courtLocationCode("00003") + .siteName("court 3").courtAddress("3 address").postcode("Y03 7RB").build() + ); + when(locationRefDataService.getCourtLocationsForDefaultJudgments(anyString())).thenReturn(locations); + when(categoryService.findCategoryByCategoryIdAndServiceId(any(), any(), any())).thenReturn(Optional.of(categorySearchResult)); + + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft() + .atStateClaimIssuedDisposalHearingSDOInPersonHearing().build(); + + CallbackParams params = callbackParamsOf(CallbackVersion.V_1, caseData, ABOUT_TO_START); + CaseDocument order = CaseDocument.builder().documentLink( + Document.builder().documentUrl("url").build()) + .build(); + when(sdoGeneratorService.generate(any(), any())).thenReturn(order); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + CaseData responseCaseData = objectMapper.convertValue(response.getData(), CaseData.class); + + DynamicList expected = DynamicList.builder() + .listItems(List.of( + DynamicListElement.builder().code("00001").label("court 1 - 1 address - Y01 7RB").build(), + DynamicListElement.builder().code(preSelectedCourt).label("court 2 - 2 address - Y02 7RB").build(), + DynamicListElement.builder().code("00003").label("court 3 - 3 address - Y03 7RB").build() + ) + ) + .value(DynamicListElement.builder().code(preSelectedCourt).label("court 2 - 2 address - Y02 7RB").build()) + .build(); + + assertThat(responseCaseData.getDisposalHearingMethodInPerson()).isEqualTo(expected); + assertThat(responseCaseData.getFastTrackMethodInPerson()).isEqualTo(expected); + assertThat(responseCaseData.getSmallClaimsMethodInPerson()).isEqualTo(expected); + } + @Test void shouldGenerateDynamicListsCorrectly() { Category category = Category.builder().categoryKey("HearingChannel").key("INTER").valueEn("In Person").activeFlag("Y").build(); @@ -194,8 +244,15 @@ class AboutToSubmitCallback { @BeforeEach void setup() { + List items = List.of("label 1", "label 2", "label 3"); + DynamicList options = DynamicList.fromList(items, Object::toString, items.get(0), false); caseData = CaseDataBuilder.builder().atStateClaimDraft() .caseManagementLocation(CaseLocationCivil.builder().baseLocation("00000").build()) + .build().toBuilder() + .disposalHearingMethodInPerson(options) + .fastTrackMethodInPerson(options) + .smallClaimsMethodInPerson(options) + .setFastTrackFlag(YES) .build(); params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); userId = UUID.randomUUID().toString(); @@ -206,11 +263,20 @@ void setup() { given(time.now()).willReturn(submittedDate); given(featureToggleService.isLocationWhiteListedForCaseProgression(anyString())).willReturn(true); + + given(featureToggleService.isEarlyAdoptersEnabled()).willReturn(true); } @Test void shouldUpdateBusinessProcess_whenInvoked() { - var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle( + params.toBuilder() + .caseData(params.getCaseData().toBuilder() + .claimsTrack(ClaimsTrack.smallClaimsTrack) + .drawDirectionsOrderRequired(NO) + .build()) + .build() + ); assertThat(response.getData()) .extracting("businessProcess") @@ -249,6 +315,8 @@ void shouldNotUpdateCaseLocation_whenDisposal() { .caseManagementLocation(CaseLocationCivil.builder().baseLocation("00000").build()) .disposalHearingMethod(DisposalHearingMethod.disposalHearingMethodInPerson) .disposalHearingMethodInPerson(options) + .fastTrackMethodInPerson(options) + .smallClaimsMethodInPerson(options) .disposalHearingMethodToggle(Collections.singletonList(OrderDetailsPagesSectionsToggle.SHOW)) .caseManagementLocation(previousManagementLocation) .build(); @@ -314,6 +382,8 @@ void shouldNotUpdateCaseLocation_whenSmallClaims() { CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build().toBuilder() .caseManagementLocation(CaseLocationCivil.builder().baseLocation("00000").build()) .smallClaimsMethod(SmallClaimsMethod.smallClaimsMethodInPerson) + .disposalHearingMethodInPerson(options) + .fastTrackMethodInPerson(options) .smallClaimsMethodInPerson(options) .claimsTrack(ClaimsTrack.smallClaimsTrack) .caseManagementLocation(previousManagementLocation) @@ -372,7 +442,7 @@ void shouldNotUpdateCaseLocation_whenFastTrackAndOrderRequired() { @Test void shouldNotUpdateCaseLocation_whenSmallClaimsAndOrderRequired() { List items = List.of("label 1", "label 2", "label 3"); - DynamicList options = DynamicList.fromList(items, Object::toString, items.get(0), false); + DynamicList options = DynamicList.fromList(items, Object::toString, Object::toString, items.get(0), false); CaseLocationCivil previousManagementLocation = CaseLocationCivil.builder() .region("previous region") .baseLocation("previous base location") @@ -380,6 +450,8 @@ void shouldNotUpdateCaseLocation_whenSmallClaimsAndOrderRequired() { CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build().toBuilder() .caseManagementLocation(CaseLocationCivil.builder().baseLocation("00000").build()) .smallClaimsMethod(SmallClaimsMethod.smallClaimsMethodInPerson) + .fastTrackMethodInPerson(options) + .disposalHearingMethodInPerson(options) .smallClaimsMethodInPerson(options) .drawDirectionsOrderRequired(YesOrNo.YES) .drawDirectionsOrderSmallClaims(YesOrNo.YES) @@ -404,8 +476,14 @@ void shouldNotUpdateCaseLocation_whenSmallClaimsAndOrderRequired() { @Test void shouldReturnNullDocument_whenInvokedAboutToSubmit() { + List items = List.of("label 1", "label 2", "label 3"); + DynamicList options = DynamicList.fromList(items, Object::toString, Object::toString, items.get(0), false); CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build().toBuilder() .caseManagementLocation(CaseLocationCivil.builder().baseLocation("00000").build()) + .build().toBuilder() + .fastTrackMethodInPerson(options) + .disposalHearingMethodInPerson(options) + .smallClaimsMethodInPerson(options) .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); @@ -415,6 +493,212 @@ void shouldReturnNullDocument_whenInvokedAboutToSubmit() { } } + @ParameterizedTest + @CsvSource({"true", "false"}) + void shouldSetEarlyAdoptersFlag_whenDisposal(Boolean isLocationWhiteListed) { + DynamicList options = DynamicList.builder() + .listItems(List.of( + DynamicListElement.builder().code("00001").label("court 1 - 1 address - Y01 7RB").build(), + DynamicListElement.builder().code("00002").label("court 2 - 2 address - Y02 7RB").build(), + DynamicListElement.builder().code("00003").label("court 3 - 3 address - Y03 7RB").build() + ) + ) + .build(); + + DynamicListElement selectedCourt = DynamicListElement.builder() + .code("00002").label("court 2 - 2 address - Y02 7RB").build(); + + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build().toBuilder() + .caseManagementLocation(CaseLocationCivil.builder().baseLocation("00000").build()) + .disposalHearingMethod(DisposalHearingMethod.disposalHearingMethodInPerson) + .disposalHearingMethodInPerson(options.toBuilder().value(selectedCourt).build()) + .fastTrackMethodInPerson(options) + .smallClaimsMethodInPerson(options) + .disposalHearingMethodInPerson(options.toBuilder().value(selectedCourt).build()) + .disposalHearingMethodToggle(Collections.singletonList(OrderDetailsPagesSectionsToggle.SHOW)) + .orderType(OrderType.DISPOSAL) + .build(); + + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + when(featureToggleService.isEarlyAdoptersEnabled()).thenReturn(true); + when(featureToggleService.isLocationWhiteListedForCaseProgression(eq(selectedCourt.getCode()))).thenReturn( + isLocationWhiteListed); + when(locationRefDataService.getLocationMatchingLabel(selectedCourt.getCode(), params.getParams().get( + CallbackParams.Params.BEARER_TOKEN).toString())) + .thenReturn(Optional.of(LocationRefData.builder() + .regionId("region id") + .epimmsId("epimms id") + .siteName("site name") + .build())); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + CaseData responseCaseData = objectMapper.convertValue(response.getData(), CaseData.class); + + assertThat(responseCaseData.getEaCourtLocation()).isEqualTo(isLocationWhiteListed ? YES : NO); + } + + @ParameterizedTest + @CsvSource({"true", "false"}) + void shouldSetEarlyAdoptersFlag_whenSmallClaims(Boolean isLocationWhiteListed) { + DynamicList options = DynamicList.builder() + .listItems(List.of( + DynamicListElement.builder().code("00001").label("court 1 - 1 address - Y01 7RB").build(), + DynamicListElement.builder().code("00002").label("court 2 - 2 address - Y02 7RB").build(), + DynamicListElement.builder().code("00003").label("court 3 - 3 address - Y03 7RB").build() + ) + ) + .build(); + + DynamicListElement selectedCourt = DynamicListElement.builder() + .code("00002").label("court 2 - 2 address - Y02 7RB").build(); + + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build().toBuilder() + .caseManagementLocation(CaseLocationCivil.builder().baseLocation("00000").build()) + .smallClaimsMethod(SmallClaimsMethod.smallClaimsMethodInPerson) + .disposalHearingMethodInPerson(options) + .fastTrackMethodInPerson(options) + .smallClaimsMethodInPerson(options.toBuilder().value(selectedCourt).build()) + .claimsTrack(ClaimsTrack.smallClaimsTrack) + .setSmallClaimsFlag(YES) + .drawDirectionsOrderRequired(NO) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + when(featureToggleService.isEarlyAdoptersEnabled()).thenReturn(true); + when(featureToggleService.isLocationWhiteListedForCaseProgression(eq(selectedCourt.getCode()))).thenReturn( + isLocationWhiteListed); + when(locationRefDataService.getLocationMatchingLabel("label 1", params.getParams().get( + CallbackParams.Params.BEARER_TOKEN).toString())).thenReturn( + Optional.of(LocationRefData.builder() + .regionId("region id") + .epimmsId("epimms id") + .siteName("location name") + .build())); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + CaseData responseCaseData = objectMapper.convertValue(response.getData(), CaseData.class); + + assertThat(responseCaseData.getEaCourtLocation()).isEqualTo(isLocationWhiteListed ? YES : NO); + } + + @ParameterizedTest + @CsvSource({"true", "false"}) + void shouldSetEarlyAdoptersFlag_whenFastTrack(Boolean isLocationWhiteListed) { + DynamicList options = DynamicList.builder() + .listItems(List.of( + DynamicListElement.builder().code("00001").label("court 1 - 1 address - Y01 7RB").build(), + DynamicListElement.builder().code("00002").label("court 2 - 2 address - Y02 7RB").build(), + DynamicListElement.builder().code("00003").label("court 3 - 3 address - Y03 7RB").build() + ) + ) + .build(); + + DynamicListElement selectedCourt = DynamicListElement.builder() + .code("00002").label("court 2 - 2 address - Y02 7RB").build(); + + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build().toBuilder() + .caseManagementLocation(CaseLocationCivil.builder().baseLocation("00000").build()) + .fastTrackMethod(FastTrackMethod.fastTrackMethodInPerson) + .smallClaimsMethodInPerson(options) + .fastTrackMethodInPerson(options.toBuilder().value(selectedCourt).build()) + .disposalHearingMethodInPerson(options) + .claimsTrack(ClaimsTrack.fastTrack) + .setFastTrackFlag(YES) + .drawDirectionsOrderRequired(NO) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + when(featureToggleService.isEarlyAdoptersEnabled()).thenReturn(true); + when(featureToggleService.isLocationWhiteListedForCaseProgression(eq(selectedCourt.getCode()))).thenReturn( + isLocationWhiteListed); + when(locationRefDataService.getLocationMatchingLabel("label 1", params.getParams().get( + CallbackParams.Params.BEARER_TOKEN).toString())).thenReturn( + Optional.of(LocationRefData.builder() + .regionId("region id") + .epimmsId("epimms id") + .siteName("location name") + .build())); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + CaseData responseCaseData = objectMapper.convertValue(response.getData(), CaseData.class); + + assertThat(responseCaseData.getEaCourtLocation()).isEqualTo(isLocationWhiteListed ? YES : NO); + } + + @Test + @SneakyThrows + void shouldThrowIllegalArgumentException_whenClaimTrackCannotDefined() { + DynamicList options = DynamicList.builder() + .listItems(List.of( + DynamicListElement.builder().code("00001").label("court 1 - 1 address - Y01 7RB").build(), + DynamicListElement.builder().code("00002").label("court 2 - 2 address - Y02 7RB").build(), + DynamicListElement.builder().code("00003").label("court 3 - 3 address - Y03 7RB").build() + ) + ) + .build(); + + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build().toBuilder() + .caseManagementLocation(CaseLocationCivil.builder().baseLocation("00000").build()) + .fastTrackMethod(FastTrackMethod.fastTrackMethodInPerson) + .smallClaimsMethodInPerson(options) + .fastTrackMethodInPerson(options) + .disposalHearingMethodInPerson(options) + .claimsTrack(ClaimsTrack.fastTrack) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + when(featureToggleService.isEarlyAdoptersEnabled()).thenReturn(true); + when(locationRefDataService.getLocationMatchingLabel("label 1", params.getParams().get( + CallbackParams.Params.BEARER_TOKEN).toString())).thenReturn( + Optional.of(LocationRefData.builder() + .regionId("region id") + .epimmsId("epimms id") + .siteName("location name") + .build())); + + assertThrows(IllegalArgumentException.class, () -> handler.handle(params), + "Epimms Id is not provided" + ); + } + + @ParameterizedTest + @CsvSource({"true", "false"}) + void shouldNotSetEarlyAdoptersFlag_whenEarlyAdoptersToggleIsOff(Boolean isLocationWhiteListed) { + DynamicList options = DynamicList.builder() + .listItems(List.of( + DynamicListElement.builder().code("00001").label("court 1 - 1 address - Y01 7RB").build(), + DynamicListElement.builder().code("00002").label("court 2 - 2 address - Y02 7RB").build(), + DynamicListElement.builder().code("00003").label("court 3 - 3 address - Y03 7RB").build() + ) + ) + .build(); + + DynamicListElement selectedCourt = DynamicListElement.builder() + .code("00002").label("court 2 - 2 address - Y02 7RB").build(); + + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build().toBuilder() + .caseManagementLocation(CaseLocationCivil.builder().baseLocation("00000").build()) + .fastTrackMethod(FastTrackMethod.fastTrackMethodInPerson) + .fastTrackMethodInPerson(options.toBuilder().value(selectedCourt).build()) + .smallClaimsMethodInPerson(options) + .disposalHearingMethodInPerson(options) + .claimsTrack(ClaimsTrack.fastTrack) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + when(featureToggleService.isEarlyAdoptersEnabled()).thenReturn(false); + when(featureToggleService.isLocationWhiteListedForCaseProgression(eq(selectedCourt.getCode()))).thenReturn( + isLocationWhiteListed); + when(locationRefDataService.getLocationMatchingLabel("label 1", params.getParams().get( + CallbackParams.Params.BEARER_TOKEN).toString())).thenReturn( + Optional.of(LocationRefData.builder() + .regionId("region id") + .epimmsId("epimms id") + .siteName("location name") + .build())); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + CaseData responseCaseData = objectMapper.convertValue(response.getData(), CaseData.class); + + assertThat(responseCaseData.getEaCourtLocation()).isNull(); + } + @Nested class MidEventDisposalHearingLocationRefDataCallback extends LocationRefSampleDataBuilder { diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandlerTest.java index ddc7d79823c..d37c56db259 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandlerTest.java @@ -97,20 +97,115 @@ void shouldPopulateNoteDateTime_whenNoteIsAddedToCase() { assertThat(response.getData()).extracting("caseNotesTA") .isEqualTo(objectMapper.convertValue(updatedCaseNotes, new TypeReference<>() {})); + assertThat(response.getData()).extracting("documentAndName").isNull(); + assertThat(response.getData()).extracting("documentAndNote").isNull(); + } + + @Test + void shouldCopyDocumentAndNameToAdd_whenDocumentWithNameIsNull() { + Document document = Document.builder().documentFileName("fileName").build(); + DocumentWithName testDocument = DocumentWithName.builder() + .documentName("testDocument") + .document(document) + .build(); + List> documentWithNameToAdd = wrapElements(testDocument); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() + .caseNoteType(CaseNoteType.DOCUMENT_ONLY) + .documentAndNameToAdd(documentWithNameToAdd) + .caseNoteTA(null) + .build(); + + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + assertThat(response.getData()).extracting("documentAndName") + .isEqualTo(objectMapper.convertValue(documentWithNameToAdd, new TypeReference<>() {})); + assertThat(response.getData()).extracting("caseNotesTA").isNull(); + assertThat(response.getData()).extracting("documentAndNote").isNull(); } @Test - void shouldNotPopulateNoteDateTime_whenNoteIsAddedToCase() { + void shouldAddDocument_whenDocumentWithNameIsNotNull() { + Document document = Document.builder().documentFileName("fileName").build(); + DocumentWithName testDocument = DocumentWithName.builder() + .documentName("testDocument") + .document(document) + .build(); + List> documentWithNameToAdd = wrapElements(testDocument); + List> documentWithNameStart = wrapElements(testDocument); + List> documentWithNameEnd = wrapElements(testDocument, testDocument); + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .caseNoteType(CaseNoteType.DOCUMENT_ONLY) + .documentAndNameToAdd(documentWithNameToAdd) + .documentAndName(documentWithNameStart) .caseNoteTA(null) .build(); + + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + assertThat(response.getData()).extracting("documentAndName") + .isEqualTo(objectMapper.convertValue(documentWithNameEnd, new TypeReference<>() {})); + assertThat(response.getData()).extracting("caseNotesTA").isNull(); + assertThat(response.getData()).extracting("documentAndNote").isNull(); + + } + + @Test + void shouldAddNote_whenDocumentWithNoteIsNotNull() { + Document document = Document.builder().documentFileName("fileName").build(); + DocumentAndNote testDocument = DocumentAndNote.builder() + .documentName("testDocument") + .document(document) + .documentNote("Note") + .build(); + List> documentAndNoteToAdd = wrapElements(testDocument); + List> documentAndNoteStart = wrapElements(testDocument); + List> documentAndNoteEnd = wrapElements(testDocument, testDocument); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() + .caseNoteType(CaseNoteType.DOCUMENT_AND_NOTE) + .documentAndNoteToAdd(documentAndNoteToAdd) + .documentAndNote(documentAndNoteStart) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + assertThat(response.getData()).extracting("documentAndNote") + .isEqualTo(objectMapper.convertValue(documentAndNoteEnd, new TypeReference<>() {})); + assertThat(response.getData()).extracting("caseNotesTA").isNull(); + assertThat(response.getData()).extracting("documentAndName").isNull(); + + } + + @Test + void shouldCopyDocumentAndNoteToAdd_whenDocumentWithNoteIsNull() { + Document document = Document.builder().documentFileName("fileName").build(); + DocumentAndNote testDocument = DocumentAndNote.builder() + .documentName("testDocument") + .document(document) + .documentNote("Note") + .build(); + List> documentAndNoteToAdd = wrapElements(testDocument); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() + .caseNoteType(CaseNoteType.DOCUMENT_AND_NOTE) + .documentAndNoteToAdd(documentAndNoteToAdd) + .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertThat(response.getData()).extracting("documentAndNote") + .isEqualTo(objectMapper.convertValue(documentAndNoteToAdd, new TypeReference<>() {})); assertThat(response.getData()).extracting("caseNotesTA").isNull(); + assertThat(response.getData()).extracting("documentAndName").isNull(); } } @@ -133,7 +228,7 @@ void shouldPopulateConfirmation_DocumentAndNote() { documentList.add(Element.builder().value(documentAndNote).build()); CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() - .documentAndNote(documentList) + .documentAndNoteToAdd(documentList) .caseNoteType(CaseNoteType.DOCUMENT_AND_NOTE) .build(); CallbackParams params = callbackParamsOf(caseData, CallbackType.SUBMITTED); @@ -162,7 +257,7 @@ void submittedCallback_documentOnly() { documentList.add(Element.builder().value(documentAndNote).build()); CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() - .documentAndName(documentList) + .documentAndNameToAdd(documentList) .caseNoteType(CaseNoteType.DOCUMENT_ONLY) .build(); CallbackParams params = callbackParamsOf(caseData, CallbackType.SUBMITTED); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToDefenceSpecCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToDefenceSpecCallbackHandlerTest.java index 22ab7c93da4..15c778c9771 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToDefenceSpecCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToDefenceSpecCallbackHandlerTest.java @@ -68,6 +68,7 @@ import uk.gov.hmcts.reform.civil.service.PaymentDateService; import uk.gov.hmcts.reform.civil.service.Time; import uk.gov.hmcts.reform.civil.service.citizenui.RespondentMediationService; +import uk.gov.hmcts.reform.civil.service.citizenui.ResponseOneVOneShowTagService; import uk.gov.hmcts.reform.civil.service.flowstate.FlowState; import uk.gov.hmcts.reform.civil.utils.CaseFlagsInitialiser; import uk.gov.hmcts.reform.civil.utils.CourtLocationUtils; @@ -128,7 +129,8 @@ LocationHelper.class, LocationRefDataService.class, JudgementService.class, - PaymentDateService.class + PaymentDateService.class, + ResponseOneVOneShowTagService.class }) class RespondToDefenceSpecCallbackHandlerTest extends BaseCallbackHandlerTest { @@ -144,6 +146,9 @@ class RespondToDefenceSpecCallbackHandlerTest extends BaseCallbackHandlerTest { @Autowired private PaymentDateService paymentDateService; + @Autowired + private ResponseOneVOneShowTagService responseOneVOneShowTagService; + @MockBean private UnavailableDateValidator unavailableDateValidator; @@ -1079,6 +1084,7 @@ void shouldChangeCaseStateToJudicialReferral_ONE_V_TWO_ONE_REP() { .addRespondent2(YES) .respondentResponseIsSame(YES) .responseClaimTrack(FAST_CLAIM.name()) + .applicant1ProceedWithClaim(YES) .applicant1DQ(Applicant1DQ.builder().applicant1RespondToClaimExperts( ExpertDetails.builder().build()).build()) .respondent1(Party.builder().type(Party.Type.INDIVIDUAL).build()).build(); @@ -1099,6 +1105,7 @@ void shouldChangeCaseStateToJudicialReferral_ONE_V_TWO_TWO_REP() { .respondent2SameLegalRepresentative(NO) .addRespondent2(YES) .responseClaimTrack(FAST_CLAIM.name()) + .applicant1ProceedWithClaim(YES) .applicant1DQ(Applicant1DQ.builder().applicant1RespondToClaimExperts( ExpertDetails.builder().build()).build()) .respondent1(Party.builder().type(Party.Type.INDIVIDUAL).build()).build(); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/StandardDirectionOrderDJTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/StandardDirectionOrderDJTest.java index 4f94e09294f..3fea6f64824 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/StandardDirectionOrderDJTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/StandardDirectionOrderDJTest.java @@ -5,6 +5,8 @@ import org.junit.jupiter.api.Nested; 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.CsvSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -49,6 +51,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; @@ -57,6 +61,7 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED; import static uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType.ACKNOWLEDGEMENT_OF_CLAIM; import static uk.gov.hmcts.reform.civil.enums.CaseCategory.UNSPEC_CLAIM; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element; @@ -544,6 +549,44 @@ void shouldPrePopulateDJTrialHearingToggle() { var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); assertThat(response.getData()).extracting("trialHearingVariationsDirectionsDJToggle").isNotNull(); + assertThat(response.getData()).extracting("trialHearingVariationsDirectionsDJToggle").isNotNull(); + } + + @Test + void shouldPopulateLocationListsWithPreselectedCourt() { + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimDraft() + .atStateClaimIssuedTrialHearing() + .build(); + + String preSelectedCourt = "214320"; + + CallbackParams params = callbackParamsOf(caseData, MID, PAGE_ID); + List locations = List.of( + LocationRefData.builder().epimmsId("00001").courtLocationCode("00001") + .siteName("court 1").courtAddress("1 address").postcode("Y01 7RB").build(), + LocationRefData.builder().epimmsId(preSelectedCourt).courtLocationCode(preSelectedCourt) + .siteName("court 2").courtAddress("2 address").postcode("Y02 7RB").build(), + LocationRefData.builder().epimmsId("00003").courtLocationCode("00003") + .siteName("court 3").courtAddress("3 address").postcode("Y03 7RB").build() + ); + + when(locationRefDataService.getCourtLocationsForDefaultJudgments(anyString())).thenReturn(locations); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + CaseData responseCaseData = mapper.convertValue(response.getData(), CaseData.class); + DynamicList expected = DynamicList.builder() + .listItems(List.of( + DynamicListElement.builder().code("00001").label("court 1 - 1 address - Y01 7RB").build(), + DynamicListElement.builder().code(preSelectedCourt).label("court 2 - 2 address - Y02 7RB").build(), + DynamicListElement.builder().code("00003").label("court 3 - 3 address - Y03 7RB").build() + ) + ) + .value(DynamicListElement.builder().code(preSelectedCourt).label("court 2 - 2 address - Y02 7RB").build()) + .build(); + + assertThat(responseCaseData.getTrialHearingMethodInPersonDJ()).isEqualTo(expected); + assertThat(responseCaseData.getDisposalHearingMethodInPersonDJ()).isEqualTo(expected); } @Test @@ -693,9 +736,21 @@ void shouldCreateAndSaveSDOOrder_whenStateClaimIssuedDisposalSDOVideoCall() { @Nested class AboutToSubmitCallback { + + @BeforeEach + void setup() { + given(featureToggleService.isEarlyAdoptersEnabled()).willReturn(true); + } + @Test void shouldFinishBusinessProcess() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build(); + List items = List.of("label 1", "label 2", "label 3"); + DynamicList options = DynamicList.fromList(items, Object::toString, Object::toString, items.get(0), false); + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build() + .toBuilder() + .disposalHearingMethodInPersonDJ(options) + .trialHearingMethodInPersonDJ(options) + .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); assertThat(response.getData()).extracting("businessProcess").isNotNull(); @@ -717,9 +772,13 @@ void shouldAssignCategoryId_whenInvoked() { .build(); List> documentList = new ArrayList<>(); documentList.add(element(testDocument)); + List items = List.of("label 1", "label 2", "label 3"); + DynamicList options = DynamicList.fromList(items, Object::toString, items.get(0), false); //Given when(featureToggleService.isCaseFileViewEnabled()).thenReturn(true); CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build().toBuilder() + .trialHearingMethodInPersonDJ(options) + .disposalHearingMethodInPersonDJ(options) .orderSDODocumentDJCollection(documentList) .build(); @@ -730,6 +789,88 @@ void shouldAssignCategoryId_whenInvoked() { //Then assertThat(updatedData.getOrderSDODocumentDJCollection().get(0).getValue().getDocumentLink().getCategoryID()).isEqualTo("sdo"); } + + @ParameterizedTest + @CsvSource({"true", "false"}) + void shouldPopulateEarlyAdoptersFlag_whenDisposalHearingMethodInPersonDJIsSet(Boolean isLocationWhiteListed) { + DynamicList options = DynamicList.builder() + .listItems(List.of( + DynamicListElement.builder().code("00001").label("court 1 - 1 address - Y01 7RB").build(), + DynamicListElement.builder().code("00002").label("court 2 - 2 address - Y02 7RB").build(), + DynamicListElement.builder().code("00003").label("court 3 - 3 address - Y03 7RB").build() + ) + ) + .value(DynamicListElement.builder().code("00002").label("court 2 - 2 address - Y02 7RB").build()) + .build(); + + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build() + .toBuilder() + .disposalHearingMethodInPersonDJ(options) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + when(featureToggleService.isLocationWhiteListedForCaseProgression(eq(options.getValue().getCode()))).thenReturn( + isLocationWhiteListed); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + CaseData responseCaseData = mapper.convertValue(response.getData(), CaseData.class); + + assertThat(responseCaseData.getEaCourtLocation()).isEqualTo(isLocationWhiteListed ? YES : NO); + } + + @Test + void shouldNotPopulateEarlyAdoptersFlag_whenEarlyAdoptersToggleIsOff() { + DynamicList options = DynamicList.builder() + .listItems(List.of( + DynamicListElement.builder().code("00001").label("court 1 - 1 address - Y01 7RB").build(), + DynamicListElement.builder().code("00002").label("court 2 - 2 address - Y02 7RB").build(), + DynamicListElement.builder().code("00003").label("court 3 - 3 address - Y03 7RB").build() + ) + ) + .value(DynamicListElement.builder().code("00002").label("court 2 - 2 address - Y02 7RB").build()) + .build(); + + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build() + .toBuilder() + .disposalHearingMethodInPersonDJ(options) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + when(featureToggleService.isEarlyAdoptersEnabled()).thenReturn(false); + when(featureToggleService.isLocationWhiteListedForCaseProgression(eq(options.getValue().getCode()))) + .thenReturn(true); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + CaseData responseCaseData = mapper.convertValue(response.getData(), CaseData.class); + + assertThat(responseCaseData.getEaCourtLocation()).isNull(); + } + } + + @ParameterizedTest + @CsvSource({"true", "false"}) + void shouldPopulateEarlyAdoptersFlag_whenTrialHearingMethodInPersonDJIsSet(Boolean isLocationWhiteListed) { + DynamicList options = DynamicList.builder() + .listItems(List.of( + DynamicListElement.builder().code("00001").label("court 1 - 1 address - Y01 7RB").build(), + DynamicListElement.builder().code("00002").label("court 2 - 2 address - Y02 7RB").build(), + DynamicListElement.builder().code("00003").label("court 3 - 3 address - Y03 7RB").build() + ) + ) + .value(DynamicListElement.builder().code("00002").label("court 2 - 2 address - Y02 7RB").build()) + .build(); + + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().build() + .toBuilder() + .trialHearingMethodInPersonDJ(options) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + when(featureToggleService.isEarlyAdoptersEnabled()).thenReturn(true); + when(featureToggleService.isLocationWhiteListedForCaseProgression(eq(options.getValue().getCode()))).thenReturn( + isLocationWhiteListed); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + CaseData responseCaseData = mapper.convertValue(response.getData(), CaseData.class); + + assertThat(responseCaseData.getEaCourtLocation()).isEqualTo(isLocationWhiteListed ? YES : NO); } @Nested diff --git a/src/test/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapperTest.java b/src/test/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapperTest.java index bc6d8bfe685..1e4665f1f00 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapperTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapperTest.java @@ -8,6 +8,7 @@ import uk.gov.hmcts.reform.civil.enums.caseprogression.TypeOfDocDocumentaryEvidenceOfTrial; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.Party; +import uk.gov.hmcts.reform.civil.model.ServedDocumentFiles; import uk.gov.hmcts.reform.civil.model.bundle.BundleCreateRequest; import uk.gov.hmcts.reform.civil.model.caseprogression.UploadEvidenceDocumentType; import uk.gov.hmcts.reform.civil.model.caseprogression.UploadEvidenceExpert; @@ -76,20 +77,22 @@ void testBundleRequestMapperWithAllDocs() { bundleCreateRequest.getCaseDetails().getCaseData().getTrialDocuments().get(11).getValue().getDocumentFileName()); assertEquals("Claim Form 10/02/2023", bundleCreateRequest.getCaseDetails().getCaseData().getStatementsOfCaseDocuments().get(0).getValue().getDocumentFileName()); - assertEquals("DF 1 Defence 10/02/2023", + assertEquals("Particulars Of Claim 10/02/2023", bundleCreateRequest.getCaseDetails().getCaseData().getStatementsOfCaseDocuments().get(1).getValue().getDocumentFileName()); - assertEquals("CL's reply 10/02/2023", + assertEquals("DF 1 Defence 10/02/2023", bundleCreateRequest.getCaseDetails().getCaseData().getStatementsOfCaseDocuments().get(2).getValue().getDocumentFileName()); - assertEquals("CL 1 reply to part 18 request 12/01/2023", + assertEquals("CL's reply 10/02/2023", bundleCreateRequest.getCaseDetails().getCaseData().getStatementsOfCaseDocuments().get(3).getValue().getDocumentFileName()); - assertEquals("CL 2 reply to part 18 request 12/01/2023", + assertEquals("CL 1 reply to part 18 request 12/01/2023", bundleCreateRequest.getCaseDetails().getCaseData().getStatementsOfCaseDocuments().get(4).getValue().getDocumentFileName()); - assertEquals("DF 1 reply to part 18 request 12/01/2023", + assertEquals("CL 2 reply to part 18 request 12/01/2023", bundleCreateRequest.getCaseDetails().getCaseData().getStatementsOfCaseDocuments().get(5).getValue().getDocumentFileName()); - assertEquals("DF 2 reply to part 18 request 12/01/2023", + assertEquals("DF 1 reply to part 18 request 12/01/2023", bundleCreateRequest.getCaseDetails().getCaseData().getStatementsOfCaseDocuments().get(6).getValue().getDocumentFileName()); - assertEquals("Directions Questionnaire 10/02/2023", + assertEquals("DF 2 reply to part 18 request 12/01/2023", bundleCreateRequest.getCaseDetails().getCaseData().getStatementsOfCaseDocuments().get(7).getValue().getDocumentFileName()); + assertEquals("Directions Questionnaire 10/02/2023", + bundleCreateRequest.getCaseDetails().getCaseData().getStatementsOfCaseDocuments().get(8).getValue().getDocumentFileName()); assertEquals("Directions Order 10/02/2023", bundleCreateRequest.getCaseDetails().getCaseData().getOrdersDocuments().get(0).getValue().getDocumentFileName()); assertEquals("Order 10/02/2023", @@ -148,6 +151,7 @@ void testBundleRequestMapperWithAllDocs() { bundleCreateRequest.getCaseDetails().getCaseData().getDefendant1CostsBudgets().get(0).getValue().getDocumentFileName()); assertEquals("testFileName 12/12/2023", bundleCreateRequest.getCaseDetails().getCaseData().getDefendant2CostsBudgets().get(0).getValue().getDocumentFileName()); + } private CaseData getCaseData() { @@ -213,9 +217,19 @@ private CaseData getCaseData() { .respondent2(Party.builder().individualLastName("lastname").individualFirstName("df2Fname").partyName( "respondent2").type(Party.Type.INDIVIDUAL).build()) .hearingDate(LocalDate.now()) + .submittedDate(LocalDateTime.of(2023, 2, 10, 2, + 2, 2)) + .servedDocumentFiles(setupParticularsOfClaimDocs()) .build(); } + private ServedDocumentFiles setupParticularsOfClaimDocs() { + List> particularsOfClaim = new ArrayList<>(); + Document document = Document.builder().documentFileName(TEST_FILE_NAME).documentUrl(TEST_URL).build(); + particularsOfClaim.add(ElementUtils.element(document)); + return ServedDocumentFiles.builder().particularsOfClaimDocument(particularsOfClaim).build(); + } + private List> getExpertOtherPartyQuestionDocs(String partyName) { String expertName = ""; String otherParty = ""; diff --git a/src/test/java/uk/gov/hmcts/reform/civil/model/PartyTest.java b/src/test/java/uk/gov/hmcts/reform/civil/model/PartyTest.java index 87ee19e09cc..177d6930853 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/model/PartyTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/model/PartyTest.java @@ -61,4 +61,28 @@ void shouldGetSoulTraderPartyNameExcludingTitle_whenInstantiated() { assertThat(party.getPartyName(true)).isEqualTo("James Carver"); } + @Test + void shouldReturnTrueWhenPartyIsCompany() { + Party party = Party.builder().type(Party.Type.COMPANY) + .build(); + + assertThat(party.isCompanyOROrganisation()).isTrue(); + } + + @Test + void shouldReturnTrueWhenPartyIsOrganisation() { + Party party = Party.builder().type(Party.Type.ORGANISATION) + .build(); + + assertThat(party.isCompanyOROrganisation()).isTrue(); + } + + @Test + void shouldReturnTrueWhenPartyIsNOTOrganisationOrCompany() { + Party party = Party.builder().type(Party.Type.INDIVIDUAL) + .build(); + + assertThat(party.isCompanyOROrganisation()).isFalse(); + } + } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/model/common/DynamicListTest.java b/src/test/java/uk/gov/hmcts/reform/civil/model/common/DynamicListTest.java new file mode 100644 index 00000000000..1aef0b2539b --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/model/common/DynamicListTest.java @@ -0,0 +1,57 @@ +package uk.gov.hmcts.reform.civil.model.common; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import java.util.Arrays; +import java.util.List; +import java.util.function.Function; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +public class DynamicListTest { + + private List listItems; + + @BeforeEach + public void setUp() { + listItems = Arrays.asList("Item1", "Item2", "Item3"); + } + + @Test + public void shouldPopulateDynamicListFromList_whenCodeFunctionIsProvided() { + Function toCode = item -> item + "_code"; + Function toLabel = item -> item + "_label"; + String value = "Item2"; + + DynamicList actual = DynamicList.fromList(listItems, toCode, toLabel, value, true); + + DynamicList expected = DynamicList.builder() + .listItems(List.of( + DynamicListElement.builder().code("Item1_code").label("Item1_label").build(), + DynamicListElement.builder().code("Item2_code").label("Item2_label").build(), + DynamicListElement.builder().code("Item3_code").label("Item3_label").build() + )) + .value(DynamicListElement.builder().code("Item2_code").label("Item2_label").build()) + .build(); + + assertEquals(expected, actual); + } + + @Test + public void shouldPopulateDynamicListFromList_whenCodeFunctionIsNotProvided() { + Function toLabel = item -> item + "_label"; + String value = "Item2"; + + DynamicList actual = DynamicList.fromList(listItems, null, toLabel, value, true); + + assertNotNull(actual.getListItems().get(0).getCode()); + assertEquals("Item1_label", actual.getListItems().get(0).getLabel()); + assertNotNull(actual.getListItems().get(1).getCode()); + assertEquals("Item2_label", actual.getListItems().get(1).getLabel()); + assertNotNull(actual.getListItems().get(2).getCode()); + assertEquals("Item3_label", actual.getListItems().get(2).getLabel()); + assertNotNull(actual.getValue().getCode()); + assertEquals("Item2_label", actual.getValue().getLabel()); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventServiceTest.java index cae90e7ca58..3046d377756 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventServiceTest.java @@ -137,6 +137,8 @@ class FlowStateAllowedEventServiceTest { @Autowired FlowStateAllowedEventService flowStateAllowedEventService; + // used by StateFlowEngine bean + @SuppressWarnings("unused") @MockBean private FeatureToggleService toggleService; diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchServiceTest.java index 0aefcb6a5c2..24a6e6b3716 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyCheckSearchServiceTest.java @@ -26,7 +26,10 @@ protected Query buildQuery(int fromValue) { .should(boolQuery() .must(rangeQuery("data.hearingDate").lt(LocalDate.now().atTime(LocalTime.MIN).plusWeeks(3) .toString())) - .must(boolQuery().must(matchQuery("state", "PREPARE_FOR_HEARING_CONDUCT_HEARING"))) + .must(boolQuery() + .minimumShouldMatch(1) + .should(boolQuery().must(matchQuery("state", "PREPARE_FOR_HEARING_CONDUCT_HEARING"))) + .should(boolQuery().must(matchQuery("state", "HEARING_READINESS")))) .mustNot(matchQuery("data.allocatedTrack", "SMALL_CLAIM")) .mustNot(matchQuery("data.trialReadyChecked", "Yes"))); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchServiceTest.java index 961b2c67253..f94d49c3430 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/search/TrialReadyNotificationSearchServiceTest.java @@ -28,10 +28,13 @@ protected Query buildQuery(int fromValue) { .should(boolQuery() .must(rangeQuery("data.hearingDate").lt(LocalDate.now().atTime(LocalTime.MIN).plusWeeks(6) .toString())) - .must(boolQuery().must(matchQuery("state", "PREPARE_FOR_HEARING_CONDUCT_HEARING")))) + .must(boolQuery() + .minimumShouldMatch(1) + .should(boolQuery().must(matchQuery("state", "PREPARE_FOR_HEARING_CONDUCT_HEARING"))) + .should(boolQuery().must(matchQuery("state", "HEARING_READINESS")))) .mustNot(matchQuery("data.allocatedTrack", "SMALL_CLAIM")) .mustNot(matchQuery("data.listingOrRelisting", ListingOrRelisting.RELISTING)) - .mustNot(matchQuery("data.trialReadyNotified", YesOrNo.YES)); + .mustNot(matchQuery("data.trialReadyNotified", YesOrNo.YES))); return new Query(query, List.of("reference"), fromValue); } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/utils/JudicialReferralUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/civil/utils/JudicialReferralUtilsTest.java new file mode 100644 index 00000000000..72601e30b71 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/utils/JudicialReferralUtilsTest.java @@ -0,0 +1,53 @@ +package uk.gov.hmcts.reform.civil.utils; + +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.reform.civil.enums.CaseCategory; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; +import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.model.ClaimValue; + +import java.math.BigDecimal; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; + +public class JudicialReferralUtilsTest { + + @Test + public void testShouldMoveToJudicialReferralForSpecClaim() { + CaseData caseData = CaseData.builder() + .caseAccessCategory(CaseCategory.SPEC_CLAIM) + .applicant1ProceedWithClaim(YesOrNo.YES) + .build(); + + boolean judicialReferralUtils = JudicialReferralUtils.shouldMoveToJudicialReferral(caseData); + assertTrue(judicialReferralUtils); + } + + @Test + public void testShouldNotMoveToJudicialReferralForSpecClaim() { + CaseData caseData = CaseData.builder() + .caseAccessCategory(CaseCategory.SPEC_CLAIM) + .applicant1ProceedWithClaim(YesOrNo.NO) + .build(); + + boolean judicialReferralUtils = JudicialReferralUtils.shouldMoveToJudicialReferral(caseData); + + assertFalse(judicialReferralUtils); + } + + @Test + public void testShouldMoveToJudicialReferralForUnspecClaim() { + CaseData caseData = CaseData.builder() + .caseAccessCategory(CaseCategory.UNSPEC_CLAIM) + .claimValue(ClaimValue.builder() + .statementOfValueInPennies(BigDecimal.valueOf(10000_00)) + .build()) + .applicant1ProceedWithClaim(YesOrNo.YES) + .build(); + + boolean judicialReferralUtils = JudicialReferralUtils.shouldMoveToJudicialReferral(caseData); + assertTrue(judicialReferralUtils); + } + +}