Skip to content

Commit

Permalink
Set NPIs for all CountyRoutingDestinations
Browse files Browse the repository at this point in the history
- Counties must have at least dhs provider ids, emails, and phone numbers (address optional) no more no-args constructor leading to weird null's in application IDs
- Simplify env set up to be either prod or non-prod, the only difference should be the NPIs and help emails

[#182255304]
  • Loading branch information
bencalegari committed Jun 13, 2022
1 parent 8e9f89f commit c24fb5a
Show file tree
Hide file tree
Showing 9 changed files with 352 additions and 792 deletions.
983 changes: 279 additions & 704 deletions src/main/java/org/codeforamerica/shiba/mnit/CountyMapConfiguration.java

Large diffs are not rendered by default.

@@ -1,28 +1,30 @@
package org.codeforamerica.shiba.mnit;

import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.codeforamerica.shiba.County;
import org.codeforamerica.shiba.pages.enrichment.Address;

@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class CountyRoutingDestination extends RoutingDestination {

private County county;
private Address postOfficeAddress;

@Builder
public CountyRoutingDestination(County county, String dhsProviderId,
String email, String phoneNumber, Address postOfficeAddress) {
super(dhsProviderId, email, phoneNumber);
this.county = county;
this.postOfficeAddress = postOfficeAddress;
}

public CountyRoutingDestination(County county, String dhsProviderId, String email,
String phoneNumber) {
super(dhsProviderId, email, phoneNumber);
this.county = county;
}

@Override
public String getName() {
return county.displayName();
Expand Down
29 changes: 17 additions & 12 deletions src/test/java/org/codeforamerica/shiba/ResubmissionServiceTest.java
Expand Up @@ -2,6 +2,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.codeforamerica.shiba.County.Anoka;
import static org.codeforamerica.shiba.County.Hennepin;
import static org.codeforamerica.shiba.County.Olmsted;
import static org.codeforamerica.shiba.TribalNationRoutingDestination.MILLE_LACS_BAND_OF_OJIBWE;
import static org.codeforamerica.shiba.application.Status.DELIVERED_BY_EMAIL;
Expand All @@ -11,17 +12,27 @@
import static org.codeforamerica.shiba.output.Document.CCAP;
import static org.codeforamerica.shiba.output.Document.UPLOADED_DOC;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.List;
import java.util.Map;
import org.codeforamerica.shiba.application.*;
import org.codeforamerica.shiba.application.Application;
import org.codeforamerica.shiba.application.ApplicationRepository;
import org.codeforamerica.shiba.application.ApplicationStatus;
import org.codeforamerica.shiba.application.ApplicationStatusRepository;
import org.codeforamerica.shiba.application.Status;
import org.codeforamerica.shiba.mnit.CountyRoutingDestination;
import org.codeforamerica.shiba.mnit.TribalNationConfiguration;
import org.codeforamerica.shiba.output.ApplicationFile;
import org.codeforamerica.shiba.output.Document;
import org.codeforamerica.shiba.output.Recipient;
import org.codeforamerica.shiba.output.caf.FilenameGenerator;
import org.codeforamerica.shiba.output.caf.SnapExpeditedEligibilityDecider;
import org.codeforamerica.shiba.output.pdf.PdfGenerator;
import org.codeforamerica.shiba.pages.RoutingDecisionService;
Expand Down Expand Up @@ -60,26 +71,20 @@ class ResubmissionServiceTest {
private ApplicationStatusRepository applicationStatusRepository;
@Mock
private PageEventPublisher pageEventPublisher;
@Mock
private FilenameGenerator filenameGenerator ;

@BeforeEach
void setUp() {
countyMap.setDefaultValue(CountyRoutingDestination.builder()
.dhsProviderId("defaultDhsProviderId")
.email(DEFAULT_EMAIL) // TODO test other counties besides DEFAULT
.build());
countyMap.setDefaultValue(new CountyRoutingDestination(Hennepin, "defaultDhsProviderId", DEFAULT_EMAIL, "phoneNumber"));
String OLMSTED_EMAIL = "olmsted@example.com";
countyMap.setCounties(Map.of(
Anoka, CountyRoutingDestination.builder().county(Anoka).email(ANOKA_EMAIL).build(),
Olmsted, CountyRoutingDestination.builder().county(Olmsted).email(OLMSTED_EMAIL).build()
Anoka, new CountyRoutingDestination(Anoka, "dpi1", ANOKA_EMAIL, "phoneNumber"),
Olmsted, new CountyRoutingDestination(Olmsted, "dpi2", OLMSTED_EMAIL, "phoneNumber")
));
Map<String, TribalNationRoutingDestination> tribalNations = new TribalNationConfiguration().localTribalNations();
routingDecisionService = new RoutingDecisionService(tribalNations, countyMap, mock(
FeatureFlagConfiguration.class));
FeatureFlagConfiguration featureFlagConfiguration = new FeatureFlagConfiguration(Map.of());
SnapExpeditedEligibilityDecider decider = mock(SnapExpeditedEligibilityDecider.class);
filenameGenerator = new FilenameGenerator(countyMap, decider);
resubmissionService = new ResubmissionService(applicationRepository, emailClient,
pdfGenerator, routingDecisionService, applicationStatusRepository, pageEventPublisher, featureFlagConfiguration);
}
Expand Down
Expand Up @@ -32,7 +32,7 @@ class RoutingDestinationMessageServiceTest {
void generatesMessageStringsWhenCountyAndTribalNation() {
routingDestinations = new ArrayList<>();
routingDestinations.add(
CountyRoutingDestination.builder().county(Anoka).phoneNumber("555-5555").build());
new CountyRoutingDestination(Anoka, "DPI", "email", "555-5555"));
routingDestinations.add(new TribalNationRoutingDestination(MILLE_LACS_BAND_OF_OJIBWE,
"someProviderId", "someEmail", "222-2222"));
RoutingDestinationMessageService routingDestinationMessageService = new RoutingDestinationMessageService(
Expand All @@ -49,7 +49,7 @@ void generatesMessageStringsWhenCountyAndTribalNation() {
void generatesMessageStringsWithoutPhoneNumbers() {
routingDestinations = new ArrayList<>();
routingDestinations.add(
CountyRoutingDestination.builder().county(Anoka).phoneNumber("555-5555").build());
new CountyRoutingDestination(Anoka, "DPI", "email", "555-5555"));
routingDestinations.add(new TribalNationRoutingDestination(MILLE_LACS_BAND_OF_OJIBWE,
"someProviderId", "someEmail", "222-2222"));
RoutingDestinationMessageService routingDestinationMessageService = new RoutingDestinationMessageService(
Expand All @@ -65,7 +65,7 @@ void generatesMessageStringsWithoutPhoneNumbers() {
@Test
void generatesMessageStringsWhenCountyOnly() {
routingDestinations = new ArrayList<>();
routingDestinations.add(CountyRoutingDestination.builder().county(Anoka).phoneNumber("555-5555").build());
routingDestinations.add(new CountyRoutingDestination(Anoka, "DPI", "email", "555-5555"));
RoutingDestinationMessageService routingDestinationMessageService = new RoutingDestinationMessageService(messageSource);
when(routingDecisionService.getRoutingDestinations(any(), any())).thenReturn(routingDestinations);

Expand Down
Expand Up @@ -38,7 +38,6 @@ public class ApplicationStatusRepositoryTest extends AbstractRepositoryTest {
private ApplicationStatusRepository applicationStatusRepository;

private final RoutingDecisionService routingDecisionService = mock(RoutingDecisionService.class);
private CountyMap<CountyRoutingDestination> countyMap;
@MockBean
private FilenameGenerator filenameGenerator;
private CountyRoutingDestination routingDestination;
Expand All @@ -47,10 +46,8 @@ public class ApplicationStatusRepositoryTest extends AbstractRepositoryTest {

@BeforeEach
void setUp() {
countyMap = new CountyMap<>();
routingDestination = CountyRoutingDestination.builder()
.county(Olmsted)
.build();
CountyMap<CountyRoutingDestination> countyMap = new CountyMap<>();
routingDestination = new CountyRoutingDestination(Olmsted, "dpi", "email", "phoneNumber");
countyMap.setDefaultValue(routingDestination);
SnapExpeditedEligibilityDecider decider = mock(SnapExpeditedEligibilityDecider.class);
filenameGenerator = new FilenameGenerator(countyMap, decider);
Expand Down
Expand Up @@ -94,20 +94,14 @@ class FilenetWebServiceClientTest {
void setUp() {
when(clock.instant()).thenReturn(Instant.now());
when(clock.getZone()).thenReturn(ZoneId.of("UTC"));
mockWebServiceServer = MockWebServiceServer.createServer(webServiceTemplate);
olmsted = new CountyRoutingDestination();
olmsted.setCounty(Olmsted);
olmsted.setDhsProviderId("A000055800");

hennepin = new CountyRoutingDestination();
hennepin.setCounty(Hennepin);
hennepin.setDhsProviderId("A000027200");
olmsted = new CountyRoutingDestination(Olmsted, "A000055800", "email", "8004112222");
hennepin = new CountyRoutingDestination(Hennepin, "A000027200", "email", "8004112222");

mockWebServiceServer = MockWebServiceServer.createServer(webServiceTemplate);
String routerRequest = String.format("%s/%s", sftpUploadUrl, filenetIdd);
Mockito.when(restTemplate.getForObject(routerRequest, String.class)).thenReturn(routerResponse);
}

//TODO: namespaces change order. Need to figure out how to use a wildcard in the xpath assertions.
@Test
void sendsTheDocument() {
mockWebServiceServer.expect(connectionTo(url))
Expand Down Expand Up @@ -160,7 +154,7 @@ void sendsTheDocument() {
);

verify(applicationStatusRepository).createOrUpdate("someId", Document.CAF, olmsted.getName(),
DELIVERED,fileName);
DELIVERED, fileName);

mockWebServiceServer.verify();
}
Expand Down
@@ -1,6 +1,7 @@
package org.codeforamerica.shiba.output.documentfieldpreparers;

import static org.assertj.core.api.Assertions.assertThat;
import static org.codeforamerica.shiba.County.Hennepin;
import static org.codeforamerica.shiba.County.Olmsted;
import static org.codeforamerica.shiba.County.Other;
import static org.codeforamerica.shiba.output.Document.CAF;
Expand Down Expand Up @@ -61,11 +62,8 @@ public void setUp() {
countyInstructionsMapping.getCounties().put(Other, Map.of(
Recipient.CLIENT, "county-to-instructions.default-client",
Recipient.CASEWORKER, "county-to-instructions.default-caseworker"));
CountyRoutingDestination countyRoutingDestination = CountyRoutingDestination.builder()
.dhsProviderId("someDhsProviderId")
.email("someEmail")
.phoneNumber("555-123-4567")
.build();
CountyRoutingDestination countyRoutingDestination = new CountyRoutingDestination(
Hennepin, "someDhsProviderId", "someEmail", "555-123-4567");
when(routingDecisionService.getRoutingDestinations(any(ApplicationData.class),
any(Document.class)))
.thenReturn(List.of(countyRoutingDestination));
Expand Down Expand Up @@ -112,7 +110,7 @@ void shouldIncludeProgramsInputWithCombinedProgramSelection() {
DocumentFieldType.SINGLE_VALUE
));
}

@Test
void shouldIncludeTribalAffiliation() {
new TestApplicationDataBuilder(applicationData)
Expand Down

0 comments on commit c24fb5a

Please sign in to comment.