Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIV-15869 leave state make and order #5922

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

import static io.jsonwebtoken.lang.Collections.isEmpty;
import static java.lang.String.format;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
import static uk.gov.hmcts.reform.civil.callback.CallbackParams.Params.BEARER_TOKEN;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START;
Expand All @@ -83,6 +84,7 @@
import static uk.gov.hmcts.reform.civil.enums.caseprogression.FinalOrderDownloadTemplateOptions.FIX_DATE_CCMC;
import static uk.gov.hmcts.reform.civil.enums.caseprogression.FinalOrderDownloadTemplateOptions.FIX_DATE_CMC;
import static uk.gov.hmcts.reform.civil.enums.caseprogression.FinalOrderSelection.ASSISTED_ORDER;
import static uk.gov.hmcts.reform.civil.enums.caseprogression.FinalOrderSelection.FREE_FORM_ORDER;
import static uk.gov.hmcts.reform.civil.enums.finalorders.CostEnums.CLAIMANT;
import static uk.gov.hmcts.reform.civil.enums.finalorders.CostEnums.STANDARD_BASIS;
import static uk.gov.hmcts.reform.civil.enums.finalorders.CostEnums.SUBJECT_DETAILED_ASSESSMENT;
Expand Down Expand Up @@ -607,11 +609,6 @@ private CallbackResponse addGeneratedDocumentToCollection(CallbackParams callbac

caseDataBuilder.businessProcess(BusinessProcess.ready(GENERATE_ORDER_NOTIFICATION));

CaseState state = All_FINAL_ORDERS_ISSUED;
if (caseData.getFinalOrderFurtherHearingToggle() != null || isJudicialReferral(callbackParams)) {
state = CASE_PROGRESSION;
}

if (nonNull(caseData.getFinalOrderSelection())) {
// populate hearing notes in listing tab with hearing notes from either assisted or freeform order, if either exist.
if (caseData.getFinalOrderSelection().equals(ASSISTED_ORDER)) {
Expand All @@ -636,8 +633,22 @@ private CallbackResponse addGeneratedDocumentToCollection(CallbackParams callbac
caseDataBuilder
));
}

nullPreviousSelections(caseDataBuilder);

if (featureToggleService.isCaseEventsEnabled()
&& ((ASSISTED_ORDER.equals(caseData.getFinalOrderSelection())
&& isNull(caseData.getFinalOrderFurtherHearingToggle()))
|| FREE_FORM_ORDER.equals(caseData.getFinalOrderSelection()))) {

return AboutToStartOrSubmitCallbackResponse.builder()
.data(caseDataBuilder.build().toMap(objectMapper))
.build();
}
CaseState state = All_FINAL_ORDERS_ISSUED;
if (caseData.getFinalOrderFurtherHearingToggle() != null || isJudicialReferral(callbackParams)) {
state = CASE_PROGRESSION;
}

return AboutToStartOrSubmitCallbackResponse.builder()
.data(caseDataBuilder.build().toMap(objectMapper))
.state(state.name())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
import static uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType.JUDGE_FINAL_ORDER;
import static uk.gov.hmcts.reform.civil.enums.CaseState.CASE_PROGRESSION;
import static uk.gov.hmcts.reform.civil.enums.CaseState.JUDICIAL_REFERRAL;
import static uk.gov.hmcts.reform.civil.enums.CaseState.PREPARE_FOR_HEARING_CONDUCT_HEARING;
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.enums.caseprogression.FinalOrderDownloadTemplateOptions.BLANK_TEMPLATE_AFTER_HEARING;
Expand Down Expand Up @@ -1919,6 +1920,54 @@ void shouldNotCallUpdateWaCourtLocationsServiceWhenNotPresent_AndMintiEnabled()

verifyNoInteractions(updateWaCourtLocationsService);
}

@Test
void shouldNotChangeState_onAboutToSubmitAndAssistedOrderWithNoFurtherHearingWithCaseEventsEnabled() {
when(theUserService.getUserDetails(anyString())).thenReturn(UserDetails.builder()
.forename("Judge")
.surname("Judy")
.roles(Collections.emptyList()).build());
when(featureToggleService.isCaseEventsEnabled()).thenReturn(true);
// Given
List<Element<CaseDocument>> finalCaseDocuments = new ArrayList<>();
finalCaseDocuments.add(element(finalOrder));
CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder()
.finalOrderSelection(FinalOrderSelection.ASSISTED_ORDER)
.finalOrderFurtherHearingToggle(null)
.finalOrderDocumentCollection(finalCaseDocuments)
.finalOrderDocument(finalOrder)
.ccdState(PREPARE_FOR_HEARING_CONDUCT_HEARING)
.build();
CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT);
// When
var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params);
// Then
assertThat(response.getState()).isEqualTo(null);
}

@Test
void shouldNotChangeState_onAboutToSubmitAndAssistedOrderWithNoFurtherHearingWithCaseEventsEnabledFreeForm() {
when(theUserService.getUserDetails(anyString())).thenReturn(UserDetails.builder()
.forename("Judge")
.surname("Judy")
.roles(Collections.emptyList()).build());
when(featureToggleService.isCaseEventsEnabled()).thenReturn(true);
// Given
List<Element<CaseDocument>> finalCaseDocuments = new ArrayList<>();
finalCaseDocuments.add(element(finalOrder));
CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder()
.finalOrderSelection(FinalOrderSelection.FREE_FORM_ORDER)
.finalOrderFurtherHearingToggle(null)
.finalOrderDocumentCollection(finalCaseDocuments)
.finalOrderDocument(finalOrder)
.ccdState(PREPARE_FOR_HEARING_CONDUCT_HEARING)
.build();
CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT);
// When
var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params);
// Then
assertThat(response.getState()).isEqualTo(null);
}
}

@Nested
Expand Down
Loading