Pascal Schumacher
2016-04-29 20:19:20 +02:00
parent 5948d7055c
commit 4d27b00fa9
6 changed files with 86 additions and 1 deletions
+1
View File
@@ -65,6 +65,7 @@ Fakers
* Company
* Crypto
* DateAndTime
* Educator
* Finance
* Hacker
* Internet
@@ -0,0 +1,30 @@
package com.github.javafaker;
import com.github.javafaker.service.FakeValuesServiceInterface;
public class Educator {
private final FakeValuesServiceInterface fakeValuesService;
public Educator(FakeValuesServiceInterface fakeValuesService) {
this.fakeValuesService = fakeValuesService;
}
public String university() {
return fakeValuesService.fetchString("educator.name") + " " + fakeValuesService.fetchString("educator.tertiary.type");
}
public String course() {
return fakeValuesService.fetchString("educator.tertiary.course.type") + " "
+ fakeValuesService.fetchString("educator.tertiary.course.subject");
}
public String secondarySchool() {
return fakeValuesService.fetchString("educator.name") + " " + fakeValuesService.fetchString("educator.secondary");
}
public String campus() {
return fakeValuesService.fetchString("educator.name") + " Campus";
}
}
@@ -39,6 +39,7 @@ public class Faker implements Resolver {
private final Code code;
private final Finance finance;
private final DateAndTime dateAndTime;
private final Educator educator;
private final Superhero superhero;
private final Bool bool;
private final Team team;
@@ -59,7 +60,7 @@ public class Faker implements Resolver {
public Faker(Locale locale, Random random) {
this.randomService = new RandomService(random);
this.fakeValuesService = new FakeValuesService(locale, randomService);
FakeValuesService defaultEnglishFakeValuesService = new FakeValuesService(locale.ENGLISH, randomService);
FakeValuesService defaultEnglishFakeValuesService = new FakeValuesService(Locale.ENGLISH, randomService);
FakeValuesServiceInterface proxiedFakeValueService = createProxiedFakeValuesService(fakeValuesService,
defaultEnglishFakeValuesService);
@@ -82,6 +83,7 @@ public class Faker implements Resolver {
this.code = new Code(randomService);
this.finance = new Finance(proxiedFakeValueService, randomService);
this.dateAndTime = new DateAndTime(randomService);
this.educator = new Educator(proxiedFakeValueService);
this.superhero = new Superhero(this, proxiedFakeValueService);
this.team = new Team(this, proxiedFakeValueService);
this.bool = new Bool(randomService);
@@ -213,6 +215,10 @@ public class Faker implements Resolver {
return dateAndTime;
}
public Educator educator() {
return educator;
}
public Superhero superhero() {
return superhero;
}
+10
View File
@@ -226,6 +226,16 @@ en:
chuck_norris:
fact: ["All arrays Chuck Norris declares are of infinite size, because Chuck Norris knows no bounds.", "Chuck Norris doesn't have disk latency because the hard drive knows to hurry the hell up.", "All browsers support the hex definitions #chuck and #norris for the colors black and blue.", "Chuck Norris can't test for equality because he has no equal.", "Chuck Norris doesn't need garbage collection because he doesn't call .Dispose(), he calls .DropKick().", "Chuck Norris's first program was kill -9.", "Chuck Norris burst the dot com bubble.", "Chuck Norris writes code that optimizes itself.", "Chuck Norris can write infinite recursion functions... and have them return.", "Chuck Norris can solve the Towers of Hanoi in one move.", "The only pattern Chuck Norris knows is God Object.", "Chuck Norris finished World of Warcraft.", "Project managers never ask Chuck Norris for estimations... ever.", "Chuck Norris doesn't use web standards as the web will conform to him.", "\"It works on my machine\" always holds true for Chuck Norris.", "Whiteboards are white because Chuck Norris scared them that way.", "Chuck Norris's beard can type 140 wpm.", "Chuck Norris can unit test an entire application with a single assert.", "Chuck Norris doesn't bug hunt, as that signifies a probability of failure. He goes bug killing.", "Chuck Norris's keyboard doesn't have a Ctrl key because nothing controls Chuck Norris.", "Chuck Norris doesn't need a debugger, he just stares down the bug until the code confesses.", "Chuck Norris can access private methods.", "Chuck Norris can instantiate an abstract class.", "Chuck Norris doesn't need to know about class factory pattern. He can instantiate interfaces.", "The class object inherits from Chuck Norris.", "For Chuck Norris, NP-Hard = O(1).", "Chuck Norris knows the last digit of PI.", "Chuck Norris can divide by zero.", "Chuck Norris doesn't get compiler errors, the language changes itself to accommodate Chuck Norris.", "The programs that Chuck Norris writes don't have version numbers because he only writes them once. If a user reports a bug or has a feature request they don't live to see the sun set.", "Chuck Norris doesn't believe in floating point numbers because they can't be typed on his binary keyboard.", "Chuck Norris solved the Travelling Salesman problem in O(1) time.", "Chuck Norris never gets a syntax error. Instead, the language gets a DoesNotConformToChuck error.", "No statement can catch the ChuckNorrisException.", "Chuck Norris doesn't program with a keyboard. He stares the computer down until it does what he wants.", "Chuck Norris doesn't pair program.", "Chuck Norris can write multi-threaded applications with a single thread.", "There is no Esc key on Chuck Norris' keyboard, because no one escapes Chuck Norris.", "Chuck Norris doesn't delete files, he blows them away.", "Chuck Norris can binary search unsorted data.", "Chuck Norris breaks RSA 128-bit encrypted codes in milliseconds.", "Chuck Norris went out of an infinite loop.", "Chuck Norris can read all encrypted data, because nothing can hide from Chuck Norris.", "Chuck Norris hosting is 101% uptime guaranteed.", "When a bug sees Chuck Norris, it flees screaming in terror, and then immediately self-destructs to avoid being roundhouse-kicked.", "Chuck Norris rewrote the Google search engine from scratch.", "Chuck Norris doesn't need the cloud to scale his applications, he uses his laptop.", "Chuck Norris can access the DB from the UI.", "Chuck Norris' protocol design method has no status, requests or responses, only commands.", "Chuck Norris' programs occupy 150% of CPU, even when they are not executing.", "Chuck Norris can spawn threads that complete before they are started.", "Chuck Norris programs do not accept input.", "Chuck Norris doesn't need an OS.", "Chuck Norris can compile syntax errors.", "Chuck Norris compresses his files by doing a flying round house kick to the hard drive.", "Chuck Norris doesn't use a computer because a computer does everything slower than Chuck Norris.", "You don't disable the Chuck Norris plug-in, it disables you.", "Chuck Norris doesn't need a java compiler, he goes straight to .war", "Chuck Norris can use GOTO as much as he wants to. Telling him otherwise is considered harmful.", "There is nothing regular about Chuck Norris' expressions.", "Quantum cryptography does not work on Chuck Norris. When something is being observed by Chuck it stays in the same state until he's finished. ", "There is no need to try catching Chuck Norris' exceptions for recovery; every single throw he does is fatal.", "Chuck Norris' beard is immutable.", "Chuck Norris' preferred IDE is hexedit."]
educator:
name: ['Marblewald', 'Mallowtown', 'Brookville', 'Flowerlake', 'Falconholt', 'Ostbarrow', 'Lakeacre', 'Clearcourt', 'Ironston', 'Mallowpond', 'Iceborough', 'Icelyn', 'Brighthurst', 'Bluemeadow', 'Vertapple', 'Ironbarrow']
secondary: ['High School', 'Secodary College', 'High']
tertiary:
type: ['College', 'University', 'Technical College', 'TAFE']
course:
subject: ['Arts', 'Business', 'Education', 'Applied Science (Psychology)', 'Architectural Technology', 'Biological Science', 'Biomedical Science', 'Commerce', 'Communications', 'Creative Arts', 'Criminology', 'Design', 'Engineering', 'Forensic Science', 'Health Science', 'Information Systems', 'Computer Science', 'Law', 'Nursing', 'Medicine', 'Psychology', 'Teaching']
type: ['Associate Degree in', 'Bachelor of', 'Master of']
country:
name: [Afghanistan, Albania, Algeria, "American Samoa", Andorra, Angola, Anguilla, Antarctica, "Antigua and Barbuda", Argentina, Armenia, Aruba, Australia, Austria, Azerbaijan, Bahamas, Bahrain, Bangladesh, Barbados, Belarus, Belgium, Belize, Benin, Bermuda, Bhutan, Bolivia, "Bosnia and Herzegovina", Botswana, "Bouvet Island", Brazil, "British Antarctic Territory", "British Indian Ocean Territory", "British Virgin Islands", Brunei, Bulgaria, "Burkina Faso", Burundi, Cambodia, Cameroon, Canada, "Canton and Enderbury Islands", "Cape Verde", "Cayman Islands", "Central African Republic", Chad, Chile, China, "Christmas Island", "Cocos [Keeling] Islands", Colombia, Comoros, "Congo - Brazzaville", "Congo - Kinshasa", "Cook Islands", "Costa Rica", Croatia, Cuba, Cyprus, "Czech Republic", "Côte dIvoire", Denmark, Djibouti, Dominica, "Dominican Republic", "Dronning Maud Land", "East Germany", Ecuador, Egypt, "El Salvador", "Equatorial Guinea", Eritrea, Estonia, Ethiopia, "Falkland Islands", "Faroe Islands", Fiji, Finland, France, "French Guiana", "French Polynesia", "French Southern Territories", "French Southern and Antarctic Territories", Gabon, Gambia, Georgia, Germany, Ghana, Gibraltar, Greece, Greenland, Grenada, Guadeloupe, Guam, Guatemala, Guernsey, Guinea, Guinea-Bissau, Guyana, Haiti, "Heard Island and McDonald Islands", Honduras, "Hong Kong SAR China", Hungary, Iceland, India, Indonesia, Iran, Iraq, Ireland, "Isle of Man", Israel, Italy, Jamaica, Japan, Jersey, "Johnston Island", Jordan, Kazakhstan, Kenya, Kiribati, Kuwait, Kyrgyzstan, Laos, Latvia, Lebanon, Lesotho, Liberia, Libya, Liechtenstein, Lithuania, Luxembourg, "Macau SAR China", Macedonia, Madagascar, Malawi, Malaysia, Maldives, Mali, Malta, "Marshall Islands", Martinique, Mauritania, Mauritius, Mayotte, "Metropolitan France", Mexico, Micronesia, "Midway Islands", Moldova, Monaco, Mongolia, Montenegro, Montserrat, Morocco, Mozambique, "Myanmar [Burma]", Namibia, Nauru, Nepal, Netherlands, "Netherlands Antilles", "Neutral Zone", "New Caledonia", "New Zealand", Nicaragua, Niger, Nigeria, Niue, "Norfolk Island", "North Korea", "North Vietnam", "Northern Mariana Islands", Norway, Oman, "Pacific Islands Trust Territory", Pakistan, Palau, "Palestinian Territories", Panama, "Panama Canal Zone", "Papua New Guinea", Paraguay, "People's Democratic Republic of Yemen", Peru, Philippines, "Pitcairn Islands", Poland, Portugal, "Puerto Rico", Qatar, Romania, Russia, Rwanda, Réunion, "Saint Barthélemy", "Saint Helena", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", Samoa, "San Marino", "Saudi Arabia", Senegal, Serbia, "Serbia and Montenegro", Seychelles, "Sierra Leone", Singapore, Slovakia, Slovenia, "Solomon Islands", Somalia, "South Africa", "South Georgia and the South Sandwich Islands", "South Korea", Spain, "Sri Lanka", Sudan, Suriname, "Svalbard and Jan Mayen", Swaziland, Sweden, Switzerland, Syria, "São Tomé and Príncipe", Taiwan, Tajikistan, Tanzania, Thailand, Timor-Leste, Togo, Tokelau, Tonga, "Trinidad and Tobago", Tunisia, Turkey, Turkmenistan, "Turks and Caicos Islands", Tuvalu, "U.S. Minor Outlying Islands", "U.S. Miscellaneous Pacific Islands", "U.S. Virgin Islands", Uganda, Ukraine, "Union of Soviet Socialist Republics", "United Arab Emirates", "United Kingdom", "United States", "Unknown or Invalid Region", Uruguay, Uzbekistan, Vanuatu, "Vatican City", Venezuela, Vietnam, "Wake Island", "Wallis and Futuna", "Western Sahara", Yemen, Zambia, Zimbabwe, "Åland Islands"]
iso: ["AF", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BA", "BW", "BV", "BR", "BQ", "IO", "VG", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CT", "CV", "KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR", "HR", "CU", "CY", "CZ", "CI", "DK", "DJ", "DM", "DO", "NQ", "DD", "EC", "EG", "SV", "GQ", "ER", "EE", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "FQ", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "HM", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JT", "JO", "KZ", "KE", "KI", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MK", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "FX", "MX", "FM", "MI", "MD", "MC", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "AN", "NT", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "KP", "VD", "MP", "NO", "OM", "PC", "PK", "PW", "PS", "PA", "PZ", "PG", "PY", "YD", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RO", "RU", "RW", "RE", "BL", "SH", "KN", "LC", "MF", "PM", "VC", "WS", "SM", "SA", "SN", "RS", "CS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "GS", "KR", "ES", "LK", "SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "ST", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UM", "PU", "VI", "UG", "UA", "SU", "AE", "GB", "US", "ZZ", "UY", "UZ", "VU", "VA", "VE", "VN", "WK", "WF", "EH", "YE", "ZM", "ZW", "AX"]
@@ -0,0 +1,37 @@
package com.github.javafaker;
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Before;
import org.junit.Test;
public class EducatorTest {
private Faker faker;
@Before
public void before() {
faker = new Faker();
}
@Test
public void testUniversity() {
assertThat(faker.educator().university(), matchesRegularExpression("(\\w+\\.? ?){2,3}"));
}
@Test
public void testCourse() {
assertThat(faker.educator().course(), matchesRegularExpression("(\\w+\\.? ?){3,6}"));
}
@Test
public void testSecondarySchool() {
assertThat(faker.educator().secondarySchool(), matchesRegularExpression("(\\w+\\.? ?){2,3}"));
}
@Test
public void testCampus() {
assertThat(faker.educator().campus(), matchesRegularExpression("(\\w+\\.? ?){1,2}"));
}
}
@@ -77,6 +77,7 @@ public class FakerIT {
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.commerce());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.company());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.crypto());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.educator());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.internet());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.lorem());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.phoneNumber());