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-15956 Add flag for defendant noc online #5923

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -151,7 +151,14 @@ public boolean isJOLiveFeedActive() {
&& featureToggleApi.isFeatureEnabled("isJOLiveFeedActive");
}

public boolean isDefendantNoCOnline() {
return featureToggleApi.isFeatureEnabled("isDefendantNoCOnline");
public boolean isDefendantNoCOnlineForCase(CaseData caseData) {
ZoneId zoneId = ZoneId.systemDefault();
long epoch;
if (caseData.getSubmittedDate() == null) {
epoch = LocalDateTime.now().atZone(zoneId).toEpochSecond();
} else {
epoch = caseData.getSubmittedDate().atZone(zoneId).toEpochSecond();
}
return featureToggleApi.isFeatureEnabledForDate("is-defendant-noc-online-for-case", epoch, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,106 +38,72 @@ public ClaimSubmittedTransitionBuilder(FeatureToggleService featureToggleService

@Override
void setUpTransitions(List<Transition> transitions) {
if (!featureToggleService.isDefendantNoCOnline()) {
this.moveTo(CLAIM_ISSUED_PAYMENT_SUCCESSFUL, transitions).onlyWhen(paymentSuccessful, transitions)
.moveTo(TAKEN_OFFLINE_BY_STAFF, transitions).onlyWhen(takenOfflineByStaffBeforeClaimIssued, transitions)
.moveTo(CLAIM_ISSUED_PAYMENT_FAILED, transitions).onlyWhen(paymentFailed, transitions)
.moveTo(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC, transitions).onlyWhen(
isLipCase,
transitions
)
.set(
(c, flags) -> {
if (featureToggleService.isPinInPostEnabled()) {
flags.put(FlowFlag.PIP_ENABLED.name(), true);
}
if (claimIssueBilingual.test(c)) {
flags.put(FlowFlag.CLAIM_ISSUE_BILINGUAL.name(), true);
}
if (claimIssueHwF.test(c)) {
flags.put(FlowFlag.CLAIM_ISSUE_HWF.name(), true);
}
flags.put(FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true);
flags.put(FlowFlag.LIP_CASE.name(), true);
}, transitions
)
.moveTo(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC, transitions).onlyWhen(
nocSubmittedForLiPApplicant,
transitions
)
.set(
flags -> flags.putAll(
Map.of(
FlowFlag.LIP_CASE.name(), false,
FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true
)), transitions
)
.moveTo(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC, transitions)
.onlyWhen(
isLiPvLRCase.and(not(nocSubmittedForLiPDefendant))
.and(not(nocSubmittedForLiPDefendantBeforeOffline)), transitions
)
.set(
flags -> flags.putAll(
Map.of(
FlowFlag.LIP_CASE.name(), true,
FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), false
)), transitions
)
.moveTo(SPEC_DEFENDANT_NOC, transitions).onlyWhen(nocSubmittedForLiPDefendantBeforeOffline, transitions)
.set(
flags -> flags.putAll(
Map.of(
FlowFlag.LIP_CASE.name(), true,
FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), false
)), transitions
);
} else {
this.moveTo(CLAIM_ISSUED_PAYMENT_SUCCESSFUL, transitions).onlyWhen(paymentSuccessful, transitions)
.moveTo(TAKEN_OFFLINE_BY_STAFF, transitions).onlyWhen(takenOfflineByStaffBeforeClaimIssued, transitions)
.moveTo(CLAIM_ISSUED_PAYMENT_FAILED, transitions).onlyWhen(paymentFailed, transitions)
.moveTo(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC, transitions).onlyWhen(
isLipCase,
transitions
)
.set(
(c, flags) -> {
if (featureToggleService.isPinInPostEnabled()) {
flags.put(FlowFlag.PIP_ENABLED.name(), true);
}
if (claimIssueBilingual.test(c)) {
flags.put(FlowFlag.CLAIM_ISSUE_BILINGUAL.name(), true);
}
if (claimIssueHwF.test(c)) {
flags.put(FlowFlag.CLAIM_ISSUE_HWF.name(), true);
}
flags.put(FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true);
flags.put(FlowFlag.LIP_CASE.name(), true);
}, transitions
)
.moveTo(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC, transitions).onlyWhen(
nocSubmittedForLiPApplicant,
transitions
)
.set(
flags -> flags.putAll(
Map.of(
FlowFlag.LIP_CASE.name(), false,
FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true
)), transitions
)
.moveTo(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC, transitions)
.onlyWhen(
isLiPvLRCase, transitions
)
.set(
flags -> flags.putAll(
Map.of(
FlowFlag.LIP_CASE.name(), true,
FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), false
)), transitions
);
}
this.moveTo(CLAIM_ISSUED_PAYMENT_SUCCESSFUL, transitions).onlyWhen(paymentSuccessful, transitions)
.moveTo(TAKEN_OFFLINE_BY_STAFF, transitions).onlyWhen(takenOfflineByStaffBeforeClaimIssued, transitions)
.moveTo(CLAIM_ISSUED_PAYMENT_FAILED, transitions).onlyWhen(paymentFailed, transitions)
.moveTo(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC, transitions).onlyWhen(
isLipCase,
transitions
)
.set(
(c, flags) -> {
if (featureToggleService.isPinInPostEnabled()) {
flags.put(FlowFlag.PIP_ENABLED.name(), true);
}
if (claimIssueBilingual.test(c)) {
flags.put(FlowFlag.CLAIM_ISSUE_BILINGUAL.name(), true);
}
if (claimIssueHwF.test(c)) {
flags.put(FlowFlag.CLAIM_ISSUE_HWF.name(), true);
}
flags.put(FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true);
flags.put(FlowFlag.LIP_CASE.name(), true);
}, transitions
)
.moveTo(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC, transitions).onlyWhen(
nocSubmittedForLiPApplicant,
transitions
)
.set(
flags -> flags.putAll(
Map.of(
FlowFlag.LIP_CASE.name(), false,
FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true
)), transitions
)
.moveTo(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC, transitions)
.onlyWhen(
not(isDefendantNoCOnlineForCase).and(isLiPvLRCase.and(not(nocSubmittedForLiPDefendant))
.and(not(nocSubmittedForLiPDefendantBeforeOffline))),
transitions
)
.set(
flags -> flags.putAll(
Map.of(
FlowFlag.LIP_CASE.name(), true,
FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), false
)), transitions
)
.moveTo(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC, transitions)
.onlyWhen(
isDefendantNoCOnlineForCase.and(isLiPvLRCase), transitions
)
.set(
flags -> flags.putAll(
Map.of(
FlowFlag.LIP_CASE.name(), true,
FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), false
)), transitions
)
.moveTo(SPEC_DEFENDANT_NOC, transitions).onlyWhen(not(isDefendantNoCOnlineForCase).and(
nocSubmittedForLiPDefendantBeforeOffline), transitions)
.set(
flags -> flags.putAll(
Map.of(
FlowFlag.LIP_CASE.name(), true,
FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), false
)), transitions
);
}

