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

University name extension with places + testNoDuplications improvement #1394

Merged
merged 1 commit into from
Oct 20, 2024
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
4 changes: 4 additions & 0 deletions src/main/java/net/datafaker/providers/base/University.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ public String prefix() {
public String suffix() {
return resolve("university.suffix");
}

public String place() {
return resolve("university.place");
}
}
163 changes: 163 additions & 0 deletions src/main/resources/en/university.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,171 @@ en:
- "Institute"
- "College"
- "Academy"
place:
- "Aix-Marseille"
- "Akron"
- "Alabama"
- "Alaska"
- "Alberta"
- "Alexandria"
- "America"
- "Arizona"
- "Arkansas"
- "Beirut"
- "Berlin"
- "Bologna"
- "Bridgeport"
- "British Columbia"
- "Calcutta"
- "Calgary"
- "California"
- "Cambridge"
- "Central Florida"
- "Central Oklahoma"
- "Charleston"
- "Chicago"
- "Cincinnati"
- "Cologne"
- "Colorado"
- "Connecticut"
- "Dayton"
- "Delaware"
- "Delhi"
- "Denver"
- "Detroit Mercy"
- "Dublin"
- "Economics and Political Science"
- "Edinburgh"
- "Education"
- "Evansville"
- "Florence"
- "Florida"
- "Freiburg"
- "Geneva"
- "Georgia"
- "Glasgow"
- "Göttingen"
- "Grenoble"
- "Guadalajara"
- "Guelph"
- "Halle-Wittenberg"
- "Hartford"
- "Hawaii"
- "Heidelberg"
- "Houston"
- "Idaho"
- "Illinois"
- "Iowa"
- "Ireland"
- "Jerusalem"
- "Kansas"
- "Kentucky"
- "Königsberg"
- "Leiden"
- "Leipzig"
- "Leuven"
- "Liège"
- "Lille"
- "Lisbon"
- "London"
- "Louisiana at Monroe"
- "Louisville"
- "Madras"
- "Madrid"
- "Maine"
- "Manchester"
- "Manitoba"
- "Marburg"
- "Maryland"
- "Massachusetts"
- "Melbourne"
- "Memphis"
- "Mexico"
- "Miami"
- "Michigan"
- "Milan"
- "Mines"
- "Minnesota"
- "Mississippi"
- "Missouri"
- "Montana"
- "Montpellier"
- "Montreal"
- "Mumbai"
- "Munich"
- "Nantes"
- "Naples"
- "Nebraska"
- "Nevada"
- "New Brunswick"
- "New Hampshire"
- "New Jersey"
- "New Mexico"
- "New York"
- "Newfoundland"
- "Nisibis"
- "North Carolina"
- "North Dakota"
- "North Texas"
- "Northern Colorado"
- "Northern Iowa"
- "Notre Dame"
- "Oklahoma"
- "Oregon"
- "Oxford"
- "Padua"
- "Paris"
- "Pennsylvania"
- "Perugia"
- "Pittsburgh"
- "Poitiers"
- "Pretoria"
- "Rhode Island"
- "Richmond"
- "Rochester"
- "Rome"
- "Russia"
- "Salamanca"
- "Salerno"
- "San Francisco"
- "San Marcos Lima"
- "Saskatchewan"
- "Sevilla"
- "Siena"
- "South Carolina"
- "South Dakota"
- "Southern California"
- "Southern Mississippi"
- "St. Andrews"
- "Strasbourg"
- "Sydney"
- "Tennessee"
- "Texas"
- "the District Columbia"
- "the Holy Cross"
- "the Pacific"
- "the Punjab"
- "Tokyo"
- "Toledo"
- "Toronto"
- "Tübingen"
- "Tulsa"
- "Turin"
- "Utah"
- "Valladolid"
- "Vermont"
- "Victoria"
- "Vienna"
- "Virginia"
- "Washington"
- "Waterloo"
- "Western Ontario"
- "Wisconsin"
- "Würzburg"
- "Wyoming"
name:
- "#{Name.last_name} #{University.suffix}"
- "#{University.prefix} #{Name.last_name} #{University.suffix}"
- "#{University.prefix} #{Name.last_name} #{University.suffix} of #{University.place}"
- "#{University.prefix} #{Name.last_name}"
- "#{University.prefix} #{Address.state} #{University.suffix}"
13 changes: 10 additions & 3 deletions src/test/java/net/datafaker/providers/base/BaseFakerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,16 @@ void testNoDuplications(TestSpec testSpec) {

var terms = getBaseList(testSpec.key);

assertThat(new HashSet<>(terms))
.as("Check no duplications in " + testSpec.key)
.hasSameSizeAs(terms);
Set<String> uniques = new HashSet<>();
Set<String> duplicates = new HashSet<>();
for (String term : terms) {
if (!uniques.add(term)) {
duplicates.add(term);
}
}
assertThat(duplicates)
.as("Check no duplications in " + testSpec.key + " with terms " + terms)
.isEmpty();
}

protected Collection<TestSpec> providerListTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void testName() {
protected Collection<TestSpec> providerListTest() {
return List.of(TestSpec.of(university::prefix, "university.prefix"),
TestSpec.of(university::suffix, "university.suffix"),
TestSpec.of(university::degree, "university.degree"));
TestSpec.of(university::degree, "university.degree"),
TestSpec.of(university::place, "university.place"));
}
}