diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/citizen/UpdateCaseManagementDetailsService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/citizen/UpdateCaseManagementDetailsService.java index b37adcba484..fd8c23bbb72 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/citizen/UpdateCaseManagementDetailsService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/citizen/UpdateCaseManagementDetailsService.java @@ -76,6 +76,9 @@ private void updateRespondent1RequestedCourtDetails(CaseData caseData, CaseData. } private RequestedCourt correctCaseLocation(RequestedCourt requestedCourt, List locations) { + if (requestedCourt.getCaseLocation() == null || requestedCourt.getCaseLocation().getBaseLocation() == null) { + return requestedCourt; + } String locationLabel = requestedCourt.getCaseLocation().getBaseLocation(); LocationRefData preferredLocation = locations.stream() .filter(locationRefData -> courtLocationUtils.checkLocation(locationRefData, locationLabel)) 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 f1b054d05e7..a02a6bc4cea 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 @@ -258,6 +258,82 @@ void shouldUpdateCaseStateToJudicialReferral_WhenFullDefence() { assertEquals(CaseState.JUDICIAL_REFERRAL.name(), response.getState()); } + @Test + void shouldOnlyUpdateClaimStatus_whenPartAdmitNotSettled_NoMediation_NoBaseCourt() { + Applicant1DQ applicant1DQ = + Applicant1DQ.builder().applicant1DQRequestedCourt(RequestedCourt.builder() + .caseLocation(CaseLocationCivil.builder() + .build()) + .build()).build(); + Respondent1DQ respondent1DQ = + Respondent1DQ.builder().respondent1DQRequestedCourt(RequestedCourt.builder() + .caseLocation(CaseLocationCivil.builder() + .build()) + .build()).build(); + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimIssued() + .applicant1PartAdmitConfirmAmountPaidSpec(NO) + .applicant1PartAdmitIntentionToSettleClaimSpec(NO) + .applicant1DQ(applicant1DQ) + .respondent1DQ(respondent1DQ) + .applicant1AcceptAdmitAmountPaidSpec(NO) + .caseDataLip(CaseDataLiP.builder().applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder().hasAgreedFreeMediation( + MediationDecision.No).build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + assertThat(response.getData()) + .extracting("businessProcess") + .extracting("camundaEvent") + .isEqualTo(CLAIMANT_RESPONSE_CUI.name()); + assertThat(response.getData()) + .extracting("businessProcess") + .extracting("status") + .isEqualTo("READY"); + + CaseData data = mapper.convertValue(response.getData(), CaseData.class); + assertThat(data.getApplicant1DQ().getApplicant1DQRequestedCourt().getResponseCourtCode()).isNull(); + } + + @Test + void shouldOnlyUpdateClaimStatus_whenPartAdmitNotSettled_NoMediation_NoCourtSelected() { + Applicant1DQ applicant1DQ = + Applicant1DQ.builder().applicant1DQRequestedCourt(RequestedCourt.builder() + .build()).build(); + Respondent1DQ respondent1DQ = + Respondent1DQ.builder().respondent1DQRequestedCourt(RequestedCourt.builder() + .build()).build(); + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimIssued() + .applicant1PartAdmitConfirmAmountPaidSpec(NO) + .applicant1PartAdmitIntentionToSettleClaimSpec(NO) + .applicant1DQ(applicant1DQ) + .respondent1DQ(respondent1DQ) + .applicant1AcceptAdmitAmountPaidSpec(NO) + .caseDataLip(CaseDataLiP.builder().applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder().hasAgreedFreeMediation( + MediationDecision.No).build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + assertThat(response.getData()) + .extracting("businessProcess") + .extracting("camundaEvent") + .isEqualTo(CLAIMANT_RESPONSE_CUI.name()); + assertThat(response.getData()) + .extracting("businessProcess") + .extracting("status") + .isEqualTo("READY"); + + CaseData data = mapper.convertValue(response.getData(), CaseData.class); + assertThat(data.getApplicant1DQ().getApplicant1DQRequestedCourt().getResponseCourtCode()).isNull(); + } + @Test void shouldChangeCaseState_whenApplicantRejectClaimSettlementAndAgreeToMediation() { CaseData caseData = CaseDataBuilder.builder()