public static final Predicate<CaseData> paymentFailed = caseData ->
Expand All @@ -163,4 +129,6 @@ public static boolean getPredicateTakenOfflineByStaffBeforeClaimIssue(CaseData c
public static final Predicate<CaseData> nocSubmittedForLiPApplicant = CaseData::nocApplyForLiPClaimant;

public static final Predicate<CaseData> isLiPvLRCase = CaseData::isLipvLROneVOne;

public final Predicate<CaseData> isDefendantNoCOnlineForCase = featureToggleService::isDefendantNoCOnlineForCase;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void setUpTransitions(List<Transition> transitions) {
BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled(),
JO_ONLINE_LIVE_ENABLED.name(), featureToggleService.isJudgmentOnlineLive(),
IS_JO_LIVE_FEED_ACTIVE.name(), featureToggleService.isJOLiveFeedActive(),
DEFENDANT_NOC_ONLINE.name(), featureToggleService.isDefendantNoCOnline()
DEFENDANT_NOC_ONLINE.name(), featureToggleService.isDefendantNoCOnlineForCase(c)
)), transitions)
.moveTo(CLAIM_SUBMITTED, transitions)
.onlyWhen(claimSubmittedTwoRegisteredRespondentRepresentatives
Expand All @@ -61,7 +61,7 @@ void setUpTransitions(List<Transition> transitions) {
BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled(),
JO_ONLINE_LIVE_ENABLED.name(), featureToggleService.isJudgmentOnlineLive(),
IS_JO_LIVE_FEED_ACTIVE.name(), featureToggleService.isJOLiveFeedActive(),
DEFENDANT_NOC_ONLINE.name(), featureToggleService.isDefendantNoCOnline()
DEFENDANT_NOC_ONLINE.name(), featureToggleService.isDefendantNoCOnlineForCase(c)
)), transitions)
// Only one unrepresented defendant
.moveTo(CLAIM_SUBMITTED, transitions)
Expand All @@ -75,7 +75,7 @@ void setUpTransitions(List<Transition> transitions) {
BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled(),
JO_ONLINE_LIVE_ENABLED.name(), featureToggleService.isJudgmentOnlineLive(),
IS_JO_LIVE_FEED_ACTIVE.name(), featureToggleService.isJOLiveFeedActive(),
DEFENDANT_NOC_ONLINE.name(), featureToggleService.isDefendantNoCOnline()
DEFENDANT_NOC_ONLINE.name(), featureToggleService.isDefendantNoCOnlineForCase(c)
)), transitions)
// Unrepresented defendant 1
.moveTo(CLAIM_SUBMITTED, transitions)
Expand All @@ -92,7 +92,7 @@ void setUpTransitions(List<Transition> transitions) {
BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled(),
JO_ONLINE_LIVE_ENABLED.name(), featureToggleService.isJudgmentOnlineLive(),
IS_JO_LIVE_FEED_ACTIVE.name(), featureToggleService.isJOLiveFeedActive(),
DEFENDANT_NOC_ONLINE.name(), featureToggleService.isDefendantNoCOnline()
DEFENDANT_NOC_ONLINE.name(), featureToggleService.isDefendantNoCOnlineForCase(c)
)), transitions)
// Unrepresented defendant 2
.moveTo(CLAIM_SUBMITTED, transitions)
Expand All @@ -108,7 +108,7 @@ void setUpTransitions(List<Transition> transitions) {
BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled(),
JO_ONLINE_LIVE_ENABLED.name(), featureToggleService.isJudgmentOnlineLive(),
IS_JO_LIVE_FEED_ACTIVE.name(), featureToggleService.isJOLiveFeedActive(),
DEFENDANT_NOC_ONLINE.name(), featureToggleService.isDefendantNoCOnline()
DEFENDANT_NOC_ONLINE.name(), featureToggleService.isDefendantNoCOnlineForCase(c)
)), transitions)
// Unrepresented defendants
.moveTo(CLAIM_SUBMITTED, transitions)
Expand All @@ -124,7 +124,7 @@ void setUpTransitions(List<Transition> transitions) {
BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled(),
JO_ONLINE_LIVE_ENABLED.name(), featureToggleService.isJudgmentOnlineLive(),
IS_JO_LIVE_FEED_ACTIVE.name(), featureToggleService.isJOLiveFeedActive(),
DEFENDANT_NOC_ONLINE.name(), featureToggleService.isDefendantNoCOnline()
DEFENDANT_NOC_ONLINE.name(), featureToggleService.isDefendantNoCOnlineForCase(c)
)), transitions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.civil.service.flowstate.FlowState;
import uk.gov.hmcts.reform.civil.stateflow.model.Transition;

