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

[CCAP-509] adding additional counties behind enableSDA15Providers flag #1096

Merged
merged 2 commits into from
Feb 6, 2025
Merged
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
28 changes: 26 additions & 2 deletions src/main/java/org/ilgcc/app/utils/CountyOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@
import static org.ilgcc.app.utils.ZipcodeOption.zip_60530;
import static org.ilgcc.app.utils.ZipcodeOption.zip_61015;
import static org.ilgcc.app.utils.ZipcodeOption.zip_61053;
import static org.ilgcc.app.utils.ZipcodeOption.zip_61243;
import static org.ilgcc.app.utils.ZipcodeOption.zip_61071;
import static org.ilgcc.app.utils.ZipcodeOption.zip_62011;
import static org.ilgcc.app.utils.ZipcodeOption.zip_62401;
import static org.ilgcc.app.utils.ZipcodeOption.zip_62410;
import static org.ilgcc.app.utils.ZipcodeOption.zip_62413;
import static org.ilgcc.app.utils.ZipcodeOption.zip_62421;
import static org.ilgcc.app.utils.ZipcodeOption.zip_62432;
import static org.ilgcc.app.utils.ZipcodeOption.zip_62434;
import static org.ilgcc.app.utils.ZipcodeOption.zip_62439;
import static org.ilgcc.app.utils.ZipcodeOption.zip_62446;
import static org.ilgcc.app.utils.ZipcodeOption.zip_62476;
import static org.ilgcc.app.utils.ZipcodeOption.zip_62807;
import static org.ilgcc.app.utils.ZipcodeOption.zip_62814;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -18,7 +30,19 @@ public enum CountyOption implements InputOption {
LEE("Lee", zip_60530),
MCHENRY("McHenry", zip_60050),
OGLE("Ogle", zip_61015),
WHITESIDE("Whiteside", zip_61243);
WHITESIDE("Whiteside", zip_61071),
MARION("Marion", zip_62807),
JEFFERSON("Jefferson", zip_62814),
EFFINGHAM("Effingham", zip_62401),
FAYETTE("Fayette", zip_62011),
CRAWFORD("Crawford", zip_62413),
WAYNE("Wayne", zip_62446),
RICHLAND("Richland", zip_62421),
LAWRENCE("Lawrence", zip_62439),
CLAY("Clay", zip_62434),
WABASH("Wabash", zip_62410),
JASPER("Jasper", zip_62432),
EDWARDS("Edwards", zip_62476);

private final String value;
private final ZipcodeOption zipcodeOption;
Expand Down
63 changes: 63 additions & 0 deletions src/main/java/org/ilgcc/app/utils/CountyOptionUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.ilgcc.app.utils;

import static org.ilgcc.app.utils.CountyOption.CARROLL;
import static org.ilgcc.app.utils.CountyOption.CLAY;
import static org.ilgcc.app.utils.CountyOption.CRAWFORD;
import static org.ilgcc.app.utils.CountyOption.DEKALB;
import static org.ilgcc.app.utils.CountyOption.EDWARDS;
import static org.ilgcc.app.utils.CountyOption.EFFINGHAM;
import static org.ilgcc.app.utils.CountyOption.FAYETTE;
import static org.ilgcc.app.utils.CountyOption.JASPER;
import static org.ilgcc.app.utils.CountyOption.JEFFERSON;
import static org.ilgcc.app.utils.CountyOption.LAWRENCE;
import static org.ilgcc.app.utils.CountyOption.LEE;
import static org.ilgcc.app.utils.CountyOption.MARION;
import static org.ilgcc.app.utils.CountyOption.MCHENRY;
import static org.ilgcc.app.utils.CountyOption.OGLE;
import static org.ilgcc.app.utils.CountyOption.RICHLAND;
import static org.ilgcc.app.utils.CountyOption.WABASH;
import static org.ilgcc.app.utils.CountyOption.WAYNE;
import static org.ilgcc.app.utils.CountyOption.WHITESIDE;

import jakarta.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class CountyOptionUtils {
@Value("${il-gcc.enable-sda15-providers}")
boolean enableSDA15Providers;

private static List<CountyOption> countyOptions;

@PostConstruct
public void init() {
countyOptions = new ArrayList<>();
countyOptions.add(CARROLL);
countyOptions.add(DEKALB);
countyOptions.add(LEE);
countyOptions.add(MCHENRY);
countyOptions.add(OGLE);
countyOptions.add(WHITESIDE);
if (enableSDA15Providers) {
Copy link
Contributor

@analoo analoo Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than hard coding this, I think it makes sense to use this logic:

 public static Boolean isValidZipcodeOption(String zipcode, Boolean includeSDA15) {
        return Arrays.stream(ZipcodeOption.values()).filter(zip -> zip.active)
                .filter(zip -> includeSDA15 ? zip.caseloadCode.equals("BB") || zip.caseloadCode.equals("QQ")
                        : zip.caseloadCode.equals("BB")).anyMatch(zip -> zip.value.equals(zipcode));
    }
to determine whether the county is valid or not. 

We don't want the two sets of data to get our of sync.

countyOptions.add(MARION);
countyOptions.add(JEFFERSON);
countyOptions.add(EFFINGHAM);
countyOptions.add(FAYETTE);
countyOptions.add(CRAWFORD);
countyOptions.add(WAYNE);
countyOptions.add(RICHLAND);
countyOptions.add(LAWRENCE);
countyOptions.add(CLAY);
countyOptions.add(WABASH);
countyOptions.add(JASPER);
countyOptions.add(EDWARDS);
}
}

public static List<CountyOption> getActiveCountyOptions() {
return countyOptions;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/templates/gcc/onboarding-county.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<th:block th:ref="countyInput">
<th:block
th:replace="~{fragments/inputs/selectOptionPlaceholder :: selectOptionPlaceholder(optionText=#{onboarding-county.placeholder-text})}"/>
<th:block th:each="county : ${T(org.ilgcc.app.utils.CountyOption).values()}">
<th:block th:each="county : ${T(org.ilgcc.app.utils.CountyOptionUtils).getActiveCountyOptions()}">
<th:block
th:replace="~{fragments/inputs/selectOption :: selectOption(value=${county.getLabel()}, optionText=${county.getLabel()})}"/>
</th:block>
Expand Down
41 changes: 41 additions & 0 deletions src/test/java/org/ilgcc/app/submission/actions/CountyUtilTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.ilgcc.app.submission.actions;

import static org.assertj.core.api.Assertions.assertThat;

import formflow.library.data.FormSubmission;
import formflow.library.data.Submission;
import jakarta.annotation.Resource;
import java.util.Map;
import org.ilgcc.app.IlGCCApplication;
import org.ilgcc.app.utils.CountyOptionUtils;
import org.ilgcc.app.utils.SubmissionTestBuilder;
import org.ilgcc.app.utils.ZipcodeOption;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.util.TestPropertyValues;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anahar-cfa - you are importing a lot of classes that are not used anywhere on the tests. Can you remove those?

Also - If you are testing that the number of active county options is 18 when the flag is on. It would make sense to also confirm that those inactive counties are NOT included when the feature flag is off.

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.support.TestPropertySourceUtils;
import org.springframework.util.Assert;

@SpringBootTest(
classes = IlGCCApplication.class
)

@TestPropertySource(properties = {"il-gcc.enable-sda15-providers=true"})
@ActiveProfiles("test")
public class CountyUtilTest {

@Test
public void getCountiesWithSda15ProvidersAsFalse() {
assertThat(CountyOptionUtils.getActiveCountyOptions().size()).isEqualTo(18);
}

}