From 410634fa697e1c0933342a043162acb870a374c3 Mon Sep 17 00:00:00 2001 From: ShwetaTandel-hmcts <130586258+ShwetaTandel-hmcts@users.noreply.github.com> Date: Wed, 24 Jan 2024 17:59:09 +0000 Subject: [PATCH] CIV-11243 SDO-Clear-data (#3868) * Initial Commit * commit Changes --------- Co-authored-by: krishnanuthalapati <32389208+krishnanuthalapati@users.noreply.github.com> Co-authored-by: Azam <106387766+Azam-Hmcts@users.noreply.github.com> --- .../user/CreateSDOCallbackHandler.java | 25 ++++++ .../user/CreateSDOCallbackHandlerTest.java | 85 ++++++++++++++++++- 2 files changed, 109 insertions(+), 1 deletion(-) 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 a0546992832..1d7f6fa3f8b 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 @@ -16,6 +16,8 @@ import uk.gov.hmcts.reform.civil.crd.model.CategorySearchResult; import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument; import uk.gov.hmcts.reform.civil.enums.CaseCategory; +import uk.gov.hmcts.reform.civil.enums.CaseState; +import uk.gov.hmcts.reform.civil.enums.DecisionOnRequestReconsiderationOptions; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.enums.sdo.DateToShowToggle; import uk.gov.hmcts.reform.civil.enums.sdo.DisposalHearingMethod; @@ -30,6 +32,7 @@ import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.Party; +import uk.gov.hmcts.reform.civil.model.SDOHearingNotes; import uk.gov.hmcts.reform.civil.model.common.DynamicList; import uk.gov.hmcts.reform.civil.model.common.DynamicListElement; import uk.gov.hmcts.reform.civil.model.common.Element; @@ -46,10 +49,12 @@ import uk.gov.hmcts.reform.civil.model.sdo.DisposalHearingSchedulesOfLoss; import uk.gov.hmcts.reform.civil.model.sdo.DisposalHearingWitnessOfFact; import uk.gov.hmcts.reform.civil.model.sdo.DisposalOrderWithoutHearing; +import uk.gov.hmcts.reform.civil.model.sdo.FastTrackAllocation; import uk.gov.hmcts.reform.civil.model.sdo.FastTrackBuildingDispute; import uk.gov.hmcts.reform.civil.model.sdo.FastTrackClinicalNegligence; import uk.gov.hmcts.reform.civil.model.sdo.FastTrackCreditHire; import uk.gov.hmcts.reform.civil.model.sdo.FastTrackDisclosureOfDocuments; +import uk.gov.hmcts.reform.civil.model.sdo.FastTrackHearingNotes; import uk.gov.hmcts.reform.civil.model.sdo.FastTrackHearingTime; import uk.gov.hmcts.reform.civil.model.sdo.FastTrackHousingDisrepair; import uk.gov.hmcts.reform.civil.model.sdo.FastTrackJudgementDeductionValue; @@ -661,6 +666,26 @@ private CallbackResponse prePopulateOrderDetailsPages(CallbackParams callbackPar updatedData.smallClaimsRoadTrafficAccident(tempSmallClaimsRoadTrafficAccident).build(); + //This the flowafter request for reconsideration + if (featureToggleService.isSdoR2Enabled() && CaseState.CASE_PROGRESSION.equals(caseData.getCcdState()) + && DecisionOnRequestReconsiderationOptions.CREATE_SDO.equals(caseData.getDecisionOnRequestReconsiderationOptions())) { + updatedData.drawDirectionsOrderRequired(null); + updatedData.drawDirectionsOrderSmallClaims(null); + updatedData.fastClaims(null); + updatedData.smallClaims(null); + updatedData.claimsTrack(null); + updatedData.orderType(null); + updatedData.trialAdditionalDirectionsForFastTrack(null); + updatedData.drawDirectionsOrderSmallClaimsAdditionalDirections(null); + updatedData.fastTrackAllocation(FastTrackAllocation.builder().assignComplexityBand(null).build()); + updatedData.disposalHearingAddNewDirections(null); + updatedData.smallClaimsAddNewDirections(null); + updatedData.fastTrackAddNewDirections(null); + updatedData.sdoHearingNotes(SDOHearingNotes.builder().input("").build()); + updatedData.fastTrackHearingNotes(FastTrackHearingNotes.builder().input("").build()); + updatedData.disposalHearingHearingNotes(null); + } + return AboutToStartOrSubmitCallbackResponse.builder() .data(updatedData.build().toMap(objectMapper)) .build(); 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 04e96d2cece..968c26b317c 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 @@ -25,18 +25,29 @@ import uk.gov.hmcts.reform.civil.crd.model.Category; import uk.gov.hmcts.reform.civil.crd.model.CategorySearchResult; import uk.gov.hmcts.reform.civil.enums.AllocatedTrack; +import uk.gov.hmcts.reform.civil.enums.DecisionOnRequestReconsiderationOptions; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.enums.sdo.ClaimsTrack; import uk.gov.hmcts.reform.civil.enums.sdo.DisposalHearingMethod; +import uk.gov.hmcts.reform.civil.enums.sdo.FastTrack; import uk.gov.hmcts.reform.civil.enums.sdo.FastTrackMethod; +import uk.gov.hmcts.reform.civil.enums.sdo.SmallTrack; import uk.gov.hmcts.reform.civil.enums.sdo.OrderDetailsPagesSectionsToggle; import uk.gov.hmcts.reform.civil.enums.sdo.OrderType; import uk.gov.hmcts.reform.civil.enums.sdo.SmallClaimsMethod; +import uk.gov.hmcts.reform.civil.model.sdo.DisposalHearingAddNewDirections; +import uk.gov.hmcts.reform.civil.model.sdo.FastTrackAddNewDirections; +import uk.gov.hmcts.reform.civil.model.sdo.FastTrackAllocation; +import uk.gov.hmcts.reform.civil.model.sdo.FastTrackHearingNotes; +import uk.gov.hmcts.reform.civil.model.sdo.SmallClaimsAddNewDirections; +import uk.gov.hmcts.reform.civil.model.sdo.JudgementSum; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; import uk.gov.hmcts.reform.civil.helpers.DateFormatHelper; import uk.gov.hmcts.reform.civil.helpers.LocationHelper; +import uk.gov.hmcts.reform.civil.model.SDOHearingNotes; import uk.gov.hmcts.reform.civil.model.common.DynamicListElement; +import uk.gov.hmcts.reform.civil.model.common.Element; import uk.gov.hmcts.reform.civil.service.CategoryService; import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.model.CaseData; @@ -48,7 +59,6 @@ import uk.gov.hmcts.reform.civil.model.dq.Applicant1DQ; import uk.gov.hmcts.reform.civil.model.dq.RequestedCourt; import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData; -import uk.gov.hmcts.reform.civil.model.sdo.JudgementSum; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.sampledata.LocationRefSampleDataBuilder; import uk.gov.hmcts.reform.civil.service.DeadlinesCalculator; @@ -87,6 +97,7 @@ 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.CaseCategory.UNSPEC_CLAIM; +import static uk.gov.hmcts.reform.civil.enums.CaseState.CASE_PROGRESSION; 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; @@ -241,6 +252,78 @@ void shouldGenerateDynamicListsCorrectly() { assertThat(hearingMethodValuesDisposalHearingActual).containsOnly("In Person"); assertThat(hearingMethodValuesSmallClaimsActual).containsOnly("In Person"); } + + @Test + void shouldClearDataIfstateIsCaseProgression() { + + when(featureToggleService.isSdoR2Enabled()).thenReturn(true); + List directions = List.of(FastTrack.fastClaimBuildingDispute); + List smallDirections = List.of(SmallTrack.smallClaimCreditHire); + DisposalHearingAddNewDirections disposalHearingAddNewDirections = DisposalHearingAddNewDirections.builder() + .directionComment("test") + .build(); + Element disposalHearingAddNewDirectionsElement = + Element.builder() + .value(disposalHearingAddNewDirections) + .build(); + SmallClaimsAddNewDirections smallClaimsAddNewDirections = SmallClaimsAddNewDirections.builder() + .directionComment("test") + .build(); + + Element smallClaimsAddNewDirectionsElement = + Element.builder() + .value(smallClaimsAddNewDirections) + .build(); + + FastTrackAddNewDirections fastTrackAddNewDirections = FastTrackAddNewDirections.builder() + .directionComment("test") + .build(); + + Element fastTrackAddNewDirectionsElement = + Element.builder() + .value(fastTrackAddNewDirections) + .build(); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() + .drawDirectionsOrderRequired(YES) + .drawDirectionsOrderSmallClaims(YES) + .fastClaims(directions) + .smallClaims(smallDirections) + .claimsTrack(ClaimsTrack.smallClaimsTrack) + .orderType(OrderType.DECIDE_DAMAGES) + .trialAdditionalDirectionsForFastTrack(directions) + .drawDirectionsOrderSmallClaimsAdditionalDirections(smallDirections) + .fastTrackAllocation(FastTrackAllocation.builder().assignComplexityBand(YES).build()) + .disposalHearingAddNewDirections(List.of(disposalHearingAddNewDirectionsElement)) + .smallClaimsAddNewDirections(List.of(smallClaimsAddNewDirectionsElement)) + .fastTrackAddNewDirections(List.of(fastTrackAddNewDirectionsElement)) + .sdoHearingNotes(SDOHearingNotes.builder().input("TEST").build()) + .fastTrackHearingNotes(FastTrackHearingNotes.builder().input("TEST").build()) + .disposalHearingHearingNotes("TEST") + .ccdState(CASE_PROGRESSION) + .decisionOnRequestReconsiderationOptions(DecisionOnRequestReconsiderationOptions.CREATE_SDO) + .build(); + + CallbackParams params = callbackParamsOf(CallbackVersion.V_1, caseData, ABOUT_TO_START); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + CaseData responseCaseData = objectMapper.convertValue(response.getData(), CaseData.class); + + assertThat(responseCaseData.getDrawDirectionsOrderRequired()).isNull(); + assertThat(responseCaseData.getDrawDirectionsOrderSmallClaims()).isNull(); + assertThat(responseCaseData.getFastClaims()).isNull(); + assertThat(responseCaseData.getSmallClaims()).isNull(); + assertThat(responseCaseData.getClaimsTrack()).isNull(); + assertThat(responseCaseData.getOrderType()).isNull(); + assertThat(responseCaseData.getTrialAdditionalDirectionsForFastTrack()).isNull(); + assertThat(responseCaseData.getDrawDirectionsOrderSmallClaimsAdditionalDirections()).isNull(); + assertThat(responseCaseData.getFastTrackAllocation()).isNull(); + assertThat(responseCaseData.getDisposalHearingAddNewDirections()).isNull(); + assertThat(responseCaseData.getSmallClaimsAddNewDirections()).isNull(); + assertThat(responseCaseData.getFastTrackAddNewDirections()).isNull(); + assertThat(responseCaseData.getSdoHearingNotes()).isNull(); + assertThat(responseCaseData.getFastTrackHearingNotes()).isNull(); + assertThat(responseCaseData.getDisposalHearingHearingNotes()).isNull(); + } } @Nested