import java.util.List;
import java.util.function.Predicate;

import static java.util.function.Predicate.not;
import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.nocSubmittedForLiPDefendant;
import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_SPEC_DEFENDANT_NOC;

Expand All @@ -22,12 +25,11 @@ public SpecDefendantNocTransitionBuilder(FeatureToggleService featureToggleServi

@Override
void setUpTransitions(List<Transition> transitions) {
if (!featureToggleService.isDefendantNoCOnline()) {
this.moveTo(TAKEN_OFFLINE_SPEC_DEFENDANT_NOC, transitions).onlyWhen(
nocSubmittedForLiPDefendant,
transitions
);
}
this.moveTo(TAKEN_OFFLINE_SPEC_DEFENDANT_NOC, transitions).onlyWhen(
not(isDefendantNoCOnlineForCase).and(nocSubmittedForLiPDefendant),
transitions
);
}

public final Predicate<CaseData> isDefendantNoCOnlineForCase = featureToggleService::isDefendantNoCOnlineForCase;
}
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,16 @@ void shouldReturnCorrectValue_whenisJOLiveFeedActive(Boolean toggleStat) {

@ParameterizedTest
@ValueSource(booleans = {true, false})
void shouldReturnCorrectValue_whenIsDefendantNoCOnline(Boolean toggleStat) {
var isDefendantNoCOnline = "isDefendantNoCOnline";
givenToggle(isDefendantNoCOnline, toggleStat);
void shouldReturnCorrectValue_whenIsDefendantNoCOnlineForCase(Boolean toggleStat) {
var nocOnlineKey = "is-defendant-noc-online-for-case";

assertThat(featureToggleService.isDefendantNoCOnline()).isEqualTo(toggleStat);
CaseData caseData = CaseDataBuilder.builder().atStateClaimIssued()
.setClaimTypeToSpecClaim()
.build();

when(featureToggleApi.isFeatureEnabledForDate(eq(nocOnlineKey), anyLong(), eq(false)))
.thenReturn(toggleStat);

assertThat(featureToggleService.isDefendantNoCOnlineForCase(caseData)).isEqualTo(toggleStat);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static uk.gov.hmcts.reform.civil.enums.CaseCategory.SPEC_CLAIM;
import static uk.gov.hmcts.reform.civil.enums.FeeType.CLAIMISSUED;
Expand Down Expand Up @@ -5198,7 +5199,7 @@ void shouldReturnProceedsInHeritageSystemState_whenFullAdmitRepaymentAcceptedWit
}

@Nested
class TakenOfflineByDefendantNoc {
class DefendantNoc {

@Test
void beforeTakenOffline_whenNOCSubmittedForLipDefendant() {
Expand Down Expand Up @@ -5228,6 +5229,7 @@ void beforeTakenOffline_whenNOCSubmittedForLipDefendant() {
.caseAccessCategory(SPEC_CLAIM).build();

// When
when(featureToggleService.isDefendantNoCOnlineForCase(any())).thenReturn(false);
StateFlow stateFlow = stateFlowEngine.evaluate(caseData);

// Then
Expand Down Expand Up @@ -5271,6 +5273,7 @@ void shouldTakenOffline_whenNOCSubmittedForLipDefendant() {
.caseAccessCategory(SPEC_CLAIM).build();

// When
when(featureToggleService.isDefendantNoCOnlineForCase(any())).thenReturn(false);
StateFlow stateFlow = stateFlowEngine.evaluate(caseData);

// Then
Expand All @@ -5280,6 +5283,44 @@ void shouldTakenOffline_whenNOCSubmittedForLipDefendant() {
.isEqualTo(TAKEN_OFFLINE_SPEC_DEFENDANT_NOC.fullName());
}

@Test
void shouldRemainOnline_whenNOCSubmittedForLipDefendant() {
// Given
CaseData caseData = CaseDataBuilder.builder()
.atStateClaimIssued1v1UnrepresentedDefendantSpec()
.applicant1Represented(NO)
.respondent1Represented(YES)
.build().toBuilder()
.respondent1PinToPostLRspec(DefendantPinToPostLRspec.builder().accessCode("Temp").build())
.paymentSuccessfulDate(null)
.claimIssuedPaymentDetails(null)
.changeOfRepresentation(ChangeOfRepresentation.builder().caseRole("RESPONDENTSOLICITORONE")
.timestamp(LocalDateTime.now())
.organisationToAddID("HA160")
.build())
.caseDataLiP(CaseDataLiP.builder()
.helpWithFees(HelpWithFees.builder()
.helpWithFeesReferenceNumber("Test")
.build())
.build())
.feePaymentOutcomeDetails(FeePaymentOutcomeDetails.builder()
.hwfFullRemissionGrantedForClaimIssue(YES)
.build())
.ccdState(CaseState.AWAITING_RESPONDENT_ACKNOWLEDGEMENT)
.claimNotificationDeadline(LocalDateTime.now().plusDays(2))
.caseAccessCategory(SPEC_CLAIM).build();

// When
when(featureToggleService.isDefendantNoCOnlineForCase(any())).thenReturn(true);
StateFlow stateFlow = stateFlowEngine.evaluate(caseData);

// Then
assertThat(stateFlow.getState())
.extracting(State::getName)
.isNotNull()
.isEqualTo(CLAIM_ISSUED.fullName());
}

@Test
void claimIssued_whenNotNOCSubmittedForLipDefendant() {
// Given
Expand Down
Loading
Loading