Skip to content

Commit

Permalink
Fix is ibc case (#1683)
Browse files Browse the repository at this point in the history
* Fix to account for case create mid event when ibc is set in dynamic list

* Update SscsCaseDataTest for tests on new changes

* Removing extra space added

* Added missing import
  • Loading branch information
Tim97eng authored Nov 28, 2024
1 parent 97efda6 commit dbe289e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType;
import uk.gov.hmcts.reform.sscs.ccd.validation.groups.UniversalCreditValidationGroup;
import uk.gov.hmcts.reform.sscs.ccd.validation.localdate.LocalDateMustNotBeInFuture;
Expand Down Expand Up @@ -762,10 +763,19 @@ public Optional<Benefit> getBenefitType() {

@JsonIgnore
public boolean isIbcCase() {
return INFECTED_BLOOD_COMPENSATION.getBenefitCode().equals(benefitCode)
|| getBenefitType()
.map(INFECTED_BLOOD_COMPENSATION::equals)
.orElse(false);
if (INFECTED_BLOOD_COMPENSATION.getBenefitCode().equals(benefitCode)) {
return true;
}

return Optional.of(this)
.map(SscsCaseData::getAppeal)
.map(Appeal::getBenefitType)
.map(BenefitType::getDescriptionSelection)
.map(DynamicList::getValue)
.map(DynamicListItem::getCode)
.filter(ObjectUtils::isNotEmpty)
.map(INFECTED_BLOOD_COMPENSATION.getBenefitCode()::equals)
.orElseGet(() -> getBenefitType().map(INFECTED_BLOOD_COMPENSATION::equals).orElse(false));
}

@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,17 @@ public void givenAppealBenefitCodeIsSetIba_thenIsIbcIsTrue() {
assertTrue(sscsCaseData.isIbcCase());
}

@Test
public void givenAppealBenefitCodeIsSetMidCaseCreateIba_thenIsIbcIsTrue() {
DynamicList expectedList = new DynamicList(
new DynamicListItem(INFECTED_BLOOD_COMPENSATION.getBenefitCode(), INFECTED_BLOOD_COMPENSATION.getShortName()), new ArrayList<>());

SscsCaseData sscsCaseData = SscsCaseData.builder()
.appeal(Appeal.builder().benefitType(BenefitType.builder().descriptionSelection(expectedList).build()).build()).build();

assertTrue(sscsCaseData.isIbcCase());
}

@Test
public void givenAppealBenefitCodeIsSetOnlyNonIba_thenIsIbcIsFalse() {
SscsCaseData sscsCaseData = SscsCaseData.builder()
Expand Down

0 comments on commit dbe289e

Please sign in to comment.