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-11150 flight delay screen test PR #3572

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d213fed
CIV-11150 Add new handler
hmcts-version1-ignacio Oct 27, 2023
ddf72aa
CIV-11150 Add new handler
hmcts-version1-ignacio Oct 30, 2023
6acff96
Merge branch 'master' into feat/CIV-11150-flight-delay-screen
hmcts-version1-ignacio Oct 30, 2023
c560e13
CIV-11150 Fix sonar issues
hmcts-version1-ignacio Oct 30, 2023
6b752a3
CIV-11150 Add new test and new changes
hmcts-version1-ignacio Oct 30, 2023
e353349
CIV-11150 Add new test and new changes
hmcts-version1-ignacio Oct 30, 2023
baa080f
CIV-11150 Fix sonar issue
hmcts-version1-ignacio Oct 31, 2023
6dcaa6e
Merge branch 'master' into feat/CIV-11150-flight-delay-screen
hmcts-version1-ignacio Oct 31, 2023
40b6821
Merge branch 'master' into feat/CIV-11150-flight-delay-screen
Azam-Hmcts Oct 31, 2023
7bc06d7
CIV-11150 Add claimType modifyer
hmcts-version1-ignacio Oct 31, 2023
ad02d7b
Merge remote-tracking branch 'origin/feat/CIV-11150-flight-delay-scre…
hmcts-version1-ignacio Oct 31, 2023
ccc87a7
Merge branch 'master' into feat/CIV-11150-flight-delay-screen
hmcts-version1-ignacio Nov 2, 2023
c07f81f
Merge branch 'master' into feat/CIV-11150-flight-delay-screen
krishnanuthalapati Nov 8, 2023
ae58a1a
Merge branch 'master' into feat/CIV-11150-flight-delay-screen
hmcts-version1-ignacio Nov 10, 2023
51e9eaf
Merge branch 'master' into feat/CIV-11150-flight-delay-screen
krishnanuthalapati Nov 13, 2023
22d7325
Merge branch 'master' into feat/CIV-11150-flight-delay-screen
hmcts-version1-ignacio Nov 14, 2023
49afe53
Merge branch 'master' into feat/CIV-11150-flight-delay-screen
hmcts-version1-ignacio Nov 14, 2023
78f614a
Merge branch 'master' into feat/CIV-11150-flight-delay-screen
hmcts-version1-ignacio Nov 14, 2023
5089c55
Merge branch 'master' into feat/CIV-11150-flight-delay-screen
hmcts-version1-ignacio Nov 14, 2023
49a5c73
CIV-11150 test PR
hmcts-version1-ignacio Nov 14, 2023
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
2 changes: 1 addition & 1 deletion Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import uk.gov.hmcts.contino.GithubAPI
def type = "java"
def product = "civil"
def component = "service"
def ccdBranch = "master"
def ccdBranch = "feat/CIV-11150-flight-delay-screen"
def camundaBranch = "master"
def yarnBuilder = new uk.gov.hmcts.contino.YarnBuilder(this)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public enum ClaimType {
BREACH_OF_CONTRACT(FeeType.HIGHER),
CONSUMER(FeeType.HIGHER),
CONSUMER_CREDIT(FeeType.HIGHER),
OTHER(FeeType.HIGHER);
OTHER(FeeType.HIGHER),
FLIGHT_DELAY(null);

private final FeeType feeType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import uk.gov.hmcts.reform.civil.config.ToggleConfiguration;
import uk.gov.hmcts.reform.civil.config.ClaimUrlsConfiguration;
import uk.gov.hmcts.reform.civil.enums.CaseCategory;
import uk.gov.hmcts.reform.civil.enums.ClaimType;
import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.model.Address;
Expand Down Expand Up @@ -230,6 +231,7 @@ protected Map<String, Callback> callbacks() {
)
.put(callbackKey(MID, "validate-spec-defendant-legal-rep-email"), this::validateSpecRespondentRepEmail)
.put(callbackKey(MID, "validate-spec-defendant2-legal-rep-email"), this::validateSpecRespondent2RepEmail)
.put(callbackKey(MID, "is-flight-delay-claim"), this::isFlightDelayClaim)
.build();
}

