Skip to content

Commit

Permalink
Test invalid address exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mpbrown committed Jun 20, 2023
1 parent 9121ad7 commit 4fa2b6d
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gov.cdc.usds.simplereport.service;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
Expand All @@ -12,6 +13,7 @@
import com.smartystreets.api.us_street.Lookup;
import com.smartystreets.api.us_street.Metadata;
import gov.cdc.usds.simplereport.db.model.auxiliary.StreetAddress;
import gov.cdc.usds.simplereport.service.errors.InvalidAddressException;
import gov.cdc.usds.simplereport.service.model.TimezoneInfo;
import java.io.IOException;
import java.time.ZoneId;
Expand Down Expand Up @@ -92,6 +94,15 @@ void returnsCorrectTimeZoneInfoByLookup() {
assertEquals(results.get(0).getMetadata().obeysDst(), timeZoneInfo.obeysDaylightSavings);
}

@Test
void throwsInvalidAddressExceptionOnEmptyResults() {
ArrayList<Candidate> results = new ArrayList<>();
Lookup lookup = mock(Lookup.class);
when(lookup.getResult()).thenReturn(results);

assertThrows(InvalidAddressException.class, () -> s.getTimezoneInfoByLookup(lookup));
}

private Candidate getMockTimeZoneInfoResult() {
Metadata metadata = mock(Metadata.class);
when(metadata.getTimeZone()).thenReturn("Central");
Expand Down

0 comments on commit 4fa2b6d

Please sign in to comment.