Skip to content

Commit

Permalink
CIV-11243 SDO-Clear-data (#3868)
Browse files Browse the repository at this point in the history
* Initial Commit

* commit Changes

---------

Co-authored-by: krishnanuthalapati <[email protected]>
Co-authored-by: Azam <[email protected]>
  • Loading branch information
3 people authored Jan 24, 2024
1 parent 33cac21 commit 410634f
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<FastTrack> directions = List.of(FastTrack.fastClaimBuildingDispute);
List<SmallTrack> smallDirections = List.of(SmallTrack.smallClaimCreditHire);
DisposalHearingAddNewDirections disposalHearingAddNewDirections = DisposalHearingAddNewDirections.builder()
.directionComment("test")
.build();
Element<DisposalHearingAddNewDirections> disposalHearingAddNewDirectionsElement =
Element.<DisposalHearingAddNewDirections>builder()
.value(disposalHearingAddNewDirections)
.build();
SmallClaimsAddNewDirections smallClaimsAddNewDirections = SmallClaimsAddNewDirections.builder()
.directionComment("test")
.build();

Element<SmallClaimsAddNewDirections> smallClaimsAddNewDirectionsElement =
Element.<SmallClaimsAddNewDirections>builder()
.value(smallClaimsAddNewDirections)
.build();

FastTrackAddNewDirections fastTrackAddNewDirections = FastTrackAddNewDirections.builder()
.directionComment("test")
.build();

Element<FastTrackAddNewDirections> fastTrackAddNewDirectionsElement =
Element.<FastTrackAddNewDirections>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
Expand Down

0 comments on commit 410634f

Please sign in to comment.