Skip to content

Commit

Permalink
CIV-10518 fix status change (#3212)
Browse files Browse the repository at this point in the history
  • Loading branch information
MMNycz authored Sep 11, 2023
1 parent 24e31f4 commit 02a7401
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@
import uk.gov.hmcts.reform.civil.callback.CallbackHandler;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
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.MultiPartyScenario;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.helpers.LocationHelper;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.civil.model.BusinessProcess;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.ResponseDocument;
import uk.gov.hmcts.reform.civil.model.StatementOfTruth;
import uk.gov.hmcts.reform.civil.model.common.Element;
import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument;
import uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType;
import uk.gov.hmcts.reform.civil.model.dq.Applicant1DQ;
import uk.gov.hmcts.reform.civil.model.dq.Applicant2DQ;
import uk.gov.hmcts.reform.civil.model.dq.Hearing;
import uk.gov.hmcts.reform.civil.model.dq.RequestedCourt;
import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService;
import uk.gov.hmcts.reform.civil.service.ExitSurveyContentService;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.civil.service.Time;
import uk.gov.hmcts.reform.civil.utils.LocationRefDataUtil;
import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService;
import uk.gov.hmcts.reform.civil.utils.AssignCategoryId;
import uk.gov.hmcts.reform.civil.utils.CaseFlagsInitialiser;
import uk.gov.hmcts.reform.civil.utils.LocationRefDataUtil;
import uk.gov.hmcts.reform.civil.utils.UnavailabilityDatesUtils;
import uk.gov.hmcts.reform.civil.validation.UnavailableDateValidator;
import uk.gov.hmcts.reform.civil.validation.interfaces.ExpertsValidator;
Expand All @@ -54,7 +54,6 @@
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_ONE;
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 @@ -276,12 +275,24 @@ private CallbackResponse aboutToSubmit(CallbackParams callbackParams) {
* @return true if and only if the case should move to judicial referral
*/
public static boolean shouldMoveToJudicialReferral(CaseData caseData) {
if (CaseCategory.SPEC_CLAIM.equals(caseData.getCaseAccessCategory())) {
return caseData.getApplicant1ProceedWithClaim() == YesOrNo.YES;
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(caseData.getCaseAccessCategory())
CaseCategory.UNSPEC_CLAIM.equals(caseCategory)
? caseData.getClaimValue().toPounds()
: caseData.getTotalClaimAmount(),
caseData.getClaimType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,89 @@ void shouldChangeCaseState_WhenApplicant1NotAcceptPartAdmitAmountWithFastTrackAn
assertThat(response.getState())
.isEqualTo(CaseState.JUDICIAL_REFERRAL.name());
}

@Test
void shouldChangeCaseStateToJudicialReferral_ONE_V_ONE() {
CaseData caseData = CaseData.builder()
.caseAccessCategory(CaseCategory.SPEC_CLAIM)
.respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE)
.applicant1ProceedWithClaim(YES)
.responseClaimTrack(FAST_CLAIM.name())
.applicant1DQ(Applicant1DQ.builder().applicant1RespondToClaimExperts(
ExpertDetails.builder().build()).build())
.respondent1(Party.builder().type(Party.Type.INDIVIDUAL).build()).build();
CallbackParams params = callbackParamsOf(V_2, caseData, ABOUT_TO_SUBMIT);
AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler
.handle(params);
assertThat(response.getState())
.isEqualTo(CaseState.JUDICIAL_REFERRAL.name());
}

@Test
void shouldChangeCaseStateToJudicialReferral_TWO_V_ONE() {
CaseData caseData = CaseData.builder()
.caseAccessCategory(CaseCategory.SPEC_CLAIM)
.respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE)
.applicant2(Party.builder()
.individualTitle("Mr")
.individualFirstName("Test")
.individualLastName("Test")
.individualDateOfBirth(LocalDate.now().minusYears(18))
.type(Party.Type.INDIVIDUAL)
.build())
.addApplicant2(YES)
.applicant1ProceedWithClaimSpec2v1(YES)
.responseClaimTrack(FAST_CLAIM.name())
.applicant1DQ(Applicant1DQ.builder().applicant1RespondToClaimExperts(
ExpertDetails.builder().build()).build())
.respondent1(Party.builder().type(Party.Type.INDIVIDUAL).build()).build();
CallbackParams params = callbackParamsOf(V_2, caseData, ABOUT_TO_SUBMIT);
AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler
.handle(params);
assertThat(response.getState())
.isEqualTo(CaseState.JUDICIAL_REFERRAL.name());
}

@Test
void shouldChangeCaseStateToJudicialReferral_ONE_V_TWO_ONE_REP() {
CaseData caseData = CaseData.builder()
.caseAccessCategory(CaseCategory.SPEC_CLAIM)
.respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE)
.respondent2ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE)
.respondent2(PartyBuilder.builder().company().build())
.respondent2SameLegalRepresentative(YES)
.addRespondent2(YES)
.respondentResponseIsSame(YES)
.responseClaimTrack(FAST_CLAIM.name())
.applicant1DQ(Applicant1DQ.builder().applicant1RespondToClaimExperts(
ExpertDetails.builder().build()).build())
.respondent1(Party.builder().type(Party.Type.INDIVIDUAL).build()).build();
CallbackParams params = callbackParamsOf(V_2, caseData, ABOUT_TO_SUBMIT);
AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler
.handle(params);
assertThat(response.getState())
.isEqualTo(CaseState.JUDICIAL_REFERRAL.name());
}

@Test
void shouldChangeCaseStateToJudicialReferral_ONE_V_TWO_TWO_REP() {
CaseData caseData = CaseData.builder()
.caseAccessCategory(CaseCategory.SPEC_CLAIM)
.respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE)
.respondent2ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE)
.respondent2(PartyBuilder.builder().company().build())
.respondent2SameLegalRepresentative(NO)
.addRespondent2(YES)
.responseClaimTrack(FAST_CLAIM.name())
.applicant1DQ(Applicant1DQ.builder().applicant1RespondToClaimExperts(
ExpertDetails.builder().build()).build())
.respondent1(Party.builder().type(Party.Type.INDIVIDUAL).build()).build();
CallbackParams params = callbackParamsOf(V_2, caseData, ABOUT_TO_SUBMIT);
AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler
.handle(params);
assertThat(response.getState())
.isEqualTo(CaseState.JUDICIAL_REFERRAL.name());
}
}

@Nested
Expand Down

0 comments on commit 02a7401

Please sign in to comment.