Expand Down Expand Up @@ -900,6 +902,23 @@ private CallbackResponse validateSpecRespondent2RepEmail(CallbackParams callback
.build();
}

private CallbackResponse isFlightDelayClaim(CallbackParams callbackParams) {
CaseData.CaseDataBuilder<?, ?> caseDataBuilder = callbackParams.getCaseData().toBuilder();

if (toggleService.isSdoR2Enabled()) {
caseDataBuilder.isFlightDelayClaim(callbackParams.getCaseData().getIsFlightDelayClaim());
if (callbackParams.getCaseData().getIsFlightDelayClaim().equals(YES)) {
caseDataBuilder.claimType(ClaimType.FLIGHT_DELAY);
} else {
caseDataBuilder.claimType(null);
}
}

return AboutToStartOrSubmitCallbackResponse.builder()
.data(caseDataBuilder.build().toMap(objectMapper))
.build();
}

private CallbackResponse setRespondent2SameLegalRepToNo(CallbackParams callbackParams) {
CaseData.CaseDataBuilder caseDataBuilder = callbackParams.getCaseData().toBuilder();

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ public boolean hasNoOngoingBusinessProcess() {

private final TransferCaseDetails transferCaseDetails;

//SDO-R2
private YesOrNo isFlightDelayClaim;

/**
* There are several fields that can hold the I2P of applicant1 depending
* on multiparty scenario, which complicates all conditions depending on it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ public boolean isCaseProgressionEnabled() {
public boolean isEarlyAdoptersEnabled() {
return featureToggleApi.isFeatureEnabled("early-adopters");
}

public boolean isSdoR2Enabled() {
return featureToggleApi.isFeatureEnabled("isSdoR2Enabled");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -1620,6 +1622,47 @@ void shouldReturnErrors_whenRequiredAddressIsYesAndNotValid() {
}
}

@Nested
class IsFlightDelayClaimMidCallback {
@ParameterizedTest
@ValueSource(booleans = {true, false})
void shouldSetIsFlightDelayClaim_whenPopulatedAndSdoR2Enabled(Boolean toggleStat) {
// Given
YesOrNo yesOrNo = toggleStat ? YES : NO;
CaseData caseData = CaseData.builder().isFlightDelayClaim(yesOrNo)
.build();

CallbackParams params = callbackParamsOf(caseData, MID, "is-flight-delay-claim");
// When
when(toggleService.isSdoR2Enabled()).thenReturn(true);
var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params);

// Then
assertThat(response.getData()).containsEntry("isFlightDelayClaim", toggleStat ? "Yes" : "No");
if (toggleStat) {
assertThat(response.getData()).containsEntry("claimType", "FLIGHT_DELAY");
} else {
assertThat(response.getData()).doesNotHaveToString("claimType");
}
}

@Test
void shouldSetIsFlightDelayClaim_whenPopulatedAndSdoR2Disabled() {
// Given
CaseData caseData = CaseData.builder().isFlightDelayClaim(YES)
.build();

CallbackParams params = callbackParamsOf(caseData, MID, "is-flight-delay-claim");
// When
when(toggleService.isSdoR2Enabled()).thenReturn(false);
var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params);

// Then
assertThat(response.getData()).doesNotHaveToString("isFlightDelayClaim");
assertThat(response.getData()).doesNotHaveToString("claimType");
}
}

@Nested
class AboutToSubmitCallbackV1 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ void shouldReturnCorrectValue_whenEarlyAdopterEnabled(Boolean toggleStat) {
assertThat(featureToggleService.isEarlyAdoptersEnabled()).isEqualTo(toggleStat);
}

@ParameterizedTest
@ValueSource(booleans = {true, false})
void shouldReturnCorrectValue_whenIsSdoR2Enabled(Boolean toggleStat) {
var sdoR2Key = "isSdoR2Enabled";
givenToggle(sdoR2Key, toggleStat);

assertThat(featureToggleService.isSdoR2Enabled()).isEqualTo(toggleStat);
}

private void givenToggle(String feature, boolean state) {
when(featureToggleApi.isFeatureEnabled(eq(feature)))
.thenReturn(state);
Expand Down
Loading