Skip to content

Commit

Permalink
Merge branch 'master' into feat/civ-11158
Browse files Browse the repository at this point in the history
  • Loading branch information
HarryH96 authored Nov 15, 2023
2 parents f365e66 + 7e2e30e commit 2f9c7c5
Show file tree
Hide file tree
Showing 10 changed files with 543 additions and 1,025 deletions.
3 changes: 2 additions & 1 deletion src/main/java/uk/gov/hmcts/reform/civil/enums/ClaimType.java
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
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected Map<String, Callback> callbacks() {
.put(callbackKey(MID, "upload"), this::emptyCallbackResponse)
.put(callbackKey(MID, "statement-of-truth"), this::resetStatementOfTruth)
.put(callbackKey(MID, "validate-payment-date"), this::validateRespondentPaymentDate)
.put(callbackKey(MID, "specCorrespondenceAddress"), this::validateCorrespondenceAddress)
.put(callbackKey(MID, "specCorrespondenceAddress"), this::validateCorrespondenceApplicantAddress)
.put(callbackKey(MID, "determineLoggedInSolicitor"), this::determineLoggedInSolicitor)
.put(callbackKey(MID, "track"), this::handleDefendAllClaim)
.put(callbackKey(MID, "specHandleResponseType"), this::handleRespondentResponseTypeForSpec)
Expand Down Expand Up @@ -1060,26 +1060,12 @@ private AllocatedTrack getAllocatedTrack(CaseData caseData) {
);
}

