From a64879308855469e5de508c743edc0e899b088d8 Mon Sep 17 00:00:00 2001 From: kenneth-hmcts Date: Tue, 14 Nov 2023 13:30:39 +0000 Subject: [PATCH 1/2] CIV-11571: Add null checking --- .../service/citizen/UpdateCaseManagementDetailsService.java | 3 +++ 1 file changed, 3 insertions(+) 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)) From 6163201fe7a37e923dab7551555ccacec271863b Mon Sep 17 00:00:00 2001 From: kenneth-hmcts Date: Wed, 15 Nov 2023 11:17:07 +0000 Subject: [PATCH 2/2] CIV-11571: Add unit test --- ...laimantResponseCuiCallbackHandlerTest.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) 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 8c889304389..aaf75fd5034 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 @@ -176,6 +176,82 @@ void shouldOnlyUpdateClaimStatus_whenPartAdmitNotSettled_NoMediation() { assertThat(data.getCaseNameHmctsInternal()).isEqualTo(data.getApplicant1().getPartyName() + " v " + data.getRespondent1().getPartyName()); } + @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()