diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/InitiateGeneralApplicationHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/InitiateGeneralApplicationHandler.java index 1c0f300b299..52ef3d6b4a4 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/InitiateGeneralApplicationHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/InitiateGeneralApplicationHandler.java @@ -128,6 +128,9 @@ private CallbackResponse aboutToStartValidationAndSetup(CallbackParams callbackP if (initiateGeneralApplicationService.caseContainsLiP(caseData)) { if (!featureToggleService.isGaForLipsEnabled()) { errors.add(LR_VS_LIP); + } else if (!(featureToggleService.isGaForLipsEnabledAndLocationWhiteListed(caseData + .getCaseManagementLocation().getBaseLocation()))) { + errors.add(NOT_IN_EA_REGION); } else { /* * General Application can only be initiated if Defendant is assigned to the case diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/FeatureToggleService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/FeatureToggleService.java index 6e7b8750e51..4e1517f3589 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/FeatureToggleService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/FeatureToggleService.java @@ -141,6 +141,12 @@ public boolean isCaseProgressionEnabledAndLocationWhiteListed(String location) { && isCaseProgressionEnabled(); } + public boolean isGaForLipsEnabledAndLocationWhiteListed(String location) { + return location != null + && featureToggleApi.isFeatureEnabledForLocation("ea-courts-whitelisted-for-ga-lips", location, false) + && isGaForLipsEnabled(); + } + public boolean isHmcNroEnabled() { return featureToggleApi.isFeatureEnabled("hmc-nro"); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/InitiateGeneralApplicationHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/InitiateGeneralApplicationHandlerTest.java index 9752885ee93..79ca08a4ba3 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/InitiateGeneralApplicationHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/InitiateGeneralApplicationHandlerTest.java @@ -135,17 +135,78 @@ void setup() { @Test void shouldThrowError_whenLRVsLiP() { + + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimIssued1v1LiP() + .caseAccessCategory(CaseCategory.UNSPEC_CLAIM) + .caseManagementLocation(CaseLocationCivil.builder() + .baseLocation("45678") + .region("4").build()) + .build(); + + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_START); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertThat(response.getErrors()).isNotNull(); + } + + @Test + void shouldThrowError_whenLRVsLiPCourtIsNotWhitelisted() { + CaseData caseData = CaseDataBuilder.builder() .atStateClaimIssued1v1LiP() - .caseAccessCategory(CaseCategory.UNSPEC_CLAIM) + .caseAccessCategory(CaseCategory.SPEC_CLAIM) .caseManagementLocation(CaseLocationCivil.builder() .baseLocation("45678") .region("4").build()) .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_START); + given(initiateGeneralAppService.caseContainsLiP(any())).willReturn(true); + given(featureToggleService.isGaForLipsEnabled()).willReturn(true); + given(featureToggleService.isGaForLipsEnabledAndLocationWhiteListed(any())).willReturn(false); + given(initiateGeneralAppService.respondentAssigned(any())).willReturn(true); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertThat(response.getErrors()).isNotNull(); + } + + @Test + void shouldThrowError_whenLRVsLiPAndLipsNotEnabled() { + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimIssued1v1LiP() + .caseAccessCategory(CaseCategory.SPEC_CLAIM) + .caseManagementLocation(CaseLocationCivil.builder() + .baseLocation("45678") + .region("4").build()) + .build(); + + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_START); + given(initiateGeneralAppService.caseContainsLiP(any())).willReturn(true); + given(featureToggleService.isGaForLipsEnabled()).willReturn(false); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertThat(response.getErrors()).isNotNull(); + } + + @Test + void shouldThrowError_whenLRVsLiPAndLipsNotEnabledAndWhiteListed() { + + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimIssued1v1LiP() + .caseAccessCategory(CaseCategory.SPEC_CLAIM) + .caseManagementLocation(CaseLocationCivil.builder() + .baseLocation("45678") + .region("4").build()) + .build(); + + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_START); + given(initiateGeneralAppService.caseContainsLiP(any())).willReturn(true); + given(featureToggleService.isGaForLipsEnabled()).willReturn(true); + given(featureToggleService.isGaForLipsEnabledAndLocationWhiteListed(any())).willReturn(true); + given(initiateGeneralAppService.respondentAssigned(any())).willReturn(false); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); assertThat(response.getErrors()).isNotNull(); } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/FeatureToggleServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/FeatureToggleServiceTest.java index f11b1c8f88e..725d0bc5726 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/FeatureToggleServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/FeatureToggleServiceTest.java @@ -139,6 +139,29 @@ void shouldReturnCorrectValue_whenLocationWhiteListed(Boolean toggleStat) { assertThat(featureToggleService.isLocationWhiteListedForCaseProgression(location)).isEqualTo(toggleStat); } + @ParameterizedTest + @CsvSource({ + "someLocation, true, true", + "someLocation, false, false", + ", true, false", + ", false, false" + }) + void shouldReturnCorrectValueBasedOnLocationAndFeatureToggleForGaLips(String location, boolean isFeatureEnabled, boolean expected) { + + if (isFeatureEnabled && location != null) { + when(featureToggleApi.isFeatureEnabledForLocation( + "ea-courts-whitelisted-for-ga-lips", + location, + false + )).thenReturn(isFeatureEnabled); + when(featureToggleService.isGaForLipsEnabled()).thenReturn(isFeatureEnabled); + } + + boolean result = featureToggleService.isGaForLipsEnabledAndLocationWhiteListed(location); + + assertEquals(expected, result); + } + @ParameterizedTest @ValueSource(booleans = {true, false}) void shouldReturnCorrectValue_whenIsTransferCaseOnlineEnabled(Boolean toggleStat) {