Skip to content

Commit

Permalink
"CCM 168963: Update the DocumentField preparers,
Browse files Browse the repository at this point in the history
168966: Write new tests that are needed due to feature changes"
  • Loading branch information
Abdumn committed Jan 7, 2025
1 parent fc2b06c commit f4217a5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public class ApplicationDataParser {

coordinatesMap.put(Field.TRIBAL_NATION,
new ParsingCoordinate("tribalNationMember", "isTribalNationMember"));

coordinatesMap.put(Field.NATION_OF_RESIDENCE,
new ParsingCoordinate("nationOfResidence", "selectedNationOfResidence"));

coordinatesMap.put(Field.SELECTED_TRIBAL_NATION,
new ParsingCoordinate("selectTheTribe", "selectedTribe"));
Expand Down Expand Up @@ -533,6 +536,7 @@ public enum Field {
GENERAL_DELIVERY_ZIPCODE,

TRIBAL_NATION,
NATION_OF_RESIDENCE,
TRIBAL_NATION_BOUNDARY,
SELECTED_TRIBAL_NATION,
LINEAL_DESCENDANT_WEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import static org.codeforamerica.shiba.application.parsers.ApplicationDataParser.Field.LIVING_IN_TRIBAL_NATION_BOUNDARY;
import static org.codeforamerica.shiba.application.parsers.ApplicationDataParser.Field.SELECTED_TRIBAL_NATION;
import static org.codeforamerica.shiba.application.parsers.ApplicationDataParser.Field.TRIBAL_NATION;

import static org.codeforamerica.shiba.application.parsers.ApplicationDataParser.Field.NATION_OF_RESIDENCE;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -28,10 +28,28 @@ public List<DocumentField> prepareDocumentFields(Application application, Docume
Boolean isTribalNationMember = getBooleanValue(application.getApplicationData().getPagesData(), TRIBAL_NATION);
String selectedTribe = isTribalNationMember? getFirstValue(application.getApplicationData().getPagesData(), SELECTED_TRIBAL_NATION) : null;
Boolean livesInNationBoundary = isTribalNationMember ? getBooleanValue(application.getApplicationData().getPagesData(), LIVING_IN_TRIBAL_NATION_BOUNDARY) : null;

Boolean isNationBoundary = getBooleanValue(application.getApplicationData().getPagesData(), LIVING_IN_TRIBAL_NATION_BOUNDARY);
String selectedNationOfResidence = isTribalNationMember? getFirstValue(application.getApplicationData().getPagesData(), NATION_OF_RESIDENCE) : null;


if (Boolean.FALSE.equals(isTribalNationMember)) {
return result;
}

boolean tribeRequiresBoundaryAnswer = selectedTribe !=null && TRIBES_REQUIRING_BOUNDARY_ANSWER.contains(selectedTribe);

if (Boolean.FALSE.equals(livesInNationBoundary) && isNationBoundary) {
result.add(new DocumentField("nationsBoundary", "boundaryMember", "No",
DocumentFieldType.SINGLE_VALUE));
}
if (Boolean.TRUE.equals(livesInNationBoundary) && isNationBoundary) {
result.add(new DocumentField("nationsBoundary", "boundaryMember","Yes",
DocumentFieldType.SINGLE_VALUE));
result.add(new DocumentField("nationsBoundary", "selectedNationBoundaryTribe", selectedNationOfResidence,
DocumentFieldType.SINGLE_VALUE));
}


if (Boolean.TRUE.equals(isTribalNationMember) && tribeRequiresBoundaryAnswer) {
result.add(new DocumentField("nationsBoundary", "boundaryMember",livesInNationBoundary ? "Yes" : "No",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ void shouldMapTribalNationMemberYesOrNoAndWhichTribalNationBoundary() throws Exc
assertPdfFieldEquals("BOUNDARY_MEMBER", "Yes", caf);
assertPdfFieldEquals("TRIBAL_NATION_BOUNDARY", "Prairie Island", caf);
}

//This test still needs to exist to verify that the application created before implementation of NationOfResidence is compatible.
@Test
void shouldMapTribalNationMemberYesOrNoAndWhichTribalNation() throws Exception {
fillInRequiredPages();
Expand All @@ -599,6 +599,34 @@ void shouldMapTribalNationMemberYesOrNoAndWhichTribalNation() throws Exception {
assertPdfFieldEquals("BOUNDARY_MEMBER","Off", caf);
assertPdfFieldIsEmpty("TRIBAL_NATION_BOUNDARY", caf);
}
// this test verify NationBoundary
@Test
void shouldMapTribalNationMemberYesOrNoNationBoundary() throws Exception {
fillInRequiredPages();
postExpectingSuccess("tribalNationMember", "isTribalNationMember", "true");
postExpectingSuccess("selectTheTribe", "selectedTribe", "Red Lake Nation");
postExpectingSuccess("nationsBoundary", "livingInNationBoundary", "false");

var caf = submitAndDownloadCaf();

assertPdfFieldEquals("BOUNDARY_MEMBER","No", caf);
assertPdfFieldIsEmpty("TRIBAL_NATION_BOUNDARY", caf);
}
// this test verify NationOfResidence

@Test
void shouldMapTribalNationMemberYesOrNoAndWhichNationBoundary() throws Exception {
fillInRequiredPages();
postExpectingSuccess("tribalNationMember", "isTribalNationMember", "true");
postExpectingSuccess("selectTheTribe", "selectedTribe", "Leech Lake");
postExpectingSuccess("nationsBoundary", "livingInNationBoundary", "true");
postExpectingSuccess("nationOfResidence", "selectedNationOfResidence", "Red Lake Nation");

var caf = submitAndDownloadCaf();

assertPdfFieldEquals("BOUNDARY_MEMBER","Yes", caf);
assertPdfFieldEquals("TRIBAL_NATION_BOUNDARY", "Red Lake Nation", caf);
}

@Test
void shouldMapTribalTANF() throws Exception {
Expand Down

0 comments on commit f4217a5

Please sign in to comment.