private CallbackResponse validateCorrespondenceAddress(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
if (caseData.getIsRespondent1() == YES
&& caseData.getRespondentSolicitor1ServiceAddressRequired() == NO) {
List<String> errors = postcodeValidator.validate(
caseData.getRespondentSolicitor1ServiceAddress().getPostCode());

return AboutToStartOrSubmitCallbackResponse.builder()
.errors(errors)
.build();
} else if (caseData.getIsRespondent2() == YES
&& caseData.getRespondentSolicitor2ServiceAddressRequired() == NO) {
List<String> errors = postcodeValidator.validate(
caseData.getRespondentSolicitor2ServiceAddress().getPostCode());

return AboutToStartOrSubmitCallbackResponse.builder()
.errors(errors)
.build();
private CallbackResponse validateCorrespondenceApplicantAddress(CallbackParams callbackParams) {
if (SpecJourneyConstantLRSpec.DEFENDANT_RESPONSE_SPEC.equals(callbackParams.getRequest().getEventId())) {
return validateCorrespondenceApplicantAddress(callbackParams, postcodeValidator);
}
return AboutToStartOrSubmitCallbackResponse.builder().build();
return AboutToStartOrSubmitCallbackResponse.builder()
.build();
}

private CallbackResponse determineLoggedInSolicitor(CallbackParams callbackParams) {
Expand Down Expand Up @@ -1132,10 +1118,6 @@ private CallbackResponse populateRespondent1Copy(CallbackParams callbackParams)
.respondent1Copy(caseData.getRespondent1())
.respondent1ClaimResponseTestForSpec(caseData.getRespondent1ClaimResponseTypeForSpec())
.respondent2ClaimResponseTestForSpec(caseData.getRespondent2ClaimResponseTypeForSpec())
.respondentSolicitor1ServiceAddress(Address.builder().build())
.respondentSolicitor2ServiceAddress(Address.builder().build())
.respondentSolicitor1ServiceAddressRequired(null)
.respondentSolicitor2ServiceAddressRequired(null)
.showConditionFlags(initialShowTags);

updatedCaseData.respondent1DetailsForClaimDetailsTab(caseData.getRespondent1().toBuilder().flags(null).build());
Expand Down Expand Up @@ -1283,9 +1265,9 @@ private CallbackResponse validateUnavailableDates(CallbackParams callbackParams)
}

private CallbackResponse validateDateOfBirth(CallbackParams callbackParams) {
Party respondent = callbackParams.getCaseData().getRespondent1Copy();
if (respondent == null && callbackParams.getCaseData().getRespondent2Copy() != null) {
respondent = callbackParams.getCaseData().getRespondent2Copy();
Party respondent = callbackParams.getCaseData().getRespondent1();
if (respondent == null && callbackParams.getCaseData().getRespondent2() != null) {
respondent = callbackParams.getCaseData().getRespondent2();
}
List<String> errors = dateOfBirthValidator.validate(respondent);

Expand Down Expand Up @@ -1363,9 +1345,9 @@ private CallbackResponse setApplicantResponseDeadline(CallbackParams callbackPar
AllocatedTrack allocatedTrack = caseData.getAllocatedTrack();
Party updatedRespondent1;

if (NO.equals(caseData.getTempAddress1Required())) {
if (NO.equals(caseData.getSpecAoSApplicantCorrespondenceAddressRequired())) {
updatedRespondent1 = caseData.getRespondent1().toBuilder()
.primaryAddress(caseData.getTempAddress1()).build();
.primaryAddress(caseData.getSpecAoSApplicantCorrespondenceAddressdetails()).build();
} else {
updatedRespondent1 = caseData.getRespondent1().toBuilder()
.primaryAddress(caseData.getRespondent1Copy().getPrimaryAddress())
Expand Down Expand Up @@ -1442,8 +1424,21 @@ && ifResponseTypeIsPartOrFullAdmission(caseData)) {
.businessProcess(BusinessProcess.ready(DEFENDANT_RESPONSE_SPEC));

if (caseData.getRespondent2() != null && caseData.getRespondent2Copy() != null) {
Party updatedRespondent2 = applyRespondent2Address(caseData, updatedData);
updatedData.respondent2DetailsForClaimDetailsTab(updatedRespondent2);
Party updatedRespondent2;

if (NO.equals(caseData.getSpecAoSRespondent2HomeAddressRequired())) {
updatedRespondent2 = caseData.getRespondent2().toBuilder()
.primaryAddress(caseData.getSpecAoSRespondent2HomeAddressDetails()).build();
} else {
updatedRespondent2 = caseData.getRespondent2().toBuilder()
.primaryAddress(caseData.getRespondent2Copy().getPrimaryAddress()).build();
}

updatedData
.respondent2(updatedRespondent2.toBuilder()
.flags(caseData.getRespondent2Copy().getFlags()).build())
.respondent2Copy(null);
updatedData.respondent2DetailsForClaimDetailsTab(updatedRespondent2.toBuilder().flags(null).build());
}

// moving statement of truth value to correct field, this was not possible in mid event.
Expand Down Expand Up @@ -1500,10 +1495,8 @@ && ifResponseTypeIsPartOrFullAdmission(caseData)) {
.build());
}

UnavailabilityDatesUtils.rollUpUnavailabilityDatesForRespondent(
updatedData,
toggleService.isUpdateContactDetailsEnabled()
);
UnavailabilityDatesUtils.rollUpUnavailabilityDatesForRespondent(updatedData,
toggleService.isUpdateContactDetailsEnabled());

updatedData.respondent1DetailsForClaimDetailsTab(updatedData.build().getRespondent1().toBuilder().flags(null).build());
if (ofNullable(caseData.getRespondent2()).isPresent()) {
Expand Down Expand Up @@ -1575,21 +1568,6 @@ && isAwaitingAnotherDefendantResponse(caseData)) {
.build();
}

private static Party applyRespondent2Address(CaseData caseData, CaseData.CaseDataBuilder<?, ?> updatedData) {
Party updatedRespondent2;

if (NO.equals(caseData.getTempAddress2Required())) {
updatedRespondent2 = caseData.getRespondent2().toBuilder()
.primaryAddress(caseData.getTempAddress2()).build();
} else {
updatedRespondent2 = caseData.getRespondent2().toBuilder()
.primaryAddress(caseData.getRespondent2Copy().getPrimaryAddress()).build();
}

updatedData.respondent2(updatedRespondent2).respondent2Copy(null);
return updatedRespondent2;
}

private boolean ifResponseTypeIsPartOrFullAdmission(CaseData caseData) {
return (RespondentResponseTypeSpec.PART_ADMISSION.equals(caseData.getRespondent1ClaimResponseTypeForSpec())
|| RespondentResponseTypeSpec.PART_ADMISSION.equals(
Expand All @@ -1604,19 +1582,19 @@ private void updateCorrespondenceAddress(CallbackParams callbackParams,
CaseData.CaseDataBuilder<?, ?> updatedCaseData,
CaseData caseData) {
if (solicitorHasCaseRole(callbackParams, RESPONDENTSOLICITORONE)
&& caseData.getRespondentSolicitor1ServiceAddressRequired() == YesOrNo.NO) {
Address newAddress = caseData.getRespondentSolicitor1ServiceAddress();
&& caseData.getSpecAoSRespondentCorrespondenceAddressRequired() == YesOrNo.NO) {
Address newAddress = caseData.getSpecAoSRespondentCorrespondenceAddressdetails();
updatedCaseData.specRespondentCorrespondenceAddressdetails(newAddress)
.respondentSolicitor1ServiceAddress(Address.builder().build());
.specAoSRespondentCorrespondenceAddressdetails(Address.builder().build());
if (getMultiPartyScenario(caseData) == ONE_V_TWO_ONE_LEGAL_REP) {
// to keep with heading tab
updatedCaseData.specRespondent2CorrespondenceAddressdetails(newAddress);
}
} else if (solicitorHasCaseRole(callbackParams, RESPONDENTSOLICITORTWO)
&& caseData.getRespondentSolicitor2ServiceAddressRequired() == YesOrNo.NO) {
&& caseData.getSpecAoSRespondent2CorrespondenceAddressRequired() == YesOrNo.NO) {
updatedCaseData.specRespondent2CorrespondenceAddressdetails(
caseData.getRespondentSolicitor2ServiceAddress())
.respondentSolicitor2ServiceAddress(Address.builder().build());
caseData.getSpecAoSRespondent2CorrespondenceAddressdetails())
.specAoSRespondent2CorrespondenceAddressdetails(Address.builder().build());
}
}

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
17 changes: 0 additions & 17 deletions src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java
Original file line number Diff line number Diff line change
Expand Up @@ -723,23 +723,6 @@ public boolean isApplicantNotRepresented() {

private FastTrackAllocation fastTrackAllocation;

/**
* used to temporary hold addresses.
*/
private final Address tempAddress1;
/**
* used with tempAddress1.
*/
private final YesOrNo tempAddress1Required;
/**
* used to temporary hold addresses.
*/
private final Address tempAddress2;
/**
* used with tempAddress1.
*/
private final YesOrNo tempAddress2Required;

@JsonIgnore
public boolean isResponseAcceptedByClaimant() {
return applicant1AcceptAdmitAmountPaidSpec == YesOrNo.YES
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 @@ -76,7 +76,7 @@ public static void rollUpUnavailabilityDatesForRespondent(CaseData.CaseDataBuild
.getUnavailableDates();

List<Element<UnavailableDate>> updatedUnavailableDates = addEventAndDate(
caseData.getRespondent2ResponseDate().toLocalDate(),
caseData.getRespondent1ResponseDate().toLocalDate(),
DEFENDANT_RESPONSE_EVENT,
respondent2DQUnavailableDates
);
Expand Down
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
Loading

0 comments on commit 2f9c7c5

Please sign in to comment.