Skip to content

Commit

Permalink
CIV-10986 case not proceeding to judicial referral (#3411)
Browse files Browse the repository at this point in the history
* CIV-10986 fix one_v_two_two_rep validation

* Update suppressions.xml

* Remove updated supressions

* CIV-10986 update spec shouldMoveToJudicialReferral

* refactor shouldMoveToJudicialReferral method

---------

Co-authored-by: mfallonhmcts <[email protected]>
  • Loading branch information
MMNycz and mfallonhmcts authored Nov 6, 2023
1 parent f5a23fd commit 61943ed
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
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;
Expand Down Expand Up @@ -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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1084,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();
Expand All @@ -1104,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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}

}

0 comments on commit 61943ed

Please sign in to comment.