Added ability to get county via zip (en-US locale only)

This commit is contained in:
Matthew Traughber 2018-11-08 14:58:02 -05:00
parent 6fc2a3b0a5
commit f73dd19086
3 changed files with 40969 additions and 1 deletions

View File

@ -35,7 +35,13 @@ public class Address {
return faker.bothify(faker.fakeValuesService().resolve("address.postcode", this,faker));
}
public String zipCodeByState(String stateAbbr) { return faker.fakeValuesService().resolve("address.postcode_by_state." + stateAbbr, this, faker); }
public String zipCodeByState(String stateAbbr) {
return faker.fakeValuesService().resolve("address.postcode_by_state." + stateAbbr, this, faker);
}
public String countyByZipCode(String postCode) {
return faker.fakeValuesService().resolve("address.county_by_postcode." + postCode, this, faker);
}
public String streetSuffix() {
return faker.fakeValuesService().resolve("address.street_suffix", this, faker);

File diff suppressed because one or more lines are too long

View File

@ -106,4 +106,10 @@ public class AddressTest extends AbstractFakerTest {
faker = new Faker(new Locale("en-US"));
assertThat(faker.address().zipCodeByState(faker.address().stateAbbr()), matchesRegularExpression("[0-9]{5}"));
}
@Test
public void testCountyByZipCode() {
faker = new Faker(new Locale("en-US"));
assertThat(faker.address().countyByZipCode(faker.address().zipCodeByState(faker.address().stateAbbr())), not(isEmptyOrNullString()));
}
}