├── src ├── main │ ├── resources │ │ ├── en │ │ │ ├── coin.yml │ │ │ ├── invoice.yml │ │ │ ├── markdown.yml │ │ │ ├── id_number.yml │ │ │ ├── gender.yml │ │ │ ├── color.yml │ │ │ ├── weather.yml │ │ │ ├── nato_phonetic_alphabet.yml │ │ │ ├── aqua_teen_hunger_force.yml │ │ │ ├── business.yml │ │ │ ├── house.yml │ │ │ ├── relationship.yml │ │ │ ├── university.yml │ │ │ ├── source.yml │ │ │ ├── movie.yml │ │ │ ├── artist.yml │ │ │ ├── parks_and_rec.yml │ │ │ ├── measurement.yml │ │ │ ├── barcode.yml │ │ │ ├── subscription.yml │ │ │ ├── electrical_components.yml │ │ │ ├── esport.yml │ │ │ ├── hacker.yml │ │ │ ├── educator.yml │ │ │ ├── marketing.yml │ │ │ ├── app.yml │ │ │ ├── lovecraft.yml │ │ │ ├── commerce.yml │ │ │ ├── dessert.yml │ │ │ ├── dragon_ball.yml │ │ │ ├── famous_last_words.yml │ │ │ ├── singular_siegler.yml │ │ │ ├── appliance.yml │ │ │ ├── half_life.yml │ │ │ ├── job.yml │ │ │ ├── ancient.yml │ │ │ ├── animal.yml │ │ │ ├── file.yml │ │ │ ├── team.yml │ │ │ ├── crypto_coin.yml │ │ │ ├── stranger_thing.yml │ │ │ ├── family_guy.yml │ │ │ ├── stargate.yml │ │ │ ├── grateful_dead.yml │ │ │ ├── star_trek.yml │ │ │ ├── greek_philosophers.yml │ │ │ ├── rock_band.yml │ │ │ └── football.yml │ │ ├── en.yml │ │ ├── sv-SE.yml │ │ ├── no-NO.yml │ │ ├── de-CH.yml │ │ ├── en-BORK.yml │ │ ├── en-GB.yml │ │ └── tr.yml │ └── java │ │ └── com │ │ └── github │ │ └── javafaker │ │ ├── service │ │ ├── FakeValuesInterface.java │ │ ├── FakeValuesGrouping.java │ │ └── FakerIDN.java │ │ ├── Bool.java │ │ ├── CreditCardType.java │ │ ├── Matz.java │ │ ├── Yoda.java │ │ ├── Hipster.java │ │ ├── RockBand.java │ │ ├── Artist.java │ │ ├── Robin.java │ │ ├── Animal.java │ │ ├── FunnyName.java │ │ ├── ChuckNorris.java │ │ ├── DragonBall.java │ │ ├── AquaTeenHungerForce.java │ │ ├── Coin.java │ │ ├── Zelda.java │ │ ├── Pokemon.java │ │ ├── PrincessBride.java │ │ ├── Stock.java │ │ ├── Avatar.java │ │ ├── LordOfTheRings.java │ │ ├── Currency.java │ │ ├── Mountain.java │ │ ├── Kaamelott.java │ │ ├── Barcode.java │ │ ├── EnglandFootBall.java │ │ ├── Friends.java │ │ ├── ProgrammingLanguage.java │ │ ├── TwinPeaks.java │ │ ├── RickAndMorty.java │ │ ├── BackToTheFuture.java │ │ ├── App.java │ │ ├── Ancient.java │ │ ├── Cat.java │ │ ├── Lebowski.java │ │ ├── University.java │ │ ├── Color.java │ │ ├── Overwatch.java │ │ ├── Business.java │ │ ├── Esports.java │ │ ├── Team.java │ │ ├── Book.java │ │ ├── Hobbit.java │ │ ├── GameOfThrones.java │ │ ├── StarCraft.java │ │ ├── Medical.java │ │ ├── Beer.java │ │ ├── HowIMetYourMother.java │ │ ├── Job.java │ │ ├── HarryPotter.java │ │ ├── Hacker.java │ │ ├── Buffy.java │ │ ├── Superhero.java │ │ ├── idnumbers │ │ └── EnIdNumber.java │ │ ├── Demographic.java │ │ ├── StarTrek.java │ │ ├── Music.java │ │ ├── Aviation.java │ │ ├── PhoneNumber.java │ │ ├── File.java │ │ ├── Witcher.java │ │ ├── Gender.java │ │ ├── LeagueOfLegends.java │ │ ├── Educator.java │ │ ├── Food.java │ │ ├── Crypto.java │ │ ├── SlackEmoji.java │ │ ├── IdNumber.java │ │ ├── Country.java │ │ ├── Dog.java │ │ ├── Nation.java │ │ ├── BojackHorseman.java │ │ ├── ElderScrolls.java │ │ ├── HitchhikersGuideToTheGalaxy.java │ │ ├── Basketball.java │ │ └── Space.java └── test │ ├── java │ └── com │ │ └── github │ │ └── javafaker │ │ ├── CoinTest.java │ │ ├── BoolTest.java │ │ ├── MatzTest.java │ │ ├── ArtistTest.java │ │ ├── AnimalTest.java │ │ ├── HipsterTest.java │ │ ├── RockBandTest.java │ │ ├── repeating │ │ ├── Repeat.java │ │ └── RepeatRule.java │ │ ├── ChuckNorrisTest.java │ │ ├── FunnyNameTest.java │ │ ├── DragonBallTest.java │ │ ├── RobinTest.java │ │ ├── AquaTeenHungerForceTest.java │ │ ├── YodaTest.java │ │ ├── StockTest.java │ │ ├── PokemonTest.java │ │ ├── ZeldaTest.java │ │ ├── AvatarTest.java │ │ ├── EnglandFootBallTest.java │ │ ├── CurrencyTest.java │ │ ├── KaamelottTest.java │ │ ├── MountainTest.java │ │ ├── LordOfTheRingsTest.java │ │ ├── PrincessBrideTest.java │ │ ├── ProgrammingLanguageTest.java │ │ ├── CatTest.java │ │ ├── BusinessTest.java │ │ ├── ColorTest.java │ │ ├── UniversityTest.java │ │ ├── AppTest.java │ │ ├── LebowskiTest.java │ │ ├── OverwatchTest.java │ │ ├── matchers │ │ ├── IsStringWithContents.java │ │ ├── IsANumber.java │ │ ├── IsANumberTest.java │ │ ├── IsStringWithContentsTest.java │ │ ├── MatchesRegularExpression.java │ │ └── CountOfCharactersMatcher.java │ │ ├── GenderTest.java │ │ ├── AviationTest.java │ │ ├── FriendsTest.java │ │ ├── AncientTest.java │ │ ├── TwinPeaksTest.java │ │ ├── MedicalTest.java │ │ ├── RickAndMortyTest.java │ │ ├── CryptoTest.java │ │ ├── BackToTheFutureTest.java │ │ ├── MusicTest.java │ │ ├── BookTest.java │ │ ├── HobbitTest.java │ │ ├── EducatorTest.java │ │ ├── AbstractFakerTest.java │ │ ├── HowIMetYourMotherTest.java │ │ ├── BuffyTest.java │ │ ├── ShakespeareTest.java │ │ ├── BarcodeTest.java │ │ ├── EsportsTest.java │ │ ├── JobTest.java │ │ ├── BeerTest.java │ │ ├── HackerTest.java │ │ ├── SuperheroTest.java │ │ ├── idnumbers │ │ └── SwedishIdNumberTest.java │ │ ├── DemographicTest.java │ │ ├── StarTrekTest.java │ │ ├── GameOfThronesTest.java │ │ ├── NationTest.java │ │ ├── TeamTest.java │ │ ├── WitcherTest.java │ │ ├── LeagueOfLegendsTest.java │ │ ├── FoodTest.java │ │ ├── HarryPotterTest.java │ │ ├── HitchhikersGuideToTheGalaxyTest.java │ │ ├── WeatherTest.java │ │ ├── IdNumberTest.java │ │ ├── DogTest.java │ │ ├── ElderScrollsTest.java │ │ ├── integration │ │ ├── Issue194SlashFormatRegexIT.java │ │ └── MostSpecificLocaleIT.java │ │ ├── StarCraftTest.java │ │ ├── service │ │ └── FakeValuesGroupingTest.java │ │ ├── DuneTest.java │ │ ├── CountryTest.java │ │ ├── FinanceTest.java │ │ ├── SlackEmojiTest.java │ │ └── PhoneNumberTest.java │ └── resources │ └── test.yml ├── .gitignore ├── .travis.yml ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── LICENSE └── CONTRIBUTING.md /src/main/resources/en/coin.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | coin: 4 | flip: ["Heads", "Tails"] 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | time: 3 | formats: 4 | us: "%m/%d/%Y %I:%M %p" 5 | am: "AM" 6 | pm: "PM" 7 | faker: 8 | separator: ' & ' -------------------------------------------------------------------------------- /src/main/resources/en/invoice.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | invoice: 4 | reference: 5 | check_digit_method: method_731 6 | pattern: '\d{3,19}#' -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .project 3 | .classpath 4 | .settings 5 | .idea/ 6 | *.iml 7 | .java-version 8 | /dependency-reduced-pom.xml 9 | META-INF/ 10 | bin/ 11 | -------------------------------------------------------------------------------- /src/main/resources/en/markdown.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | markdown: 4 | headers: ["#", "##", "###", "####", "#####", "######"] 5 | emphasis: ["_", "~", "*", "**"] 6 | -------------------------------------------------------------------------------- /src/main/resources/sv-SE.yml: -------------------------------------------------------------------------------- 1 | sv-SE: 2 | faker: 3 | 4 | id_number: 5 | valid: "#{IDNumber.valid_sv_se_ssn}" 6 | invalid: "#{IDNumber.invalid_sv_se_ssn}" 7 | 8 | -------------------------------------------------------------------------------- /src/main/resources/en/id_number.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | id_number: 4 | valid: "#{IDNumber.ssn_valid}" 5 | invalid: ['000-##-####', '###-00-####', '###-##-0000', '666-##-####', '9##-##-####'] 6 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/service/FakeValuesInterface.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.service; 2 | 3 | import java.util.Map; 4 | 5 | public interface FakeValuesInterface { 6 | Map get(String key); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/resources/no-NO.yml: -------------------------------------------------------------------------------- 1 | no-NO: 2 | faker: 3 | invoice: 4 | reference: 5 | # Source: https://www.nordea.com/Images/37-48872/Func_Spec_Credit_Advice.pdf 6 | check_digit_method: kidmod10 7 | pattern: '\d{24}#' 8 | -------------------------------------------------------------------------------- /src/main/resources/en/gender.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | gender: 4 | types: ["Female", "Male", "NonBinary", "Agender", "Genderfluid", "Genderqueer", "Bigender", "Polygender"] 5 | binary_types: ["Female", "Male"] 6 | short_binary_types: ["f", "m"] -------------------------------------------------------------------------------- /src/main/resources/en/color.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | color: 4 | name: [red, green, blue, yellow, purple, mint green, teal, white, black, orange, pink, grey, maroon, violet, turquoise, tan, sky blue, salmon, plum, orchid, olive, magenta, lime, ivory, indigo, gold, fuchsia, cyan, azure, lavender, silver] 5 | -------------------------------------------------------------------------------- /src/main/resources/en/weather.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | weather: 4 | description: ["Fine","Sunny","Clear skies","Cloudy periods","Partly cloudy","Mostly cloudy","Overcast","Showers","Rain","Drizzle","Thunderstorms","Thunder falls","Snow","Sleet","Hail"] 5 | temperature: 6 | celsius: °C 7 | fahrenheit: °F -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Bool.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Bool { 4 | private final Faker faker; 5 | 6 | protected Bool(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public boolean bool() { 11 | return faker.random().nextBoolean(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/CreditCardType.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public enum CreditCardType { 4 | VISA, 5 | MASTERCARD, 6 | DISCOVER, 7 | AMERICAN_EXPRESS, 8 | DINERS_CLUB, 9 | JCB, 10 | SWITCH, 11 | SOLO, 12 | DANKORT, 13 | FORBRUGSFORENINGEN, 14 | LASER 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Matz.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Matz { 4 | private final Faker faker; 5 | 6 | protected Matz(final Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String quote() { 11 | return faker.resolve("matz.quotes"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Yoda.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Yoda { 4 | private final Faker faker; 5 | 6 | protected Yoda(final Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String quote() { 11 | return faker.resolve("yoda.quotes"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Hipster.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Hipster { 4 | private final Faker faker; 5 | 6 | protected Hipster(final Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String word() { 11 | return faker.resolve("hipster.words"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/RockBand.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class RockBand { 4 | 5 | private final Faker faker; 6 | 7 | protected RockBand(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String name() { 12 | return faker.resolve("rock_band.name"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/resources/en/nato_phonetic_alphabet.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | nato_phonetic_alphabet: 4 | code_word: ["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India", "Juliett", "Kilo", "Lima", "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform", "Victor", "Whiskey", "X-ray", "Yankee", "Zulu"] 5 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Artist.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Artist { 4 | 5 | private final Faker faker; 6 | 7 | protected Artist(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String name() { 12 | return faker.fakeValuesService().fetchString("artist.names"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Robin.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Robin { 4 | private final Faker faker; 5 | 6 | protected Robin(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String quote() { 11 | return faker.fakeValuesService().resolve("robin.quotes", this, faker); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/resources/en/aqua_teen_hunger_force.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | aqua_teen_hunger_force: 4 | character: ["Carl Brutananadilewski", "Cybernetic Ghost of Christmas Past from the Future", "D.P", "Dr. Weird", "Dr. Wongburger", "Emory", "Err", "Frylock", "George Lowe", "Ignignokt", "Master Shake", "MC Pee Pants", "Meatwad", "Oglethorpe", "Skeeter", "Steve", "Turkatron"] 5 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Animal.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Animal { 4 | private final Faker faker; 5 | 6 | protected Animal(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String name() { 11 | return faker.fakeValuesService().resolve("creature.animal.name", this, faker); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/FunnyName.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class FunnyName { 4 | private final Faker faker; 5 | 6 | protected FunnyName(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String name() { 11 | return faker.fakeValuesService().resolve("funny_name.name", this, faker); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/ChuckNorris.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class ChuckNorris { 4 | private final Faker faker; 5 | 6 | protected ChuckNorris(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String fact() { 11 | return faker.fakeValuesService().resolve("chuck_norris.fact", this, faker); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/DragonBall.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class DragonBall { 4 | private final Faker faker; 5 | 6 | protected DragonBall(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.fakeValuesService().resolve("dragon_ball.characters", this, faker); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/AquaTeenHungerForce.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class AquaTeenHungerForce { 4 | 5 | private final Faker faker; 6 | 7 | protected AquaTeenHungerForce(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String character() { 12 | return faker.fakeValuesService().resolve("aqua_teen_hunger_force.character", this, faker); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Coin.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Coin { 4 | 5 | private final Faker faker; 6 | 7 | protected Coin(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | /** 12 | * @return coin side e.g. "Heads", "Tails". 13 | */ 14 | public String flip() { 15 | return faker.fakeValuesService().resolve("coin.flip", this, faker); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/en/business.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | business: 4 | credit_card_numbers: ['1234-2121-1221-1211', '1212-1221-1121-1234', '1211-1221-1234-2201', '1228-1221-1221-1431'] 5 | credit_card_types: ['visa', 'mastercard', 'american_express', 'discover', 'diners_club', 'jcb', 'switch', 'solo', 'dankort', 'maestro', 'forbrugsforeningen', 'laser'] 6 | credit_card_expiry_dates: ['2011-10-12', '2012-11-12', '2015-11-11', '2013-9-12'] 7 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Zelda.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Zelda { 4 | private final Faker faker; 5 | 6 | protected Zelda(final Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String game() { 11 | return faker.resolve("games.zelda.games"); 12 | } 13 | 14 | public String character() { 15 | return faker.resolve("games.zelda.characters"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Pokemon.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Pokemon { 4 | 5 | private final Faker faker; 6 | 7 | protected Pokemon(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String name() { 12 | return faker.resolve("games.pokemon.names"); 13 | } 14 | 15 | public String location() { 16 | return faker.resolve("games.pokemon.locations"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/CoinTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import static org.junit.Assert.assertThat; 4 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 5 | 6 | import org.junit.Test; 7 | 8 | public class CoinTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void coinFlip() { 12 | assertThat(faker.coin().flip(), matchesRegularExpression("\\w+")); 13 | } 14 | } -------------------------------------------------------------------------------- /src/main/resources/en/house.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | house: 4 | furniture: ["chair", armchair", "table", "dining table", "stool", "sofa", "couch", "bath", "bed", "cupboard", "drawers", "dresser", "floor lamp", "bedside table", "futon"] 5 | rooms: ["kitchen", "living room", "reception room", "bedroom", "master bedroom", "guest room", "drawing room", "conservatory", "porch", "hallway", "pantry", "sunroom", "bathroom", "ensuite bathroom", "cellar", "attic", "loft"] 6 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/BoolTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.hamcrest.Matchers.isOneOf; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class BoolTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void testBool() { 12 | for (int i = 0; i < 100; i++) { 13 | assertThat(faker.bool().bool(), isOneOf(true, false)); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/MatzTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.hamcrest.Matchers.isEmptyOrNullString; 6 | import static org.hamcrest.core.IsNot.not; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class MatzTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void quote() { 13 | assertThat(faker.matz().quote(), not(isEmptyOrNullString())); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/PrincessBride.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class PrincessBride { 4 | private final Faker faker; 5 | 6 | protected PrincessBride(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.resolve("princess_bride.characters"); 12 | } 13 | 14 | public String quote() { 15 | return faker.resolve("princess_bride.quotes"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/ArtistTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class ArtistTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void name() { 12 | assertThat(faker.artist().name(), matchesRegularExpression("(\\w+ ?){1,2}")); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/AnimalTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class AnimalTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void name() { 12 | assertThat(faker.animal().name(), matchesRegularExpression("[A-Za-z ]+")); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/en/relationship.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | relationship: 4 | familial: 5 | direct: ['Father', 'Mother', 'Sister', 'Brother'] 6 | extended: ['Grandfather', 'Grandmother', 'Uncle', 'Aunt', 'Cousin', 'Niece', 'Nephew', 'Grandson', 'Granddaughter'] 7 | in_law: ['Father-in-law', 'Mother-in-law', 'Sister-in-law', 'Brother-in-law'] 8 | spouse: ['Husband', 'Wife'] 9 | parent: ['Father', 'Mother'] 10 | sibling: ['Sister', 'Brother'] 11 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/HipsterTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class HipsterTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void word() { 12 | assertThat(faker.hipster().word(), matchesRegularExpression("^([\\w-+&']+ ?)+$")); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/RockBandTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class RockBandTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void name() { 12 | assertThat(faker.rockBand().name(), matchesRegularExpression("([\\w'/.,&]+ ?)+")); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/repeating/Repeat.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.repeating; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | import java.lang.annotation.Target; 6 | /** 7 | * Pulled from https://gist.github.com/fappel/8bcb2aea4b39ff9cfb6e 8 | */ 9 | @Retention( RetentionPolicy.RUNTIME ) 10 | @Target( { 11 | java.lang.annotation.ElementType.METHOD 12 | } ) 13 | public @interface Repeat { 14 | int times(); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Stock.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Stock { 4 | 5 | private final Faker faker; 6 | 7 | protected Stock(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String nsdqSymbol() { 12 | return faker.fakeValuesService().resolve("stock.symbol_nsdq", this, faker); 13 | } 14 | 15 | public String nyseSymbol() { 16 | return faker.fakeValuesService().resolve("stock.symbol_nyse", this, faker); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/en/university.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | university: 4 | prefix: [The, Northern, North, Western, West, Southern, South, Eastern, East] 5 | suffix: [University, Institute, College, Academy] 6 | name: 7 | - "#{Name.last_name} #{University.suffix}" 8 | - "#{University.prefix} #{Name.last_name} #{University.suffix}" 9 | - "#{University.prefix} #{Name.last_name}" 10 | - "#{University.prefix} #{Address.state} #{University.suffix}" 11 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/ChuckNorrisTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.hamcrest.Matchers.isEmptyOrNullString; 6 | import static org.hamcrest.Matchers.not; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class ChuckNorrisTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void testFact() { 13 | assertThat(faker.chuckNorris().fact(), not(isEmptyOrNullString())); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Avatar.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Avatar { 4 | private final Faker faker; 5 | private final String baseUrl; 6 | 7 | protected Avatar(Faker faker) { 8 | this.faker = faker; 9 | this.baseUrl = "https://s3.amazonaws.com/uifaces/faces/twitter/"; 10 | } 11 | 12 | public String image() { 13 | return baseUrl + faker.fakeValuesService().resolve("internet.avatar", this, faker); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/FunnyNameTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class FunnyNameTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void name() { 12 | assertThat(faker.funnyName().name(), matchesRegularExpression("^(\\w+\\.?\\s?'?-?)+$")); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/LordOfTheRings.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class LordOfTheRings { 4 | private final Faker faker; 5 | 6 | protected LordOfTheRings(final Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.resolve("lord_of_the_rings.characters"); 12 | } 13 | 14 | public String location() { 15 | return faker.resolve("lord_of_the_rings.locations"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Currency.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Currency { 4 | 5 | private final Faker faker; 6 | 7 | public Currency(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String name() { 12 | return faker.fakeValuesService().resolve("currency.name", this, faker); 13 | } 14 | 15 | public String code() { 16 | return faker.fakeValuesService().resolve("currency.code", this, faker); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Mountain.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Mountain { 4 | private final Faker faker; 5 | 6 | protected Mountain(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String name() { 11 | return faker.fakeValuesService().resolve("mountain.name", this, faker); 12 | } 13 | 14 | public String range() { 15 | return faker.fakeValuesService().resolve("mountain.range", this, faker); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/DragonBallTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class DragonBallTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void character() { 12 | assertThat(faker.dragonBall().character(), matchesRegularExpression("^(\\w+\\.?\\s?-?)+$")); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/RobinTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class RobinTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void quote() { 12 | assertThat(faker.robin().quote(), matchesRegularExpression("^(\\w+\\.?-?'?\\s?)+(\\(?)?(\\w+\\s?\\.?)+(\\))?$")); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Kaamelott.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Kaamelott { 4 | private final Faker faker; 5 | 6 | protected Kaamelott(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.fakeValuesService().resolve("kaamelott.characters", this, faker); 12 | } 13 | 14 | public String quote() { 15 | return faker.fakeValuesService().resolve("kaamelott.quotes", this, faker); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/en/source.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | source: 4 | hello_world: 5 | ruby: "puts 'Hello World!'" 6 | javascript: "alert('Hello World!');" 7 | print: 8 | ruby: "puts 'faker_string_to_print'" 9 | javascript: "console.log('faker_string_to_print');" 10 | print_1_to_10: 11 | ruby: " 12 | (1..10).each { |i| puts i }" 13 | javascript: " 14 | for (let i=0; i<10; i++) { 15 | console.log(i); 16 | }" 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | dist: xenial 3 | jdk: 4 | - openjdk10 5 | - oraclejdk11 6 | sudo: true 7 | script: mvn verify failsafe:integration-test failsafe:verify 8 | branches: 9 | except: 10 | - travis 11 | notifications: 12 | email: false 13 | after_success: 14 | - mvn clean cobertura:cobertura coveralls:report 15 | env: 16 | global: 17 | secure: GIdF3itH9owJXPEb/ri984853yRRIDeWbSZW7yMh6XOymGWAi0+3fGssBbHqjS/s3QgiDhnrKfDjF7UhHE1aeYCxgHM5QGOjfHUhOKevhUE4u0h4ysFS4wbh7zYODMzxdFpiKwdnNF+TvMctIReH5IVDu8gUxbNrcSXN6PQgvlM= 18 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/AquaTeenHungerForceTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class AquaTeenHungerForceTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void character() { 12 | assertThat(faker.aquaTeenHungerForce().character(), matchesRegularExpression("[A-Za-z .]+")); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/YodaTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.hamcrest.Matchers.isEmptyOrNullString; 6 | import static org.hamcrest.core.IsNot.not; 7 | import static org.junit.Assert.assertThat; 8 | 9 | /** 10 | * @author Luka Obradovic (luka@vast.com) 11 | */ 12 | public class YodaTest extends AbstractFakerTest { 13 | 14 | @Test 15 | public void quote() { 16 | assertThat(faker.yoda().quote(), not(isEmptyOrNullString())); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/resources/en/movie.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | movie: 4 | quote: ["Frankly, my dear, I don’t give a damn.", "I'm going to make him an offer he can't refuse.", "Toto, I've got a feeling we're not in Kansas anymore.", "Here's looking at you, kid.", "Go ahead, make my day.", "All right, Mr. DeMille, I'm ready for my closeup.", "May the Force be with you.", "Fasten your seatbelts. It's going to be a bumpy night.", "You talking to me?", "What we've got here is failure to communicate.", "I love the smell of napalm in the morning."] 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Barcode.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Barcode { 4 | 5 | private Faker faker; 6 | 7 | public Barcode(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String type() { 12 | return faker.resolve("barcode.types"); 13 | } 14 | 15 | public String data(){ 16 | return faker.resolve("barcode.datas"); 17 | } 18 | 19 | public String typeAndData(){ 20 | return faker.resolve("barcode.typeAndData"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/EnglandFootBall.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class EnglandFootBall { 4 | 5 | private final Faker faker; 6 | 7 | protected EnglandFootBall(final Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String league() { 12 | return faker.fakeValuesService().resolve("englandfootball.leagues",this,faker); 13 | } 14 | 15 | public String team() { 16 | return faker.fakeValuesService().resolve("englandfootball.teams",this,faker); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Friends.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Friends { 4 | private final Faker faker; 5 | 6 | protected Friends(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.resolve("friends.characters"); 12 | } 13 | 14 | public String location() { 15 | return faker.resolve("friends.locations"); 16 | } 17 | 18 | public String quote() { 19 | return faker.resolve("friends.quotes"); 20 | } 21 | } -------------------------------------------------------------------------------- /src/main/resources/en/artist.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | artist: 4 | names: ["Donatello", "Botticelli", "Michelangelo", "Raphael", "Titian", "Durer", "Caravaggio", "Rubens", "Bernini", "Rembrandt", "Pissarro", "Manet", "Degas", "Cezanne", "Monet", "Renoir", "Cassatt", "Gauguin", "Munch", "Klimt", "Matisse", "Picasso", "Kandinsky", "Chagall", "Seurat", "Magritte", "Escher", "Rothko", "Dali", "Kahlo", "Pollock", "Warhol", "Vettriano", "Da Vinci", "El Greco", "Winslow Homer", "Paul Klee", "Edward Hopper", "Diego Rivera", "Vincent", "Joan Miro", "Ansel Adams"] 5 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/ProgrammingLanguage.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class ProgrammingLanguage { 4 | 5 | private final Faker faker; 6 | 7 | public ProgrammingLanguage(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String name() { 12 | return faker.fakeValuesService().resolve("programming_language.name", this, faker); 13 | } 14 | 15 | public String creator() { 16 | return faker.fakeValuesService().resolve("programming_language.creator", this, faker); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/TwinPeaks.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class TwinPeaks { 4 | private final Faker faker; 5 | 6 | protected TwinPeaks(final Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.resolve("twin_peaks.characters"); 12 | } 13 | 14 | public String location() { 15 | return faker.resolve("twin_peaks.locations"); 16 | } 17 | 18 | public String quote() { 19 | return faker.resolve("twin_peaks.quotes"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Code to reproduce 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Versions:** 20 | - OS: [e.g. OSX] 21 | - JDK 22 | - Faker Version [e.g. 22] 23 | 24 | **Additional context** 25 | Add any other context about the problem here. 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 DiUS Computing 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/RickAndMorty.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class RickAndMorty { 4 | private final Faker faker; 5 | 6 | protected RickAndMorty(final Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.resolve("rick_and_morty.characters"); 12 | } 13 | 14 | public String location() { 15 | return faker.resolve("rick_and_morty.locations"); 16 | } 17 | 18 | public String quote() { 19 | return faker.resolve("rick_and_morty.quotes"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/en/parks_and_rec.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | parks_and_rec: 4 | characters: ["Leslie Knope","Ron Swanson","Ann Perkins","Mark Brendanawicz","Tom Haverford","April Ludgate","Andy Dwyer","Jerry Gergich", 5 | "Donna Meagle","Ben Wyatt","Chris Traeger","Craig Middlebrooks","Jean-Ralphio Saperstein","Li'l Sebastian","Mona-Lisa Saperstein","Orin", 6 | "Tammy 1","Tammy 2","Tammy Zero","Jeremy Jamm","Ethel Beavers","Crazy Ira","The Douche","Joan Callamezzo","Perd Hapley","Shauna Malwae-Tweep","Bobby Newport","Dr. Richard Nygard"] 7 | cities: ["Pawnee","Eagleton","Boraqua"] 8 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/BackToTheFuture.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class BackToTheFuture { 4 | private final Faker faker; 5 | 6 | protected BackToTheFuture(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.resolve("back_to_the_future.characters"); 12 | } 13 | 14 | public String date() { 15 | return faker.resolve("back_to_the_future.dates"); 16 | } 17 | 18 | public String quote() { 19 | return faker.resolve("back_to_the_future.quotes"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/en/measurement.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | measurement: 4 | height: ["inch", "foot"] 5 | length: ["yard", "foot", "mile"] 6 | volume: ["cup", "tablespoon", "teaspoon", "quart", "pint", "gallon", "fluid ounce"] 7 | weight: ["pound", "ounce", "ton"] 8 | metric_height: ["centimeter", "meter"] 9 | metric_length: ["millimeter", "centimeter", "decimeter", "meter", "dekameter", "hectometer", "kilometer"] 10 | metric_volume: ["milliliter", "liter"] 11 | metric_weight: ["milligram", "centigram", "decigram", "gram", "dekagram", "hectogram", "kilogram", "metric ton"] 12 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/App.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class App { 4 | private final Faker faker; 5 | 6 | protected App(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String name() { 11 | return faker.fakeValuesService().resolve("app.name", this, faker); 12 | } 13 | 14 | public String version() { 15 | return faker.numerify(faker.fakeValuesService().resolve("app.version", this, faker)); 16 | } 17 | 18 | public String author() { 19 | return faker.fakeValuesService().resolve("app.author", this, faker); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/StockTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import static org.hamcrest.Matchers.isEmptyOrNullString; 4 | import static org.hamcrest.Matchers.not; 5 | import static org.junit.Assert.assertThat; 6 | 7 | import org.junit.Test; 8 | 9 | public class StockTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void testNasdaq() { 13 | assertThat(faker.stock().nsdqSymbol(), not(isEmptyOrNullString())); 14 | } 15 | 16 | @Test 17 | public void testNYSE() { 18 | assertThat(faker.stock().nyseSymbol(), not(isEmptyOrNullString())); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Ancient.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Ancient { 4 | 5 | private final Faker faker; 6 | 7 | protected Ancient(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String god() { 12 | return faker.resolve("ancient.god"); 13 | } 14 | 15 | public String primordial() { 16 | return faker.resolve("ancient.primordial"); 17 | } 18 | 19 | public String titan() { 20 | return faker.resolve("ancient.titan"); 21 | } 22 | 23 | public String hero() { 24 | return faker.resolve("ancient.hero"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Cat.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Cat { 4 | 5 | private final Faker faker; 6 | 7 | protected Cat(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String name() { 12 | return faker.fakeValuesService().resolve("creature.cat.name", this, faker); 13 | } 14 | 15 | public String breed() { 16 | return faker.fakeValuesService().resolve("creature.cat.breed", this, faker); 17 | } 18 | 19 | public String registry() { 20 | return faker.fakeValuesService().resolve("creature.cat.registry", this, faker); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/PokemonTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import org.junit.Test; 7 | 8 | public class PokemonTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void name() { 12 | assertThat(faker.pokemon().name(), matchesRegularExpression("[\\w']+.?( \\w+)?")); 13 | } 14 | 15 | @Test 16 | public void location() { 17 | assertThat(faker.pokemon().location(), matchesRegularExpression("\\w+( \\w+)?( \\w+)?")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/ZeldaTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class ZeldaTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void game() { 12 | assertThat(faker.zelda().game(), matchesRegularExpression("[A-Za-z'\\- :]+")); 13 | } 14 | 15 | @Test 16 | public void character() { 17 | assertThat(faker.zelda().character(), matchesRegularExpression("(?U)([\\w'\\-.\\(\\)]+ ?)+")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Lebowski.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Lebowski { 4 | private final Faker faker; 5 | 6 | public Lebowski(final Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String actor() { 11 | return faker.fakeValuesService().resolve("lebowski.actors", this, faker); 12 | } 13 | 14 | public String character() { 15 | return faker.fakeValuesService().resolve("lebowski.characters", this, faker); 16 | } 17 | 18 | public String quote() { 19 | return faker.fakeValuesService().resolve("lebowski.quotes", this, faker); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/University.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class University { 4 | private final Faker faker; 5 | 6 | protected University(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String name() { 11 | return faker.fakeValuesService().resolve("university.name", this, faker); 12 | } 13 | 14 | public String prefix() { 15 | return faker.fakeValuesService().resolve("university.prefix", this, faker); 16 | } 17 | 18 | public String suffix() { 19 | return faker.fakeValuesService().resolve("university.suffix", this, faker); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Color.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Color { 4 | private final Faker faker; 5 | 6 | protected Color(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String name() { 11 | return faker.fakeValuesService().resolve("color.name", this, faker); 12 | } 13 | 14 | public String hex() { 15 | return hex(true); 16 | } 17 | 18 | public String hex(boolean includeHashSign) { 19 | String hexString = faker.random().hex(6); 20 | if(includeHashSign) 21 | return "#" + hexString; 22 | return hexString; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Overwatch.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Overwatch { 4 | private final Faker faker; 5 | 6 | protected Overwatch(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String hero() { 11 | return faker.fakeValuesService().resolve("games.overwatch.heroes", this, faker); 12 | } 13 | 14 | public String location() { 15 | return faker.fakeValuesService().resolve("games.overwatch.locations", this, faker); 16 | } 17 | 18 | public String quote() { 19 | return faker.fakeValuesService().resolve("games.overwatch.quotes", this, faker); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/AvatarTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import com.github.javafaker.repeating.Repeat; 4 | import org.junit.Test; 5 | 6 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class AvatarTest extends AbstractFakerTest { 10 | 11 | @Test 12 | @Repeat(times=10) 13 | public void testAvatar() { 14 | String avatar = faker.avatar().image(); 15 | assertThat(avatar, matchesRegularExpression("^https:\\/\\/s3.amazonaws\\.com\\/uifaces\\/faces\\/twitter\\/[a-zA-Z0-9_]+\\/128\\.jpg$")); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/en/barcode.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | barcode: 4 | types: ['UPC', 'UPC-A', 'UPC-E', 'Code128', 'Code39','Code93', 'EAN', 'EAN-13', 'EAN-8', 'JAN-13', 'ISBN', 'ISSN', 5 | 'ITF', 'Codabar', 'Ames Code', 'NW-7', 'Monarch', 'Code 2 of 7', 'Rationalized', 'ANSI/AIM BC3-1995', 'USD-4', 6 | 'GS1 Databar', 'MSI Plessey', 'UCC'] 7 | datas: ['12345678', '09876543', '05755069', '15008444', '69503172', '05082366', '29951287', '37457367', 8 | '87164772', '17217165', '56462327', '35186895', '16957481', '68124245', '28664694', '12372549', 9 | '02527355'] 10 | typeAndData: "#{barcode.types} #{barcode.datas}" -------------------------------------------------------------------------------- /src/main/resources/en/subscription.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | subscription: 4 | plans: ["Free Trial", "Basic", "Starter", "Essential", "Student", "Bronze", "Standard", "Silver", "Gold", "Platinum", "Professional", "Business", "Diamond", "Premium"] 5 | statuses: ["Active", "Idle", "Blocked", "Pending"] 6 | payment_methods: ["Credit card", "Debit card", "Paypal", "Cash", "Money transfer", "Bitcoins", "Cheque", "Apple Pay", "Google Pay", "WeChat Pay", "Alipay", "Visa checkout"] 7 | subscription_terms: ["Daily", "Weekly", "Monthly", "Annual", "Biennal", "Triennal", "Quinquennal", "Lifetime"] 8 | payment_terms: ["Payment in advance", "Monthly", "Annual", "Full subscription"] 9 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/EnglandFootBallTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | 4 | import org.junit.Test; 5 | 6 | 7 | import static org.hamcrest.Matchers.*; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class EnglandFootBallTest extends AbstractFakerTest{ 11 | 12 | 13 | 14 | @Test 15 | public void testLeague() { 16 | String league = faker.englandfootball().league(); 17 | assertThat(league, not(isEmptyOrNullString())); 18 | 19 | } 20 | 21 | @Test 22 | public void testTeam() { 23 | String team = faker.englandfootball().team(); 24 | assertThat(team, not(isEmptyOrNullString())); 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/CurrencyTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import org.junit.Test; 7 | 8 | public class CurrencyTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void testName() { 12 | assertThat(faker.currency().name(), matchesRegularExpression("[\\w\\'\\.\\-\\(\\) ]+")); 13 | } 14 | 15 | @Test 16 | public void testCode() { 17 | final Currency currency = faker.currency(); 18 | assertThat(currency.code(), matchesRegularExpression("[A-Z]{3}")); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/KaamelottTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import org.junit.Test; 7 | 8 | public class KaamelottTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void testCharacter() { 12 | assertThat(faker.kaamelott().character(), matchesRegularExpression("[A-Za-z' -ÇÉàçêèéïîüùú]+")); 13 | } 14 | 15 | @Test 16 | public void testQuote() { 17 | assertThat(faker.kaamelott().quote(), matchesRegularExpression("[-A-Za-z0-9 —ÇÉàçêèéïîüùú;:…\\?\\!\\.’‘'”“,\\[\\]]+")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Business.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Business { 4 | 5 | private final Faker faker; 6 | 7 | protected Business(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String creditCardNumber() { 12 | return faker.fakeValuesService().resolve("business.credit_card_numbers", this, faker); 13 | } 14 | 15 | public String creditCardType() { 16 | return faker.fakeValuesService().resolve("business.credit_card_types", this, faker); 17 | } 18 | 19 | public String creditCardExpiry() { 20 | return faker.fakeValuesService().resolve("business.credit_card_expiry_dates", this, faker); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/resources/test.yml: -------------------------------------------------------------------------------- 1 | test: 2 | faker: 3 | code: 4 | isbn_gs1: ["333","444"] 5 | isbn_group: ["9971"] 6 | isbn_registrant: ["#{numerify '#-####'}"] 7 | property: 8 | dummy: [x, y, z] 9 | simple: "hello" 10 | simpleResolution: "#{hello}" 11 | advancedResolution: "#{Superhero.name}" 12 | regexify1: "#{regexify '[45]{2}'}" 13 | regexify_cell: "#{regexify '4[57]9'}" 14 | regexify_slash_format: /[45]{2}/ 15 | bothify_2: "#{bothify '??##','true'}" 16 | sameResolution: "#{hello} #{hello}" 17 | multipleResolution: "#{hello} #{Superhero.descriptor}" 18 | resolutionWithList: 19 | - "#{hello}" 20 | - "#{hello2}" 21 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/MountainTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.hamcrest.Matchers.isEmptyOrNullString; 6 | import static org.hamcrest.Matchers.not; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class MountainTest extends AbstractFakerTest { 10 | @Test 11 | public void testMountainName() { 12 | String mountainName = faker.mountain().name(); 13 | assertThat(mountainName, not(isEmptyOrNullString())); 14 | } 15 | 16 | @Test 17 | public void testMountainLeague() { 18 | String mountainLeague = faker.mountain().range(); 19 | assertThat(mountainLeague, not(isEmptyOrNullString())); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Esports.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Esports { 4 | private final Faker faker; 5 | 6 | protected Esports(final Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String player() { 11 | return faker.resolve("esport.players"); 12 | } 13 | 14 | public String team() { 15 | return faker.resolve("esport.teams"); 16 | } 17 | 18 | public String event() { 19 | return faker.resolve("esport.events"); 20 | } 21 | 22 | public String league() { 23 | return faker.resolve("esport.leagues"); 24 | } 25 | 26 | public String game() { 27 | return faker.resolve("esport.games"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Team.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Team { 4 | private final Faker faker; 5 | 6 | protected Team(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String name() { 11 | return faker.fakeValuesService().resolve("team.name", this, faker); 12 | } 13 | 14 | public String creature() { 15 | return faker.fakeValuesService().resolve("team.creature", this, faker); 16 | } 17 | 18 | public String state() { 19 | return faker.fakeValuesService().resolve("address.state", this, faker); 20 | } 21 | 22 | public String sport() { 23 | return faker.fakeValuesService().resolve("team.sport", this, faker); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/LordOfTheRingsTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | /** 9 | * @author Luka Obradovic (luka@vast.com) 10 | */ 11 | public class LordOfTheRingsTest extends AbstractFakerTest { 12 | 13 | @Test 14 | public void character() { 15 | assertThat(faker.lordOfTheRings().character(), matchesRegularExpression("(?U)([\\w ]+ ?)+")); 16 | } 17 | 18 | @Test 19 | public void location() { 20 | assertThat(faker.lordOfTheRings().location(), matchesRegularExpression("(?U)([\\w'\\- ]+ ?)+")); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/PrincessBrideTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.hamcrest.Matchers.isEmptyOrNullString; 7 | import static org.hamcrest.core.IsNot.not; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class PrincessBrideTest extends AbstractFakerTest { 11 | @Test 12 | public void character() { 13 | assertThat(faker.princessBride().character(), matchesRegularExpression("[A-Za-z .-]+")); 14 | } 15 | 16 | @Test 17 | public void quote() { 18 | assertThat(faker.princessBride().quote(), not(isEmptyOrNullString())); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Book.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Book { 4 | private final Faker faker; 5 | 6 | protected Book(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String author() { 11 | return faker.fakeValuesService().resolve("book.author", this, faker); 12 | } 13 | 14 | public String title() { 15 | return faker.fakeValuesService().resolve("book.title", this, faker); 16 | } 17 | 18 | public String publisher() { 19 | return faker.fakeValuesService().resolve("book.publisher", this, faker); 20 | } 21 | 22 | public String genre() { 23 | return faker.fakeValuesService().resolve("book.genre", this, faker); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/ProgrammingLanguageTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import com.github.javafaker.repeating.Repeat; 4 | import org.junit.Test; 5 | 6 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class ProgrammingLanguageTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void name() { 13 | assertThat(faker.programmingLanguage().name(), matchesRegularExpression("[A-Za-z0-9 :,.+*()#/\\–\\-@πéöü'′!]+")); 14 | } 15 | 16 | @Test 17 | public void creator() { 18 | assertThat(faker.programmingLanguage().creator(), matchesRegularExpression("[A-Za-z .,\\-]+")); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/en/electrical_components.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | electrical_components: 4 | active: ["Diode", "LED", "Rectifier", "Transistor", "JFET", "MOSFET", "Integrated Circuit", "LCD", "Cathode Ray Tube", "Vacuum Tube", "Battery", "Fuel Cell", "Power Supply"] 5 | passive: ["Resistor", "Potentiometer", "Trim Pot", "Varistor", "Capacitor", "Varicap Diode", "Inductor", "Transformer", "Generator", "Motor", "Solenoid", "Magnetic Amplifier", "Speaker", "Motion Sensor", "Accelerometer", "Thermocouple", "Antenna", "Oscillator", "Breadboard"] 6 | electromechanical: ["Piezoelectric device", "crystal", "Ultrasonic Motor", "Terminal", "Socket", "Power Cord", "Toggle Switch", "Slide Switch", "DIP Switch", "Footswitch", "Keypad", "Circuit Breaker", "Fuse", "Printed Circuit Board"] -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/CatTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class CatTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void name() { 12 | assertThat(faker.cat().name(), matchesRegularExpression("[A-Za-z'() 0-9-]+")); 13 | } 14 | 15 | @Test 16 | public void breed() { 17 | assertThat(faker.cat().breed(), matchesRegularExpression("[A-Za-z'() 0-9-,]+")); 18 | } 19 | 20 | @Test 21 | public void registry() { 22 | assertThat(faker.cat().registry(), matchesRegularExpression("[A-Za-zé'() 0-9-]+")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Hobbit.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Hobbit { 4 | private final Faker faker; 5 | 6 | protected Hobbit(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.fakeValuesService().resolve("hobbit.character", this, faker); 12 | } 13 | 14 | public String thorinsCompany() { 15 | return faker.fakeValuesService().resolve("hobbit.thorins_company", this, faker); 16 | } 17 | 18 | public String quote() { 19 | return faker.fakeValuesService().resolve("hobbit.quote", this, faker); 20 | } 21 | 22 | public String location() { 23 | return faker.fakeValuesService().resolve("hobbit.location", this, faker); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/BusinessTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.IsStringWithContents.isStringWithContents; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class BusinessTest extends AbstractFakerTest { 9 | @Test 10 | public void creditCardNumber() { 11 | assertThat(faker.business().creditCardNumber(), isStringWithContents()); 12 | } 13 | 14 | @Test 15 | public void creditCardType() { 16 | assertThat(faker.business().creditCardType(), isStringWithContents()); 17 | } 18 | 19 | @Test 20 | public void creditCardExpiry() { 21 | assertThat(faker.business().creditCardExpiry(), isStringWithContents()); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/ColorTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class ColorTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void testName() { 12 | assertThat(faker.color().name(), matchesRegularExpression("(\\w+ ?){1,2}")); 13 | } 14 | 15 | @Test 16 | public void testHex() { 17 | assertThat(faker.color().hex(), matchesRegularExpression("^#[0-9A-F]{6}$")); 18 | } 19 | 20 | @Test 21 | public void testHexNoHashSign() { 22 | assertThat(faker.color().hex(false), matchesRegularExpression("^[0-9A-F]{6}$")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/resources/en/esport.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | esport: 4 | players: ["Froggen", "Dendi", "Surefour", "Seagull", "xPeke", "shroud", "KennyS", "pasha", "RamboRay", "Crimsix", "ACE", "Grubby", "f0rest", "cArn", "Flash", "Faker", "Boxer", "Miracle", "Silvername"] 5 | teams: ["Dignitas", "OpTic Gaming", "FaZe", "iBUYPOWER", "Evil Geniuses", "Ninjas in Pijamas", "Natus Vincere", "Team SoloMid", "Cloud9", "Fnatic", "CLG", "EnVyUs", "Virtus.Pro", "Team Secret"] 6 | events: ["ESL Cologne", "MLG Meadowlands", "GFinity London", "Worlds", "IEM Championship", "League All Stars", "International"] 7 | leagues: ["ESL", "IEM", "MLG", "GFinity", "Starladder"] 8 | games: ["CS:GO", "League of Legends", "Overwatch", "StarCraft II", "Dota 2", "Super Smash Bros. Melee", "Hearthstone", "PUBG"] 9 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/UniversityTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class UniversityTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void testName() { 12 | assertThat(faker.university().name(), matchesRegularExpression("[A-Za-z'() ]+")); 13 | } 14 | 15 | @Test 16 | public void testPrefix() { 17 | assertThat(faker.university().prefix(), matchesRegularExpression("\\w+")); 18 | } 19 | 20 | @Test 21 | public void testSuffix() { 22 | assertThat(faker.university().suffix(), matchesRegularExpression("\\w+")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class AppTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void testName() { 12 | assertThat(faker.app().name(), matchesRegularExpression("([\\w-]+ ?)+")); 13 | } 14 | 15 | @Test 16 | public void testVersion() { 17 | assertThat(faker.app().version(), matchesRegularExpression("\\d\\.(\\d){1,2}(\\.\\d)?")); 18 | } 19 | 20 | @Test 21 | public void testAuthor() { 22 | assertThat(faker.app().author(), matchesRegularExpression("([\\w']+[-&,\\.]? ?){2,9}")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/GameOfThrones.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class GameOfThrones { 4 | 5 | private final Faker faker; 6 | 7 | protected GameOfThrones(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String character() { 12 | return faker.resolve("game_of_thrones.characters"); 13 | } 14 | 15 | public String house() { 16 | return faker.resolve("game_of_thrones.houses"); 17 | } 18 | 19 | public String city() { 20 | return faker.resolve("game_of_thrones.cities"); 21 | } 22 | 23 | public String dragon() { 24 | return faker.resolve("game_of_thrones.dragons"); 25 | } 26 | 27 | public String quote() { 28 | return faker.resolve("game_of_thrones.quotes"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/LebowskiTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class LebowskiTest extends AbstractFakerTest { 9 | @Test 10 | public void actor() { 11 | assertThat(faker.lebowski().actor(), matchesRegularExpression("^([\\w]+ ?){1,3}$")); 12 | } 13 | 14 | @Test 15 | public void character() { 16 | assertThat(faker.lebowski().character(), matchesRegularExpression("^([\\w]+ ?){1,3}$")); 17 | } 18 | 19 | @Test 20 | public void quote() { 21 | assertThat(faker.lebowski().quote(), matchesRegularExpression("^([\\w.,!?'-]+ ?)+$")); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/StarCraft.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class StarCraft { 4 | 5 | private final Faker faker; 6 | 7 | protected StarCraft(final Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String unit() { 12 | return faker.fakeValuesService().resolve("starcraft.units", this, faker); 13 | } 14 | 15 | public String building() { 16 | return faker.fakeValuesService().resolve("starcraft.buildings", this, faker); 17 | } 18 | 19 | public String character() { 20 | return faker.fakeValuesService().resolve("starcraft.characters", this, faker); 21 | } 22 | 23 | public String planet() { 24 | return faker.fakeValuesService().resolve("starcraft.planets", this, faker); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Medical.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Medical { 4 | 5 | private final Faker faker; 6 | 7 | protected Medical(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String medicineName() { 12 | return faker.fakeValuesService().resolve("medical.medicine_name", this, faker); 13 | } 14 | 15 | public String diseaseName() { 16 | return faker.fakeValuesService().resolve("medical.disease_name", this, faker); 17 | } 18 | 19 | public String hospitalName() { 20 | return faker.fakeValuesService().resolve("medical.hospital_name", this, faker); 21 | } 22 | 23 | public String symptoms() { 24 | return faker.fakeValuesService().resolve("medical.symptoms", this, faker); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/OverwatchTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertFalse; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class OverwatchTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void hero() { 13 | assertThat(faker.overwatch().hero(), matchesRegularExpression("^(\\w+\\.?\\s?)+$")); 14 | } 15 | 16 | @Test 17 | public void location() { 18 | assertThat(faker.overwatch().location(), matchesRegularExpression("^(.+'?:?\\s?)+$")); 19 | } 20 | 21 | @Test 22 | public void quote() { 23 | assertFalse(faker.overwatch().quote().isEmpty()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/matchers/IsStringWithContents.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.matchers; 2 | 3 | import org.hamcrest.Description; 4 | import org.hamcrest.Factory; 5 | import org.hamcrest.Matcher; 6 | import org.hamcrest.TypeSafeMatcher; 7 | 8 | public class IsStringWithContents extends TypeSafeMatcher { 9 | 10 | @Override 11 | protected boolean matchesSafely(String s) { 12 | if (s == null) return false; 13 | 14 | return s.trim().length() > 0; 15 | } 16 | 17 | 18 | @Override 19 | public void describeTo(Description description) { 20 | description.appendText("is string with contents"); 21 | } 22 | 23 | @Factory 24 | public static Matcher isStringWithContents() { 25 | return new IsStringWithContents(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/GenderTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class GenderTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void types() { 12 | assertThat(faker.gender().types(), matchesRegularExpression("(\\w+ ?){1,2}")); 13 | } 14 | 15 | @Test 16 | public void binaryTypes() { 17 | assertThat(faker.gender().binaryTypes(), matchesRegularExpression("[A-Za-z ]+")); 18 | } 19 | 20 | @Test 21 | public void shortBinaryTypes() { 22 | assertThat(faker.gender().shortBinaryTypes(), matchesRegularExpression("f|m")); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/resources/de-CH.yml: -------------------------------------------------------------------------------- 1 | de-CH: 2 | faker: 3 | address: 4 | country_code: [CH, CH, CH, DE, AT, US, LI, US, HK, VN] 5 | postcode: ['1###', '2###', '3###', '4###', '5###', '6###', '7###', '8###', '9###'] 6 | default_country: [Schweiz] 7 | 8 | company: 9 | suffix: [AG, GmbH, und Söhne, und Partner, "& Co.", Gruppe, LLC, Inc.] 10 | name: 11 | - "#{Name.last_name} #{suffix}" 12 | - "#{Name.last_name}-#{Name.last_name}" 13 | - "#{Name.last_name}, #{Name.last_name} und #{Name.last_name}" 14 | 15 | internet: 16 | domain_suffix: [com, net, biz, ch, de, li, at, ch, ch] 17 | 18 | phone_number: 19 | formats: ['0800 ### ###', '0800 ## ## ##', '0## ### ## ##', '0## ### ## ##', '+41 ## ### ## ##', '0900 ### ###', '076 ### ## ##', '+4178 ### ## ##', '0041 79 ### ## ##'] 20 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/AviationTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.IsStringWithContents.isStringWithContents; 6 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class AviationTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void airport() { 13 | assertThat(faker.aviation().airport(), matchesRegularExpression("\\w{4}")); 14 | } 15 | 16 | @Test 17 | public void aircraft() { 18 | assertThat(faker.aviation().aircraft(), isStringWithContents()); 19 | } 20 | 21 | @Test 22 | public void metar() { 23 | assertThat(faker.aviation().METAR(), isStringWithContents()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/matchers/IsANumber.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.matchers; 2 | 3 | import org.hamcrest.Description; 4 | import org.hamcrest.Factory; 5 | import org.hamcrest.Matcher; 6 | import org.hamcrest.TypeSafeMatcher; 7 | 8 | public class IsANumber extends TypeSafeMatcher { 9 | 10 | @Override 11 | protected boolean matchesSafely(String item) { 12 | try { 13 | new Double(item); 14 | } catch (NumberFormatException nfe) { 15 | return false; 16 | } 17 | return true; 18 | } 19 | 20 | @Override 21 | public void describeTo(Description description) { 22 | description.appendText("is a number"); 23 | } 24 | 25 | @Factory 26 | public static Matcher isANumber() { 27 | return new IsANumber(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Beer.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Beer { 4 | private final Faker faker; 5 | 6 | protected Beer(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String name() { 11 | return faker.fakeValuesService().resolve("beer.name", this, faker); 12 | } 13 | 14 | public String style() { 15 | return faker.fakeValuesService().resolve("beer.style", this, faker); 16 | } 17 | 18 | public String hop() { 19 | return faker.fakeValuesService().resolve("beer.hop", this, faker); 20 | } 21 | 22 | public String yeast() { 23 | return faker.fakeValuesService().resolve("beer.yeast", this, faker); 24 | } 25 | 26 | public String malt() { 27 | return faker.fakeValuesService().resolve("beer.malt", this, faker); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/HowIMetYourMother.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class HowIMetYourMother { 4 | private final Faker faker; 5 | 6 | protected HowIMetYourMother(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.fakeValuesService().resolve("how_i_met_your_mother.character", this, faker); 12 | } 13 | 14 | public String catchPhrase() { 15 | return faker.fakeValuesService().resolve("how_i_met_your_mother.catch_phrase", this, faker); 16 | } 17 | 18 | public String highFive() { 19 | return faker.fakeValuesService().resolve("how_i_met_your_mother.high_five", this, faker); 20 | } 21 | 22 | public String quote() { 23 | return faker.fakeValuesService().resolve("how_i_met_your_mother.quote", this, faker); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/FriendsTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.hamcrest.Matchers.isEmptyOrNullString; 7 | import static org.hamcrest.core.IsNot.not; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class FriendsTest extends AbstractFakerTest { 11 | 12 | @Test 13 | public void character() { 14 | assertThat(faker.friends().character(), matchesRegularExpression("[A-Za-z .,]+")); 15 | } 16 | 17 | @Test 18 | public void location() { 19 | assertThat(faker.friends().location(), matchesRegularExpression("[\\w.', ]+")); 20 | } 21 | 22 | @Test 23 | public void quote() { 24 | assertThat(faker.friends().quote(), not(isEmptyOrNullString())); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/matchers/IsANumberTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.matchers; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.hamcrest.MatcherAssert.assertThat; 6 | import static org.hamcrest.core.Is.is; 7 | 8 | public class IsANumberTest { 9 | 10 | @Test 11 | public void testNumberShouldBeANumber() { 12 | assertThat(new IsANumber().matchesSafely("34"), is(true)); 13 | } 14 | 15 | @Test 16 | public void testBlankIsNotANumber() { 17 | assertThat(new IsANumber().matchesSafely(""), is(false)); 18 | } 19 | 20 | @Test 21 | public void testOtherCharsIsNotANumber() { 22 | assertThat(new IsANumber().matchesSafely("df3DF-="), is(false)); 23 | } 24 | 25 | @Test 26 | public void testEmptyStringIsNotANumber() { 27 | assertThat(new IsANumber().matchesSafely(" "), is(false)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Job.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Job { 4 | 5 | private final Faker faker; 6 | 7 | public Job(final Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String field() { 12 | return faker.fakeValuesService().resolve("job.field", this, faker); 13 | } 14 | 15 | public String seniority() { 16 | return faker.fakeValuesService().resolve("job.seniority", this, faker); 17 | } 18 | 19 | public String position() { 20 | return faker.fakeValuesService().resolve("job.position", this, faker); 21 | } 22 | 23 | public String keySkills() { 24 | return faker.fakeValuesService().resolve("job.key_skills", this, faker); 25 | } 26 | 27 | public String title() { 28 | return faker.fakeValuesService().resolve("job.title", this, faker); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/HarryPotter.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class HarryPotter { 4 | private final Faker faker; 5 | 6 | protected HarryPotter(final Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.resolve("harry_potter.characters"); 12 | } 13 | 14 | public String location() { 15 | return faker.resolve("harry_potter.locations"); 16 | } 17 | 18 | public String quote() { 19 | return faker.resolve("harry_potter.quotes"); 20 | } 21 | 22 | public String book() { 23 | return faker.resolve("harry_potter.books"); 24 | } 25 | 26 | public String house() { 27 | return faker.resolve("harry_potter.houses"); 28 | } 29 | 30 | public String spell() { 31 | return faker.resolve("harry_potter.spells"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Hacker.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Hacker { 4 | private final Faker faker; 5 | 6 | protected Hacker(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String abbreviation() { 11 | return faker.fakeValuesService().resolve("hacker.abbreviation", this, faker); 12 | } 13 | 14 | public String adjective() { 15 | return faker.fakeValuesService().resolve("hacker.adjective", this, faker); 16 | } 17 | 18 | public String noun() { 19 | return faker.fakeValuesService().resolve("hacker.noun", this, faker); 20 | } 21 | 22 | public String verb() { 23 | return faker.fakeValuesService().resolve("hacker.verb", this, faker); 24 | } 25 | 26 | public String ingverb() { 27 | return faker.fakeValuesService().resolve("hacker.ingverb", this, faker); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/en-BORK.yml: -------------------------------------------------------------------------------- 1 | en-BORK: 2 | faker: 3 | lorem: 4 | words: [Boot, I, Nu, Nur, Tu, Um, a, becoose-a, boot, bork, burn, chuuses, cumplete-a, cun, cunseqooences, curcoomstunces, dee, deeslikes, denuoonceeng, desures, du, eccuoont, ectooel, edfuntege-a, efueeds, egeeen, ell, ere-a, feend, foolt, frum, geefe-a, gesh, greet, heem, heppeeness, hes, hoo, hoomun, idea, ifer, in, incuoonter, injuy, itselff, ixcept, ixemple-a, ixerceese-a, ixpleeen, ixplurer, ixpuoond, ixtremely, knoo, lebureeuoos, lufes, meestekee, mester-booeelder, moost, mun, nu, nut, oobteeen, oocceseeunelly, ooccoor, ooff, oone-a, oor, peeen, peeenffool, physeecel, pleesoore-a, poorsooe-a, poorsooes, preeesing, prucoore-a, prudooces, reeght, reshunelly, resooltunt, sume-a, teecheengs, teke-a, thees, thet, thuse-a, treefiel, troot, tu, tueel, und, undertekes, unnuyeeng, uny, unyune-a, us, veell, veet, ves, vheech, vhu, yuoo, zee, zeere-a] 5 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/AncientTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class AncientTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void god() { 12 | assertThat(faker.ancient().god(), matchesRegularExpression("\\w+")); 13 | } 14 | 15 | @Test 16 | public void primordial() { 17 | assertThat(faker.ancient().primordial(), matchesRegularExpression("\\w+")); 18 | } 19 | 20 | @Test 21 | public void titan() { 22 | assertThat(faker.ancient().titan(), matchesRegularExpression("\\w+")); 23 | } 24 | 25 | @Test 26 | public void hero() { 27 | assertThat(faker.ancient().hero(), matchesRegularExpression("(?U)\\w+")); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/TwinPeaksTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.hamcrest.Matchers.isEmptyOrNullString; 7 | import static org.hamcrest.core.IsNot.not; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class TwinPeaksTest extends AbstractFakerTest { 11 | 12 | @Test 13 | public void character() { 14 | assertThat(faker.twinPeaks().character(), matchesRegularExpression("^([\\w']+ ?){2,}$")); 15 | } 16 | 17 | @Test 18 | public void location() { 19 | assertThat(faker.twinPeaks().location(), matchesRegularExpression("^[A-Za-z0-9'&,\\- ]+$")); 20 | } 21 | 22 | @Test 23 | public void quote() { 24 | assertThat(faker.twinPeaks().quote(), not(isEmptyOrNullString())); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Buffy.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Buffy { 4 | private final Faker faker; 5 | 6 | protected Buffy(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String characters() { 11 | return faker.fakeValuesService().resolve("buffy.characters", this, faker); 12 | } 13 | 14 | public String quotes() { 15 | return faker.fakeValuesService().resolve("buffy.quotes", this, faker); 16 | } 17 | 18 | public String celebrities() { 19 | return faker.fakeValuesService().resolve("buffy.celebrities", this, faker); 20 | } 21 | 22 | public String bigBads() { 23 | return faker.fakeValuesService().resolve("buffy.big_bads", this, faker); 24 | } 25 | 26 | public String episodes() { 27 | return faker.fakeValuesService().resolve("buffy.episodes", this, faker); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/MedicalTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.IsStringWithContents.isStringWithContents; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class MedicalTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void testMedicineName() { 12 | assertThat(faker.medical().medicineName(), isStringWithContents()); 13 | } 14 | 15 | @Test 16 | public void testDiseaseName() { 17 | assertThat(faker.medical().diseaseName(), isStringWithContents()); 18 | } 19 | 20 | @Test 21 | public void testHospitalName() { 22 | assertThat(faker.medical().hospitalName(), isStringWithContents()); 23 | } 24 | 25 | @Test 26 | public void testSymptom() { 27 | assertThat(faker.medical().symptoms(), isStringWithContents()); 28 | } 29 | 30 | 31 | } -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Superhero.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Superhero { 4 | private final Faker faker; 5 | 6 | protected Superhero(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String name() { 11 | return faker.fakeValuesService().resolve("superhero.name", this, faker); 12 | } 13 | 14 | public String prefix() { 15 | return faker.fakeValuesService().resolve("superhero.prefix", this, faker); 16 | } 17 | 18 | public String suffix() { 19 | return faker.fakeValuesService().resolve("superhero.suffix", this, faker); 20 | } 21 | 22 | public String power() { 23 | return faker.fakeValuesService().resolve("superhero.power", this, faker); 24 | } 25 | 26 | public String descriptor() { 27 | return faker.fakeValuesService().resolve("superhero.descriptor", this, faker); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/idnumbers/EnIdNumber.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.idnumbers; 2 | 3 | import com.github.javafaker.Faker; 4 | 5 | public class EnIdNumber { 6 | private static final String[] invalidSSNPatterns = { 7 | "0{3}-\\\\d{2}-\\\\d{4}", 8 | "\\d{3}-0{2}-\\d{4}", 9 | "\\d{3}-\\d{2}-0{4}", 10 | "666-\\d{2}-\\d{4}", 11 | "9\\d{2}-\\d{2}-\\d{4}"}; 12 | 13 | public String getValidSsn(Faker f) { 14 | String ssn = f.regexify("[0-8]\\d{2}-\\d{2}-\\d{4}"); 15 | 16 | boolean isValid = true; 17 | for (String invalidSSNPattern : invalidSSNPatterns) { 18 | if (ssn.matches(invalidSSNPattern)) { 19 | isValid = false; 20 | break; 21 | } 22 | } 23 | if (!isValid) { 24 | ssn = getValidSsn(f); 25 | } 26 | return ssn; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/resources/en/hacker.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | hacker: 4 | abbreviation: [TCP,HTTP,SDD,RAM,GB,CSS,SSL,AGP,SQL,FTP,PCI,AI,ADP,RSS,XML,EXE,COM,HDD,THX,SMTP,SMS,USB,PNG,SAS,IB,SCSI,JSON,XSS,JBOD] 5 | adjective: [auxiliary,primary,back-end,digital,open-source,virtual,cross-platform,redundant,online,haptic,multi-byte,bluetooth,wireless,1080p,neural, optical,solid state,mobile] 6 | noun: [driver,protocol,bandwidth,panel,microchip,program,port,card,array,interface,system,sensor,firewall,hard drive,pixel,alarm,feed,monitor,application,transmitter,bus,circuit,capacitor,matrix] 7 | verb: [back up,bypass,hack,override,compress,copy,navigate,index,connect,generate,quantify,calculate,synthesize,input,transmit,program,reboot,parse] 8 | ingverb: [backing up,bypassing,hacking,overriding,compressing,copying,navigating,indexing,connecting,generating,quantifying,calculating, synthesizing,transmitting,programming,parsing] 9 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/RickAndMortyTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.hamcrest.Matchers.isEmptyOrNullString; 7 | import static org.hamcrest.core.IsNot.not; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class RickAndMortyTest extends AbstractFakerTest { 11 | 12 | @Test 13 | public void character() { 14 | assertThat(faker.rickAndMorty().character(), matchesRegularExpression("^([\\w'-.]+ ?){2,}$")); 15 | } 16 | 17 | @Test 18 | public void location() { 19 | assertThat(faker.rickAndMorty().location(), matchesRegularExpression("^([\\w-.]+ ?){2,}$")); 20 | } 21 | 22 | @Test 23 | public void quote() { 24 | assertThat(faker.rickAndMorty().quote(), not(isEmptyOrNullString())); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Demographic.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Demographic { 4 | 5 | private final Faker faker; 6 | 7 | protected Demographic(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String race() { 12 | return faker.fakeValuesService().fetchString("demographic.race"); 13 | } 14 | 15 | public String educationalAttainment() { 16 | return faker.fakeValuesService().fetchString("demographic.educational_attainment"); 17 | } 18 | 19 | public String demonym() { 20 | return faker.fakeValuesService().fetchString("demographic.demonym"); 21 | } 22 | 23 | public String sex() { 24 | return faker.fakeValuesService().fetchString("demographic.sex"); 25 | } 26 | 27 | public String maritalStatus() { 28 | return faker.fakeValuesService().fetchString("demographic.marital_status"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/StarTrek.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class StarTrek { 4 | private final Faker faker; 5 | 6 | protected StarTrek(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.fakeValuesService().resolve("star_trek.character", this, faker); 12 | } 13 | 14 | public String location() { 15 | return faker.fakeValuesService().resolve("star_trek.location", this, faker); 16 | } 17 | 18 | public String specie() { 19 | return faker.fakeValuesService().resolve("star_trek.specie", this, faker); 20 | } 21 | 22 | public String villain() { 23 | return faker.fakeValuesService().resolve("star_trek.villain", this, faker); 24 | } 25 | 26 | public String klingon() { 27 | return faker.fakeValuesService().resolve("star_trek.klingon", this, faker); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/CryptoTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import org.junit.Test; 7 | 8 | 9 | public class CryptoTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void testMd5() { 13 | assertThat(faker.crypto().md5(), matchesRegularExpression("[a-z\\d]+")); 14 | } 15 | 16 | @Test 17 | public void testSha1() { 18 | assertThat(faker.crypto().sha1(), matchesRegularExpression("[a-z\\d]+")); 19 | } 20 | 21 | @Test 22 | public void testSha256() { 23 | assertThat(faker.crypto().sha256(), matchesRegularExpression("[a-z\\d]+")); 24 | } 25 | 26 | @Test 27 | public void testSha512() { 28 | assertThat(faker.crypto().sha512(), matchesRegularExpression("[a-z\\d]+")); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/BackToTheFutureTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static com.github.javafaker.matchers.IsStringWithContents.isStringWithContents; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class BackToTheFutureTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void character() { 13 | assertThat(faker.backToTheFuture().character(), isStringWithContents()); 14 | } 15 | 16 | @Test 17 | public void date() { 18 | assertThat(faker.backToTheFuture().date(), matchesRegularExpression("([A-za-z]{3,8}) ([1-9]|[1-2]\\d|3[0-1]), (18[8-9]\\d|19[0-9]\\d|200\\d|201[0-5])")); 19 | } 20 | 21 | @Test 22 | public void quote() { 23 | assertThat(faker.backToTheFuture().quote(), isStringWithContents()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | First and foremost thanks to anyone who contributes, very much appreciated. 2 | 3 | 4 | ## Guidelines 5 | - Need to maintain compatibility with Java 1.6 (and Android). Therefore any attempt to migrate to 1.6 JDKs and above will not be merged back in. 6 | 7 | - If you add new faker classes like `Address`, `Country`, and `Number` they should be accompanied by a unit test. Where relevant please add more assertions to the `com.github.javafaker.integration.FakerIT` class. 8 | - If you add a new faker class, update the `README.md`. 9 | - Submit a PR with your change and if there are no comments, changes will be merged in 10 | - If you're not sure about the change, raise an issue and have a discussion before spending time coding it up 11 | - Try and make one logical change per PR. That is not make many changes in one PR. Submit multiple PRs instead 12 | 13 | ## Building 14 | 15 | - Should be as easy as running `mvn clean install` on the root directory 16 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/MusicTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class MusicTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void instrument() { 12 | assertThat(faker.music().instrument(), matchesRegularExpression("\\w+ ?\\w+")); 13 | } 14 | 15 | @Test 16 | public void key() { 17 | assertThat(faker.music().key(), matchesRegularExpression("([A-Z])+(b|#){0,1}")); 18 | } 19 | 20 | @Test 21 | public void chord() { 22 | assertThat(faker.music().chord(), matchesRegularExpression("([A-Z])+(b|#){0,1}+(-?[a-zA-Z0-9]{0,4})")); 23 | } 24 | 25 | @Test 26 | public void genre() { 27 | assertThat(faker.music().genre(), matchesRegularExpression("[[ -]?\\w+]+")); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/en/educator.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | educator: 4 | name: ['Marblewald', 'Mallowtown', 'Brookville', 'Flowerlake', 'Falconholt', 'Ostbarrow', 'Lakeacre', 'Clearcourt', 'Ironston', 'Mallowpond', 'Iceborough', 'Icelyn', 'Brighthurst', 'Bluemeadow', 'Vertapple', 'Ironbarrow'] 5 | secondary: ['High School', 'Secondary College', 'High'] 6 | tertiary: 7 | type: ['College', 'University', 'Technical College', 'TAFE'] 8 | degree: 9 | 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'] 10 | type: ['Associate Degree in', 'Bachelor of', 'Master of'] 11 | course_number: ['1##', '2##', '3##', '4##', '5##'] 12 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/BookTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class BookTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void testTitle() { 12 | assertThat(faker.book().title(), matchesRegularExpression("([\\p{L}'\\-\\?]+[!,]? ?){2,9}")); 13 | } 14 | 15 | @Test 16 | public void testAuthor() { 17 | assertThat(faker.book().author(), matchesRegularExpression("([\\w']+\\.? ?){2,3}")); 18 | } 19 | 20 | @Test 21 | public void testPublisher() { 22 | assertThat(faker.book().publisher(), matchesRegularExpression("([\\p{L}'&\\-]+[,.]? ?){1,5}")); 23 | } 24 | 25 | @Test 26 | public void testGenre() { 27 | assertThat(faker.book().genre(), matchesRegularExpression("([\\w/]+ ?){2,4}")); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/HobbitTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertFalse; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class HobbitTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void character() { 13 | assertThat(faker.hobbit().character(), matchesRegularExpression("^(\\(?\\w+\\.?\\s?\\)?)+$")); 14 | } 15 | 16 | @Test 17 | public void thorinsCompany() { 18 | assertThat(faker.hobbit().thorinsCompany(), matchesRegularExpression("^(\\w+\\s?)+$")); 19 | } 20 | 21 | @Test 22 | public void quote() { 23 | assertFalse(faker.hobbit().quote().isEmpty()); 24 | } 25 | 26 | @Test 27 | public void location() { 28 | assertThat(faker.hobbit().location(), matchesRegularExpression("^(\\w+'?-?\\s?)+$")); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/EducatorTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class EducatorTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void testUniversity() { 12 | assertThat(faker.educator().university(), matchesRegularExpression("(\\w+ ?){2,3}")); 13 | } 14 | 15 | @Test 16 | public void testCourse() { 17 | assertThat(faker.educator().course(), matchesRegularExpression("(\\(?\\w+\\)? ?){3,6}")); 18 | } 19 | 20 | @Test 21 | public void testSecondarySchool() { 22 | assertThat(faker.educator().secondarySchool(), matchesRegularExpression("(\\w+ ?){2,3}")); 23 | } 24 | 25 | @Test 26 | public void testCampus() { 27 | assertThat(faker.educator().campus(), matchesRegularExpression("(\\w+ ?){1,2}")); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/AbstractFakerTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import com.github.javafaker.repeating.RepeatRule; 4 | import org.junit.Before; 5 | import org.junit.Rule; 6 | import org.mockito.MockitoAnnotations; 7 | import org.mockito.Spy; 8 | 9 | import java.util.logging.Handler; 10 | import java.util.logging.Level; 11 | import java.util.logging.LogManager; 12 | import java.util.logging.Logger; 13 | 14 | public class AbstractFakerTest { 15 | 16 | @Rule 17 | public RepeatRule repeatRule = new RepeatRule(); 18 | 19 | @Spy 20 | protected Faker faker; 21 | 22 | @Before 23 | public void before() { 24 | MockitoAnnotations.initMocks(this); 25 | 26 | Logger rootLogger = LogManager.getLogManager().getLogger(""); 27 | Handler[] handlers = rootLogger.getHandlers(); 28 | rootLogger.setLevel(Level.INFO); 29 | for (Handler h : handlers) { 30 | h.setLevel(Level.INFO); 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/HowIMetYourMotherTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertFalse; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class HowIMetYourMotherTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void character() { 13 | assertThat(faker.howIMetYourMother().character(), matchesRegularExpression("^(\\w+\\.?\\s?)+$")); 14 | } 15 | 16 | @Test 17 | public void catchPhrase() { 18 | assertFalse(faker.howIMetYourMother().catchPhrase().isEmpty()); 19 | } 20 | 21 | @Test 22 | public void highFive() { 23 | assertThat(faker.howIMetYourMother().highFive(), matchesRegularExpression("^(\\w+-?\\s?)+$")); 24 | } 25 | 26 | @Test 27 | public void quote() { 28 | assertFalse(faker.howIMetYourMother().quote().isEmpty()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Music.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Music { 4 | 5 | private static final String[] KEYS = new String[] { "C", "D", "E", "F", "G", "A", "B" }; 6 | private static final String[] KEY_VARIANTS = new String[] { "b", "#", "" }; 7 | private static final String[] CHORD_TYPES = new String[] { "", "maj", "6", "maj7", "m", "m7", "-7", "7", "dom7", "dim", "dim7", "m7b5"}; 8 | 9 | private final Faker faker; 10 | 11 | protected Music(Faker faker) { 12 | this.faker = faker; 13 | } 14 | 15 | public String instrument() { 16 | return faker.resolve("music.instruments"); 17 | } 18 | 19 | public String key() { 20 | return faker.options().option(KEYS) + faker.options().option(KEY_VARIANTS); 21 | } 22 | 23 | public String chord() { 24 | return key() + faker.options().option(CHORD_TYPES); 25 | } 26 | 27 | public String genre() { 28 | return faker.resolve("music.genres"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/resources/en/marketing.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | marketing: 4 | buzzwords: ["etc. etc.", "put a pin in it", "t-shirt sizes", "heavy lifting", "circle back", "two-way street", "data points", "out of the box", "get value out of the conversation", "penetrate the market", "plug and chug", "deep dive", "SWAG", "bucketize it", "sales funnel", "market share", "impact map", "growth unit", "tee it up", "make it actionable", "put a bow on it", "give you some time back", "bandwidth-constrained", "had to 'punt' on that", "home stretch", "get a pulse on", "value add", "expansion play", "rubber meets the road", "sprint to the finish line", "button up the loose ends", "heads down", "learnings", "ideate", "customer journey", "buying cycle", "synergy", "snackable content", "thought leader", "thought leadership", "immersive experience", "value proposition", "gamification", "agile marketing", "infographic", "granular", "streamline", "swim lane", "best practice", "bleeding edge", "out of pocket", "let's take this offline", "branding"] -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/BuffyTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.IsStringWithContents.isStringWithContents; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class BuffyTest extends AbstractFakerTest { 9 | @Test 10 | public void testCharacters() { 11 | assertThat(faker.buffy().characters(), isStringWithContents()); 12 | } 13 | 14 | @Test 15 | public void testQuotes() { 16 | assertThat(faker.buffy().quotes(), isStringWithContents()); 17 | } 18 | 19 | @Test 20 | public void testCelebrities() { 21 | assertThat(faker.buffy().celebrities(), isStringWithContents()); 22 | } 23 | 24 | @Test 25 | public void testBigBads() { 26 | assertThat(faker.buffy().bigBads(), isStringWithContents()); 27 | } 28 | 29 | @Test 30 | public void testEpisodes() { 31 | assertThat(faker.buffy().episodes(), isStringWithContents()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/ShakespeareTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.hamcrest.Matchers.isEmptyOrNullString; 6 | import static org.hamcrest.Matchers.not; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class ShakespeareTest extends AbstractFakerTest{ 10 | 11 | @Test 12 | public void testHamletQuote() { 13 | assertThat(faker.shakespeare().hamletQuote(), not(isEmptyOrNullString())); 14 | } 15 | 16 | @Test 17 | public void testAsYouLikeItQuote() { 18 | assertThat(faker.shakespeare().asYouLikeItQuote(), not(isEmptyOrNullString())); 19 | } 20 | 21 | @Test 22 | public void testKingRichardIIIQuote() { 23 | assertThat(faker.shakespeare().kingRichardIIIQuote(), not(isEmptyOrNullString())); 24 | } 25 | 26 | @Test 27 | public void testRomeoAndJulietQuote() { 28 | assertThat(faker.shakespeare().romeoAndJulietQuote(), not(isEmptyOrNullString())); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/BarcodeTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class BarcodeTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void type() { 12 | assertThat(faker.barcode().type(), 13 | matchesRegularExpression("(Code(128|39|93))|(E|J)AN(-\\d{1,2})*|Codabar|UCC|UPC(-(A|E))*|IS(B|S)N|ITF|" + 14 | "Ames\\sCode|NW-7|Monarch|Code\\s2\\sof\\s7|Rationalized|ANSI\\/AIM BC3-1995|USD-4|" + 15 | "GS1 Databar|MSI Plessey")); 16 | } 17 | 18 | @Test 19 | public void data(){ 20 | assertThat(faker.barcode().data(), matchesRegularExpression("\\d+")); 21 | } 22 | 23 | @Test 24 | public void typeAndData(){ 25 | assertThat(faker.barcode().typeAndData(), matchesRegularExpression("(\\w|\\W)+\\s\\d+$")); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Aviation.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | /** 4 | * Generates aviation related strings. 5 | */ 6 | public class Aviation { 7 | 8 | private final Faker faker; 9 | 10 | protected Aviation(Faker faker) { 11 | this.faker = faker; 12 | } 13 | 14 | /** 15 | * @return some aircraft name/model/make e.g. "An-2". 16 | */ 17 | public String aircraft() { 18 | return faker.fakeValuesService().fetchString("aviation.aircraft"); 19 | } 20 | 21 | /** 22 | * Returns an airport ICAO code. 23 | * See also: https://en.wikipedia.org/wiki/List_of_airports_by_ICAO_code:_A 24 | */ 25 | public String airport() { 26 | return faker.fakeValuesService().fetchString("aviation.airport"); 27 | } 28 | 29 | /** 30 | * Provides a METAR weather report. 31 | * Have a look at https://en.wikipedia.org/wiki/METAR 32 | */ 33 | public String METAR() { 34 | return faker.fakeValuesService().fetchString("aviation.metar"); 35 | } 36 | } -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/matchers/IsStringWithContentsTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.matchers; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | 6 | import static org.hamcrest.MatcherAssert.assertThat; 7 | import static org.hamcrest.core.Is.is; 8 | 9 | public class IsStringWithContentsTest { 10 | 11 | private IsStringWithContents matcher; 12 | 13 | @Before 14 | public void before() { 15 | matcher = new IsStringWithContents(); 16 | } 17 | 18 | @Test 19 | public void emptyStringShouldFail() { 20 | assertThat(matcher.matchesSafely(""), is(false)); 21 | } 22 | 23 | @Test 24 | public void nullStringShouldFail() { 25 | assertThat(matcher.matchesSafely(null), is(false)); 26 | } 27 | 28 | @Test 29 | public void stringShouldPass() { 30 | assertThat(matcher.matchesSafely("123"), is(true)); 31 | } 32 | 33 | @Test 34 | public void whiteSpaceShouldFail() { 35 | assertThat(matcher.matchesSafely(" "), is(false)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/service/FakeValuesGrouping.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | public class FakeValuesGrouping implements FakeValuesInterface { 8 | 9 | private List fakeValuesList = new ArrayList(); 10 | 11 | public void add(FakeValues fakeValues) { 12 | fakeValuesList.add(fakeValues); 13 | } 14 | 15 | @Override 16 | @SuppressWarnings({"unchecked", "rawtypes"}) 17 | public Map get(String key) { 18 | Map result = null; 19 | for (FakeValues fakeValues : fakeValuesList) { 20 | if (fakeValues.supportsPath(key)) { 21 | if (result != null) { 22 | final Map newResult = fakeValues.get(key); 23 | result.putAll(newResult); 24 | } else { 25 | result = fakeValues.get(key); 26 | } 27 | } 28 | } 29 | return result; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/matchers/MatchesRegularExpression.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.matchers; 2 | 3 | import org.hamcrest.Description; 4 | import org.hamcrest.Factory; 5 | import org.hamcrest.Matcher; 6 | import org.hamcrest.TypeSafeMatcher; 7 | 8 | public class MatchesRegularExpression extends TypeSafeMatcher { 9 | 10 | private final String regularExpression; 11 | 12 | public MatchesRegularExpression(String regularExpression) { 13 | this.regularExpression = regularExpression; 14 | } 15 | 16 | @Override 17 | protected boolean matchesSafely(String item) { 18 | return item.matches(regularExpression); 19 | } 20 | 21 | @Override 22 | public void describeTo(Description description) { 23 | description.appendText("to match the regular expression " + regularExpression); 24 | } 25 | 26 | @Factory 27 | public static Matcher matchesRegularExpression(String regularExpression) { 28 | return new MatchesRegularExpression(regularExpression); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/PhoneNumber.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class PhoneNumber { 4 | private final Faker faker; 5 | 6 | protected PhoneNumber(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String cellPhone() { 11 | return faker.numerify(faker.fakeValuesService().resolve("cell_phone.formats", this, faker)); 12 | } 13 | 14 | public String phoneNumber() { 15 | return faker.numerify(faker.fakeValuesService().resolve("phone_number.formats", this, faker)); 16 | } 17 | 18 | public String extension() { 19 | return subscriberNumber(); 20 | } 21 | 22 | public String subscriberNumber(int length) { 23 | StringBuilder subscriberNumber = new StringBuilder(); 24 | for (int i = 0; i < length; i++) { 25 | subscriberNumber.append("#"); 26 | } 27 | return faker.numerify(subscriberNumber.toString()); 28 | } 29 | 30 | public String subscriberNumber() { 31 | return subscriberNumber(4); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/EsportsTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class EsportsTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void player() { 12 | assertThat(faker.esports().player(), matchesRegularExpression("(\\w|.)+")); 13 | } 14 | 15 | @Test 16 | public void team() { 17 | assertThat(faker.esports().team(), matchesRegularExpression("((\\w|.)+ ?)+")); 18 | } 19 | 20 | @Test 21 | public void event() { 22 | assertThat(faker.esports().event(), matchesRegularExpression("(\\w+ ?)+")); 23 | } 24 | 25 | @Test 26 | public void league() { 27 | assertThat(faker.esports().league(), matchesRegularExpression("\\w+")); 28 | } 29 | 30 | @Test 31 | public void game() { 32 | assertThat(faker.esports().game(), matchesRegularExpression("([\\w:.]+ ?)+")); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/en/app.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | app: 4 | name: ['Redhold', 'Treeflex', 'Trippledex', 'Kanlam', 'Bigtax', 'Daltfresh', 'Toughjoyfax', 'Mat Lam Tam', 'Otcom', 'Tres-Zap', 'Y-Solowarm', 'Tresom', 'Voltsillam', 'Biodex', 'Greenlam', 'Viva', 'Matsoft', 'Temp', 'Zoolab', 'Subin', 'Rank', 'Job', 'Stringtough', 'Tin', 'It', 'Home Ing', 'Zamit', 'Sonsing', 'Konklab', 'Alpha', 'Latlux', 'Voyatouch', 'Alphazap', 'Holdlamis', 'Zaam-Dox', 'Sub-Ex', 'Quo Lux', 'Bamity', 'Ventosanzap', 'Lotstring', 'Hatity', 'Tempsoft', 'Overhold', 'Fixflex', 'Konklux', 'Zontrax', 'Tampflex', 'Span', 'Namfix', 'Transcof', 'Stim', 'Fix San', 'Sonair', 'Stronghold', 'Fintone', 'Y-find', 'Opela', 'Lotlux', 'Ronstring', 'Zathin', 'Duobam', 'Keylex', 'Andalax', 'Solarbreeze', 'Cookley', 'Vagram', 'Aerified', 'Pannier', 'Asoka', 'Regrant', 'Wrapsafe', 'Prodder', 'Bytecard', 'Bitchip', 'Veribet', 'Gembucket', 'Cardguard', 'Bitwolf', 'Cardify', 'Domainer', 'Flowdesk', 'Flexidy'] 5 | version: ['0.#.#', '0.##', '#.##', '#.#', '#.#.#'] 6 | author: 7 | - "#{Name.name}" 8 | - "#{Company.name}" 9 | -------------------------------------------------------------------------------- /src/main/resources/en/lovecraft.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | lovecraft: 4 | fhtagn: ["Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn"] 5 | deity: ["Azathoth", "Cthulhu", "Dagon", "Hastur", "Nyarlathotep", "Shub-Niggurath", "Tsathoggua", "Yog-Sothoth"] 6 | location: ["Arkham", "Dunwich", "Innsmouth", "Kadath", "Kingsport", "Leng", "Miskatonic", "R’lyeh", "Yuggoth", "Irem"] 7 | tome: ["Necronomicon", "Pnakotic Manuscripts", "De Vermis Mysteriis", "Book of Eibon", "Eltdown Shards"] 8 | words: ["abnormal", "accursed", "amorphous", "antediluvian", "antiquarian", "blasphemous", "cat", "charnel", "comprehension", "cyclopean", "dank", "decadent", "daemoniac", "effulgence", "eldritch", "fainted", "foetid", "fungus", "furtive", "gambrel", "gibbous", "gibbering", "hideous", "immemorial", "indescribable", "iridescence", "loathsome", "lurk", "madness", "manuscript", "mortal", "nameless", "noisome", "non-euclidean", "shunned", "singular", "spectral", "squamous", "stench", "stygian", "swarthy", "tenebrous", "tentacles", "ululate", "unmentionable", "unnamable", "unutterable"] 9 | 10 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/JobTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class JobTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void field() { 12 | assertThat(faker.job().field(), matchesRegularExpression("^[A-Z][A-Za-z-]+$")); 13 | } 14 | 15 | @Test 16 | public void seniority() { 17 | assertThat(faker.job().seniority(), matchesRegularExpression("^[A-Z][a-z]+$")); 18 | } 19 | 20 | @Test 21 | public void position() { 22 | assertThat(faker.job().position(), matchesRegularExpression("^[A-Z][a-z]+$")); 23 | } 24 | 25 | @Test 26 | public void keySkills() { 27 | assertThat(faker.job().keySkills(), matchesRegularExpression("([A-Za-z-]+ ?){1,3}")); 28 | } 29 | 30 | @Test 31 | public void title() { 32 | assertThat(faker.job().title(), matchesRegularExpression("([A-Za-z-]+ ?){2,3}")); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/File.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class File { 4 | private final Faker faker; 5 | 6 | protected File(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String extension() { 11 | return faker.resolve("file.extension"); 12 | } 13 | 14 | public String mimeType() { 15 | return faker.resolve("file.mime_type"); 16 | } 17 | 18 | public String fileName() { 19 | return fileName(null, null, null, null); 20 | } 21 | 22 | public String fileName(String dirOrNull, String nameOrNull, String extensionOrNull, String separatorOrNull) { 23 | final String sep = separatorOrNull == null ? System.getProperty("file.separator") : separatorOrNull; 24 | final String dir = dirOrNull == null ? faker.internet().slug() : dirOrNull; 25 | final String name = nameOrNull == null ? faker.lorem().word().toLowerCase() : nameOrNull; 26 | final String ext = extensionOrNull == null ? extension() : extensionOrNull; 27 | return dir + sep + name + "." + ext; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/en/commerce.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | commerce: 4 | department: ["Books", "Movies", "Music", "Games", "Electronics", "Computers", "Home", "Garden", "Tools", "Grocery", "Health", "Beauty", "Toys", "Kids", "Baby", "Clothing", "Shoes", "Jewelry", "Sports", "Outdoors", "Automotive", "Industrial"] 5 | product_name: 6 | adjective: [Small, Ergonomic, Rustic, Intelligent, Gorgeous, Incredible, Fantastic, Practical, Sleek, Awesome, Enormous, Mediocre, Synergistic, Heavy Duty, Lightweight, Aerodynamic, Durable] 7 | material: [Steel, Wooden, Concrete, Plastic, Cotton, Granite, Rubber, Leather, Silk, Wool, Linen, Marble, Iron, Bronze, Copper, Aluminum, Paper] 8 | product: [Chair, Car, Computer, Gloves, Pants, Shirt, Table, Shoes, Hat, Plate, Knife, Bottle, Coat, Lamp, Keyboard, Bag, Bench, Clock, Watch, Wallet] 9 | promotion_code: 10 | adjective: ['Amazing', 'Awesome', 'Cool', 'Good', 'Great', 'Incredible', 'Killer', 'Premium', 'Special', 'Stellar', 'Sweet'] 11 | noun: ['Code', 'Deal', 'Discount', 'Price', 'Promo', 'Promotion', 'Sale', 'Savings'] 12 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/BeerTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class BeerTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void testName() { 12 | assertThat(faker.beer().name(), matchesRegularExpression("[\\p{L}'()\\., 0-9-’’]+")); 13 | } 14 | 15 | @Test 16 | public void testStyle() { 17 | assertThat(faker.beer().style(), matchesRegularExpression("[A-Za-z'() 0-9-]+")); 18 | } 19 | 20 | @Test 21 | public void testHop() { 22 | assertThat(faker.beer().hop(), matchesRegularExpression("[A-Za-z'’()\\. 0-9-]+")); 23 | } 24 | 25 | @Test 26 | public void testMalt() { 27 | assertThat(faker.beer().malt(), matchesRegularExpression("[A-Za-z'() 0-9-]+")); 28 | } 29 | 30 | @Test 31 | public void testYeast() { 32 | assertThat(faker.beer().yeast(), matchesRegularExpression("[\\p{L}'() 0-9-ö]+")); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Witcher.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Witcher { 4 | private final Faker faker; 5 | 6 | protected Witcher(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.fakeValuesService().resolve("games.witcher.characters", this, faker); 12 | } 13 | 14 | public String witcher() { 15 | return faker.fakeValuesService().resolve("games.witcher.witchers", this, faker); 16 | } 17 | 18 | public String school() { 19 | return faker.fakeValuesService().resolve("games.witcher.schools", this, faker); 20 | } 21 | 22 | public String location() { 23 | return faker.fakeValuesService().resolve("games.witcher.locations", this, faker); 24 | } 25 | 26 | public String quote() { 27 | return faker.fakeValuesService().resolve("games.witcher.quotes", this, faker); 28 | } 29 | 30 | public String monster() { 31 | return faker.fakeValuesService().resolve("games.witcher.monsters", this, faker); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/HackerTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class HackerTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void testAbbreviation() { 12 | assertThat(faker.hacker().abbreviation(), matchesRegularExpression("[A-Z]{2,4}")); 13 | } 14 | 15 | @Test 16 | public void testAdjective() { 17 | assertThat(faker.hacker().adjective(), matchesRegularExpression("(\\w+[- ]?){1,2}")); 18 | } 19 | 20 | @Test 21 | public void testNoun() { 22 | assertThat(faker.hacker().noun(), matchesRegularExpression("\\w+( \\w+)?")); 23 | } 24 | 25 | @Test 26 | public void testVerb() { 27 | assertThat(faker.hacker().verb(), matchesRegularExpression("\\w+( \\w+)?")); 28 | } 29 | 30 | @Test 31 | public void testIngverb() { 32 | assertThat(faker.hacker().ingverb(), matchesRegularExpression("\\w+ing( \\w+)?")); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/SuperheroTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class SuperheroTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void testName() { 12 | assertThat(faker.superhero().name(), matchesRegularExpression("[A-Za-z' -/]+")); 13 | } 14 | 15 | @Test 16 | public void testPrefix() { 17 | assertThat(faker.superhero().prefix(), matchesRegularExpression("[A-Za-z -]+")); 18 | } 19 | 20 | @Test 21 | public void testSuffix() { 22 | assertThat(faker.superhero().suffix(), matchesRegularExpression("[A-Za-z -]+")); 23 | } 24 | 25 | @Test 26 | public void testPower() { 27 | assertThat(faker.superhero().power(), matchesRegularExpression("[A-Za-z/ -]+")); 28 | } 29 | 30 | @Test 31 | public void testDescriptor() { 32 | assertThat(faker.superhero().descriptor(), matchesRegularExpression("[A-Za-z' -]+")); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/idnumbers/SwedishIdNumberTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.idnumbers; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.hamcrest.MatcherAssert.assertThat; 6 | import static org.hamcrest.core.Is.is; 7 | 8 | public class SwedishIdNumberTest { 9 | 10 | @Test 11 | public void valid() { 12 | SvSEIdNumber idNumber = new SvSEIdNumber(); 13 | assertThat(idNumber.validSwedishSsn("670919-9530"), is(true)); 14 | assertThat(idNumber.validSwedishSsn("811228-9874"), is(true)); 15 | } 16 | 17 | @Test 18 | public void invalid() { 19 | SvSEIdNumber idNumber = new SvSEIdNumber(); 20 | assertThat(idNumber.validSwedishSsn("8112289873"), is(false)); 21 | assertThat(idNumber.validSwedishSsn("foo228-9873"), is(false)); 22 | assertThat(idNumber.validSwedishSsn("811228-9873"), is(false)); 23 | assertThat(idNumber.validSwedishSsn("811228-9875"), is(false)); 24 | assertThat(idNumber.validSwedishSsn("811200-9874"), is(false)); 25 | assertThat(idNumber.validSwedishSsn("810028-9874"), is(false)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/DemographicTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import org.junit.Test; 7 | 8 | public class DemographicTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void race() { 12 | assertThat(faker.demographic().race(), matchesRegularExpression("(\\w+ ?)+")); 13 | } 14 | 15 | @Test 16 | public void educationalAttainment() { 17 | assertThat(faker.demographic().educationalAttainment(), matchesRegularExpression("(?U)([\\w'-]+ ?)+")); 18 | } 19 | 20 | @Test 21 | public void demonym() { 22 | assertThat(faker.demographic().demonym(), matchesRegularExpression("(?U)([\\w'-]+ ?)+")); 23 | } 24 | 25 | @Test 26 | public void maritalStatus() { 27 | assertThat(faker.demographic().maritalStatus(), matchesRegularExpression("(\\w+ ?)+")); 28 | } 29 | 30 | @Test 31 | public void sex() { 32 | assertThat(faker.demographic().sex(), matchesRegularExpression("\\w+")); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/en/dessert.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | dessert: 4 | variety: ["Cake", "Cookie", "Pie", "Ice Cream", "Pudding", "Sweet Bread", "Cupcake", "Cheesecake", "Brownie", "Cobbler", "Ice Cream Cake", "Doughnut", "Frozen Yogurt", "Parfait", "Sundae", "Trifle", "Cake Pop", "Fruit Cake", "Coffee Cake", "Key Lime Pie", "Upside Down Pineapple Cake"] 5 | topping: ["Rainbow Sprinkles", "Chocolate Chips", "Whipped Cream", "Frosting", "Peanut Butter", "Gummy Bears", "Mocha Drizzle", "Caramel", "Bacon", "Chocolate Syrup", "Chocolate Sprinkles", "Cookie Dough", "Peanuts", "Butterscotch Syrup", "Marshmallows", "Cheesecake Bites", "Walnuts", "Granola", "Toffee Bits", "Berry Compote", "Glaze", "Powdered Sugar", "Cinnamon"] 6 | flavor: ["Vanilla", "Chocolate", "Strawberry", "Birthday Cake", "Salted Caramel", "Banana", "Butter Pecan", "Cookies 'n Cream", "Caramel", "Apple", "Butterscotch", "Mint Chocolate Chip", "Espresso", "Butter Pecan", "Cherry", "Coconut", "Chocolate Chip Cookie Dough", "French Vanilla", "Neapolitan", "Pistachio", "Rocky Road", "Peanut Butter", "Almond", "Green Tea", "Cheesecake", "Funfetti", "Lemon", "Oatmeal", "Pumpkin", "Red Velvet", "Blondie"] 7 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Gender.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | /** 4 | * This class is used to generate gender randomly. 5 | * 6 | */ 7 | 8 | public class Gender { 9 | private final Faker faker; 10 | 11 | protected Gender(Faker faker) { 12 | this.faker = faker; 13 | } 14 | 15 | /** 16 | * This method returns a gender type 17 | * 18 | * @return a string of gender type 19 | */ 20 | public String types() { 21 | return faker.fakeValuesService().fetchString("gender.types"); 22 | } 23 | 24 | /** 25 | * This method returns a binary gender type 26 | * 27 | * @return a string of binary gender type 28 | */ 29 | public String binaryTypes() { 30 | return faker.fakeValuesService().fetchString("gender.binary_types"); 31 | } 32 | 33 | /** 34 | * This method returns a short binary gender type 35 | * 36 | * @return a string of short binary gender type 37 | */ 38 | public String shortBinaryTypes() { 39 | return faker.fakeValuesService().fetchString("gender.short_binary_types"); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/LeagueOfLegends.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class LeagueOfLegends { 4 | private final Faker faker; 5 | 6 | protected LeagueOfLegends(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String champion() { 11 | return faker.fakeValuesService().resolve("games.league_of_legends.champion", this, faker); 12 | } 13 | 14 | public String location() { 15 | return faker.fakeValuesService().resolve("games.league_of_legends.location", this, faker); 16 | } 17 | 18 | public String quote() { 19 | return faker.fakeValuesService().resolve("games.league_of_legends.quote", this, faker); 20 | } 21 | 22 | public String summonerSpell() { 23 | return faker.fakeValuesService().resolve("games.league_of_legends.summoner_spell", this, faker); 24 | } 25 | 26 | public String masteries() { 27 | return faker.fakeValuesService().resolve("games.league_of_legends.masteries", this, faker); 28 | } 29 | 30 | public String rank() { 31 | return faker.fakeValuesService().resolve("games.league_of_legends.rank", this, faker); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/resources/en/dragon_ball.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | dragon_ball: 4 | characters: ["Goku", "Bulma", "Kami", "Yamcha", "Krillin", "Tien", "Piccolo", "Gohan", "Vegeta", "Kid Trunks", "Goten", "Future Trunks", "Pan", "Android 18", "Android 16", "Android 17", "Android 19", "Android 20", "Beerus", "Chaozu", "Chi-Chi", "Launch", "Mr. Satan", "Oolong", "Puar", "Videl", "Whis", "Yajirobe", "Demon King Piccolo", "Freeza", "Cell", "Majin Buu", "Goku Black", "Zamasu", "Baba", "Bra", "Bardock", "Champa", "Dende", "Dr. Gero", "Captain Ginyu", "Grandpa Gohan", "Jaco", "King Kai", "Supreme Kai", "Elder Kai", "Mr. Popo", "Nappa", "Uub", "Pilaf", "Raditz", "Shenron", "Vados", "Zarbon", "Broly", "Cooler", "King Cold", "Garlic Jr", "King Vegeta", "Nail", "Guru", "Hit", "Super Saiyan Goku", "Super Saiyan 2 Goku", "Super Saiyan 3 Goku", "Super Saiyan Vegeta", "Super Saiyan 2 Vegeta", "Majin Vegeta", "Super Saiyan Gohan", "Super Saiyan 2 Gohan", "Super Saiyan Goten", "Super Saiyan Trunks", "Vegito", "Gogeta", "Super Saiyan Blue Goku", "Super Saiyan Blue Vegeta", "Mystic Gohan", "Caulifla", "Baby", "Shenlong", "Ryan Shenlong", "Uh Shenlong", "Ryuu Shenlong", "Chi Shenlong", "Su Shenlong", "San Shenlong", "Li Shenlong"] 5 | -------------------------------------------------------------------------------- /src/main/resources/en/famous_last_words.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | famous_last_words: 4 | last_words: ["I don't know.", "No comment.", "Van Halen!", "Is it not meningitis?", "I love you too, honey. Good luck with your show.", "Am I dying, or is this my birthday?", "I want your bunk!", "I went the distance.", "Goodnight, my darlings, I'll see you tomorrow.", "I am confound.", "That was the best ice-cream soda I ever tasted.", "All my possessions for a moment of time.", "Hurrah for anarchy! This is the happiest moment of my life.", "It's stopped.", "You can get anything you want at Alice's restaurant.", "Yes, it's tough, but not as tough as doing comedy.", "That's good. Go on, read some more.", "I love you.", "One! Two! Three!", "Do you want me to come with you?", "Does nobody understand?", "I wish I could go with you.", "I'll be in Hell before you start breakfast! Let her rip!", "Tape Seinfeld for me.", "Strike the tent.", "I don't think they even heard me.", "I regret that I should leave this world without again beholding him.", "Well, this is certainly a pleasant surprise.", "Okay, I won't.", "I want to go home.", "Happy.", "I forgot something.", "My vocabulary did this to me. Your love will let you go on…"] -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/service/FakerIDN.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.service; 2 | 3 | import java.net.IDN; 4 | 5 | /** 6 | * Created by tshick on 10/30/16. 7 | */ 8 | public class FakerIDN { 9 | /** 10 | * {@link IDN#toASCII(String)} is too picky for our needs. It was throwing exceptions for fa.yml and 11 | * he.yml as they're Bidi languages and something was causing them to die. This is kind of a brute force 12 | * fix but it appears to fix the issue. 13 | */ 14 | public static final String toASCII(String in) { 15 | try { 16 | return IDN.toASCII(in); 17 | } catch (Exception e) { 18 | // let's continue with the character by character encoding hack. 19 | } 20 | final StringBuilder sb = new StringBuilder(); 21 | for (int i=0;i flagInts = (List) faker.fakeValuesService().fetch("nation.flag"); 33 | 34 | ByteBuffer byteBuffer = MappedByteBuffer.allocate(flagInts.size()); 35 | 36 | for (Integer flagInt : flagInts) { 37 | byteBuffer.put(flagInt.byteValue()); 38 | } 39 | 40 | return new String(byteBuffer.array(), UTF8_CHARSET); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/LeagueOfLegendsTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertFalse; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class LeagueOfLegendsTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void champion() { 13 | assertThat(faker.leagueOfLegends().champion(), matchesRegularExpression("^(\\w+\\.?-?'?\\s?&?\\s?)+$")); 14 | } 15 | 16 | @Test 17 | public void location() { 18 | assertThat(faker.leagueOfLegends().location(), matchesRegularExpression("^(\\w+\\s?)+$")); 19 | } 20 | 21 | @Test 22 | public void quote() { 23 | assertFalse(faker.leagueOfLegends().quote().isEmpty()); 24 | } 25 | 26 | @Test 27 | public void summonerSpell() { 28 | assertThat(faker.leagueOfLegends().summonerSpell(), matchesRegularExpression("^(\\w+\\s?!?)+$")); 29 | } 30 | 31 | @Test 32 | public void masteries() { 33 | assertThat(faker.leagueOfLegends().masteries(), matchesRegularExpression("^(\\w+\\s?'?)+$")); 34 | } 35 | 36 | @Test 37 | public void rank() { 38 | assertThat(faker.leagueOfLegends().rank(), matchesRegularExpression("^\\w+(\\s[IV]+)?$")); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/BojackHorseman.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | /** 4 | * Generate random parts in BojackHorseman. 5 | * @author unknown and irakatz 6 | */ 7 | 8 | public class BojackHorseman { 9 | private final Faker faker; 10 | 11 | /** 12 | * Create a constructor for BojackHorseman. 13 | * @param faker The Faker instance for generating random parts in BojackHorseman. 14 | */ 15 | protected BojackHorseman(Faker faker) { 16 | this.faker = faker; 17 | } 18 | 19 | /** 20 | * Generate random character's name in BojackHorseman. 21 | * @return Characters in BojackHorseman 22 | */ 23 | public String characters() { 24 | return faker.fakeValuesService().resolve("bojack_horseman.characters", this, faker); 25 | } 26 | 27 | /** 28 | * Generate random quotes in BojackHorseman. 29 | * @return Quotes in BojackHorseman 30 | */ 31 | public String quotes() { 32 | return faker.fakeValuesService().resolve("bojack_horseman.quotes", this, faker); 33 | } 34 | 35 | /** 36 | * Generate random tongue twisters in BojackHorseman. 37 | * @return Tongue twisters in BojackHorseman 38 | */ 39 | public String tongueTwisters() { 40 | return faker.fakeValuesService().resolve("bojack_horseman.tongue_twisters", this, faker); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/FoodTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class FoodTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void ingredient() { 12 | assertThat(faker.food().ingredient(), matchesRegularExpression("[A-Za-z- ]+")); 13 | } 14 | 15 | @Test 16 | public void spice() { 17 | assertThat(faker.food().spice(), matchesRegularExpression("[A-Za-z1-9- ]+")); 18 | } 19 | 20 | @Test 21 | public void dish() { 22 | assertThat(faker.food().dish(), matchesRegularExpression("\\P{Cc}+")); 23 | } 24 | 25 | @Test 26 | public void fruit() { 27 | assertThat(faker.food().fruit(), matchesRegularExpression("[A-Za-z1-9- ]+")); 28 | } 29 | 30 | @Test 31 | public void vegetable() { 32 | assertThat(faker.food().vegetable(), matchesRegularExpression("[A-Za-z1-9- ]+")); 33 | } 34 | 35 | @Test 36 | public void sushi() { 37 | assertThat(faker.food().sushi(), matchesRegularExpression("[A-Za-z1-9- ]+")); 38 | } 39 | 40 | @Test 41 | public void measurement() { 42 | assertThat(faker.food().measurement(), matchesRegularExpression("[A-Za-z1-9/ ]+{2}")); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/ElderScrolls.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class ElderScrolls { 4 | 5 | private final Faker faker; 6 | 7 | protected ElderScrolls(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String race() { 12 | return faker.fakeValuesService().resolve("games.elder_scrolls.race", this, faker); 13 | } 14 | 15 | public String creature() { 16 | return faker.fakeValuesService().resolve("games.elder_scrolls.creature", this, faker); 17 | } 18 | 19 | public String region() { 20 | return faker.fakeValuesService().resolve("games.elder_scrolls.region", this, faker); 21 | } 22 | 23 | public String dragon() { 24 | return faker.fakeValuesService().resolve("games.elder_scrolls.dragon", this, faker); 25 | } 26 | 27 | public String city() { 28 | return faker.fakeValuesService().resolve("games.elder_scrolls.city", this, faker); 29 | } 30 | 31 | public String firstName() { 32 | return faker.fakeValuesService().resolve("games.elder_scrolls.first_name", this, faker); 33 | } 34 | 35 | public String lastName() { 36 | return faker.fakeValuesService().resolve("games.elder_scrolls.last_name", this, faker); 37 | } 38 | 39 | public String quote() {return faker.fakeValuesService().resolve("games.elder_scrolls.quote", this, faker); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/resources/en/half_life.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | games: 4 | half_life: 5 | character: ["Adrian Shephard", "Alyx Vance", "Arne Magnusson", "Barney Calhoun", "Colette Green", "Dog", "Eli Vance", "Father Grigori", "G-Man", "Gina Cross", "Gordon Freeman", "Isaac Kleiner", "Judith Mossman", "Odessa Cubbage", "Richard Keller", "Simmons", "Wallace Breen", "Walter Bennet"] 6 | enemy: ["APC", "Alien Controller", "Alien Grunt", "Antlion", "Antlion Guard", "Assassin", "Baby Headcrab", "Barnacle", "Bullsquid", "City Scanner", "Civil Protection", "Combine Advisor", "Combine Gunship", "Crab Synth", "Fast Headcrab", "Fast Zombie", "Garg", "Gene Worm", "Gonarch", "Grunt", "Headcrab", "Hopper Mine", "Houndeye", "Hunter-Chopper", "Ichthyosaur", "Leech", "Manhack", "Mortar Synth", "Overwatch Elite", "Overwatch Sniper", "Overwatch Soldier", "Pit Drone", "Pit Worm", "Poison Headcrab", "Poison Zombie", "Rollermine", "Shield Scanner", "Shock Roach", "Shock Trooper", "Snark", "Strider", "Tentacle", "Voltigore", "Vortigaunt", "Zombie"] 7 | location: ["Black Mesa East", "Black Mesa Research Facility", "Citadel", "City 17", "Earth", "Nova Prospekt", "Ravenholm", "Section A-17 Prototype Labs", "Sector A Training Facility", "Sector B Coolant Reserve", "Sector C Test Labs", "Sector D Administration", "Sector E Biodome Complex", "Sector F Lambda Complex", "Sector G Hydro Electric", "St. Olga", "White Forest", "Xen"] 8 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/HarryPotterTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.hamcrest.Matchers.isEmptyOrNullString; 7 | import static org.hamcrest.core.IsNot.not; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class HarryPotterTest extends AbstractFakerTest { 11 | 12 | @Test 13 | public void character() { 14 | assertThat(faker.harryPotter().character(), matchesRegularExpression("[A-Za-z,\\-\\.\\(\\) ]+")); 15 | } 16 | 17 | @Test 18 | public void location() { 19 | assertThat(faker.harryPotter().location(), matchesRegularExpression("[A-Za-z0-9'\\. &,/]+")); 20 | } 21 | 22 | @Test 23 | public void quote() { 24 | assertThat(faker.harryPotter().quote(), not(isEmptyOrNullString())); 25 | } 26 | 27 | @Test 28 | public void book() { 29 | assertThat(faker.harryPotter().book(), matchesRegularExpression("Harry Potter and the ([A-Za-z'\\-]+ ?)+")); 30 | } 31 | 32 | @Test 33 | public void house() { 34 | assertThat(faker.harryPotter().house(), matchesRegularExpression("[A-Za-z ]+")); 35 | } 36 | 37 | @Test 38 | public void spell() { 39 | assertThat(faker.harryPotter().spell(), matchesRegularExpression("[A-Za-z ]+")); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/resources/en/job.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | job: 4 | field: [Marketing, IT, Accounting, Administration, Advertising, Banking, Community-Services, Construction, Consulting, Design, Education, Farming, Government, Healthcare, Hospitality, Legal, Manufacturing, Marketing, Mining, Real-Estate, Retail, Sales, Technology] 5 | seniority: [Lead, Senior, Product, National, Regional, District, Central, Global, Customer, Investor, Dynamic, International, Legacy, Forward, Internal, Chief, Direct, Corporate, Future, Human, Principal] 6 | position: [Supervisor, Associate, Executive, Liaison, Officer, Manager, Engineer, Specialist, Director, Coordinator, Administrator, Architect, Analyst, Designer, Planner, Orchestrator, Technician, Developer, Producer, Consultant, Assistant, Facilitator, Agent, Representative, Strategist] 7 | key_skills: [Teamwork, Communication, Problem solving, Leadership, Organisation, Work under pressure, Confidence, Self-motivated, Networking skills, Proactive, Fast learner, Technical savvy] 8 | employment_type: [Full-time, Part-time, Temporary, Contract, Internship, Commission] 9 | education_level: [Associates, Bachelor, Master, Doctorate] 10 | title: 11 | - "#{seniority} #{field} #{position}" 12 | - "#{seniority} #{field} #{position}" 13 | - "#{field} #{position}" 14 | - "#{field} #{position}" 15 | - "#{seniority} #{position}" -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/HitchhikersGuideToTheGalaxy.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class HitchhikersGuideToTheGalaxy { 4 | private final Faker faker; 5 | 6 | protected HitchhikersGuideToTheGalaxy(Faker faker) { 7 | this.faker = faker; 8 | } 9 | 10 | public String character() { 11 | return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.characters", this, faker); 12 | } 13 | 14 | public String location() { 15 | return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.locations", this, faker); 16 | } 17 | 18 | public String marvinQuote() { 19 | return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.marvin_quote", this, faker); 20 | } 21 | 22 | public String planet() { 23 | return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.planets", this, faker); 24 | } 25 | 26 | public String quote() { 27 | return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.quotes", this, faker); 28 | } 29 | 30 | public String specie() { 31 | return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.species", this, faker); 32 | } 33 | 34 | public String starship() { 35 | return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.starships", this, faker); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/resources/en/ancient.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | ancient: 4 | god: ["Aphrodite", "Apollo", "Ares", "Artemis", "Athena", "Demeter", "Dionysus", "Hades", "Hephaestus", "Hera", "Hermes", "Hestia", "Poseidon", "Zeus"] 5 | primordial: ["Aion", "Aether", "Ananke", "Chaos", "Chronos", "Erebus", "Eros", "Hypnos", "Nesoi", "Uranus", "Gaia", "Ourea", "Phanes", "Pontus", "Tartarus", "Thalassa", "Thanatos", "Hemera", "Nyx", "Nemesis"] 6 | titan: ["Coeus", "Crius", "Cronus", "Hyperion", "Iapetus", "Mnemosyne", "Oceanus", "Phoebe", "Rhea", "Tethys", "Theia", "Themis", "Asteria", "Astraeus", "Atlas", "Aura", "Clymene", "Dione", "Helios", "Selene", "Eos", "Epimetheus", "Eurybia", "Eurynome", "Lelantos", "Leto", "Menoetius", "Metis", "Ophion", "Pallas", "Perses", "Prometheus", "Styx"] 7 | hero: ["Abderus", "Achilles", "Aeneas", "Ajax", "Amphitryon", "Antilochus", "Bellerophon", "Castor", "Chrysippus", "Daedalus", "Diomedes", "Eleusis", "Eunostus", "Ganymede", "Hector", "Hercules", "Icarus", "Iolaus", "Jason", "Meleager", "Odysseus", "Orpheus", "Pandion", "Perseus", "Theseus", "Alcestis", "Amymone", "Andromache", "Andromeda", "Antigone", "Arachne", "Ariadne", "Atalanta", "Briseis", "Caeneus", "Cassandra", "Cassiopeia", "Clytemnestra", "Danaë", "Deianeira", "Electra", "Europa", "Hecuba", "Helen", "Hermione", "Iphigenia", "Ismene", "Jocasta", "Medea", "Medusa", "Niobe", "Pandora", "Penelope", "Phaedra", "Polyxena", "Semele", "Thrace"] 8 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/HitchhikersGuideToTheGalaxyTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertFalse; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class HitchhikersGuideToTheGalaxyTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void character() { 13 | assertThat(faker.hitchhikersGuideToTheGalaxy().character(), matchesRegularExpression("^(\\w+(\\.?\\s?'?))+$")); 14 | } 15 | 16 | @Test 17 | public void location() { 18 | assertThat(faker.hitchhikersGuideToTheGalaxy().location(), matchesRegularExpression("^(\\w+\\S?\\.?\\s?'?-?)+$")); 19 | } 20 | 21 | @Test 22 | public void marvinQuote() { 23 | assertFalse(faker.hitchhikersGuideToTheGalaxy().marvinQuote().isEmpty()); 24 | } 25 | 26 | @Test 27 | public void planet() { 28 | assertThat(faker.hitchhikersGuideToTheGalaxy().planet(), matchesRegularExpression("^(\\w+-?\\s?)+$")); 29 | } 30 | 31 | @Test 32 | public void quote() { 33 | assertFalse(faker.hitchhikersGuideToTheGalaxy().quote().isEmpty()); 34 | } 35 | 36 | @Test 37 | public void specie() { 38 | assertThat(faker.hitchhikersGuideToTheGalaxy().specie(), matchesRegularExpression("^(\\w+'?\\s?)+$")); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/WeatherTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.hamcrest.CoreMatchers.not; 7 | import static org.hamcrest.Matchers.isEmptyOrNullString; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class WeatherTest extends AbstractFakerTest { 11 | 12 | @Test 13 | public void description() { 14 | assertThat(faker.weather().description(), not(isEmptyOrNullString())); 15 | } 16 | 17 | @Test 18 | public void temperatureCelsius() { 19 | assertThat(faker.weather().temperatureCelsius(), matchesRegularExpression("[-]?\\d+°C")); 20 | } 21 | 22 | @Test 23 | public void temperatureFahrenheit() { 24 | assertThat(faker.weather().temperatureFahrenheit(), matchesRegularExpression("[-]?\\d+°F")); 25 | } 26 | 27 | @Test 28 | public void temperatureCelsiusInRange() { 29 | for (int i = 1; i < 100; i++) { 30 | assertThat(faker.weather().temperatureCelsius(-5, 5), matchesRegularExpression("[-]?[0-5]°C")); 31 | } 32 | } 33 | 34 | @Test 35 | public void temperatureFahrenheitInRange() { 36 | for (int i = 1; i < 100; i++) { 37 | assertThat(faker.weather().temperatureFahrenheit(-5, 5), matchesRegularExpression("[-]?[0-5]°F")); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/IdNumberTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import java.util.Locale; 6 | 7 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class IdNumberTest extends AbstractFakerTest { 11 | 12 | @Test 13 | public void testValid() { 14 | assertThat(faker.idNumber().valid(), matchesRegularExpression("[0-8]\\d{2}-\\d{2}-\\d{4}")); 15 | } 16 | 17 | @Test 18 | public void testInvalid() { 19 | assertThat(faker.idNumber().invalid(), matchesRegularExpression("[0-9]\\d{2}-\\d{2}-\\d{4}")); 20 | } 21 | 22 | @Test 23 | public void testSsnValid() { 24 | assertThat(faker.idNumber().valid(), matchesRegularExpression("[0-8]\\d{2}-\\d{2}-\\d{4}")); 25 | } 26 | 27 | @Test 28 | public void testValidSwedishSsn() { 29 | final Faker f = new Faker(new Locale("sv_SE")); 30 | for (int i = 0; i < 100; i++) { 31 | assertThat(f.idNumber().valid(), matchesRegularExpression("\\d{6}[-+]\\d{4}")); 32 | } 33 | } 34 | 35 | @Test 36 | public void testInvalidSwedishSsn() { 37 | final Faker f = new Faker(new Locale("sv_SE")); 38 | for (int i = 0; i < 100; i++) { 39 | assertThat(f.idNumber().invalid(), matchesRegularExpression("\\d{6}[-+]\\d{4}")); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/resources/en/animal.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | creature: 4 | animal: 5 | name: ["alligator", "crocodile", "alpaca", "ant", "antelope", "ape", "armadillo", "donkey", "baboon", "badger", "bat", "bear", "beaver", "bee", "beetle", "buffalo", "butterfly", "camel", "water buffalo", "caribou", "cat", "cattle", "cheetah", "chimpanzee", "chinchilla", "cicada", "clam", "cockroach", "cod", "coyote", "crab", "cricket", "crow", "raven", "deer", "dinosaur", "dog", "dolphin", "porpoise", "duck", "eagle", "eel", "elephant", "elk", "ferret", "fish", "fly", "fox", "frog", "toad", "gerbil", "giraffe", "gnat", "gnu", "wildebeest", "goat", "goldfish", "goose", "gorilla", "grasshopper", "guinea pig", "hamster", "hare", "hedgehog", "herring", "hippopotamus", "hornet", "horse", "hound", "hyena", "impala", "jackal", "jellyfish", "kangaroo", "wallaby", "koala", "leopard", "lion", "lizard", "llama", "locust", "louse", "macaw", "mallard", "mammoth", "manatee", "marten", "mink", "minnow", "mole", "monkey", "moose", "mosquito", "mouse", "rat", "mule", "muskrat", "otter", "ox", "oyster", "panda", "pig", "platypus", "porcupine", "prairie dog", "pug", "rabbit", "raccoon", "reindeer", "rhinoceros", "salmon", "sardine", "scorpion", "seal", "sea lion", "serval", "shark", "sheep", "skunk", "snail", "snake", "spider", "squirrel", "swan", "termite", "tiger", "trout", "turtle ", "tortoise", "walrus", "wasp", "weasel", "whale", "wolf", "wombat", "woodchuck", "worm", "yak", "yellowjacket", "zebra"] 6 | 7 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/DogTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class DogTest extends AbstractFakerTest { 9 | 10 | @Test 11 | public void name() { 12 | assertThat(faker.dog().name(), matchesRegularExpression("[A-Za-z ]+")); 13 | } 14 | 15 | @Test 16 | public void breed() { 17 | assertThat(faker.dog().breed(), matchesRegularExpression("[A-Za-z ]+")); 18 | } 19 | 20 | @Test 21 | public void sound() { 22 | assertThat(faker.dog().sound(), matchesRegularExpression("[A-Za-z ]+")); 23 | } 24 | 25 | @Test 26 | public void memePhrase() { 27 | assertThat(faker.dog().memePhrase(), matchesRegularExpression("[A-Za-z0-9'\\/ ]+")); 28 | } 29 | 30 | @Test 31 | public void age() { 32 | assertThat(faker.dog().age(), matchesRegularExpression("[A-Za-z ]+")); 33 | } 34 | 35 | @Test 36 | public void gender() { 37 | assertThat(faker.dog().gender(), matchesRegularExpression("[A-Za-z ]+")); 38 | } 39 | 40 | @Test 41 | public void coatLength() { 42 | assertThat(faker.dog().coatLength(), matchesRegularExpression("[A-Za-z ]+")); 43 | } 44 | 45 | @Test 46 | public void size() { 47 | assertThat(faker.dog().size(), matchesRegularExpression("[A-Za-z ]+")); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/resources/en/file.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | file: 4 | extension: ["flac", "mp3", "wav", "bmp", "gif", "jpeg", "jpg", "png", "tiff", "css", "csv", "html", "js", "json", "txt", "mp4", "avi", "mov", "webm", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "odt", "ods", "odp", "pages", "numbers", "key", "pdf"] 5 | mime_type: ["application/atom+xml", "application/ecmascript", "application/EDI-X12", "application/EDIFACT", "application/json", "application/javascript", "application/ogg", "application/pdf", "application/postscript", "application/rdf+xml", "application/rss+xml", "application/soap+xml", "application/font-woff", "application/xhtml+xml", "application/xml-dtd", "application/xop+xml", "application/zip", "application/gzip", "audio/basic", "audio/L24", "audio/mp4", "audio/mpeg", "audio/ogg", "audio/vorbis", "audio/vnd.rn-realaudio", "audio/vnd.wave", "audio/webm", "image/gif", "image/jpeg", "image/pjpeg", "image/png", "image/svg+xml", "image/tiff", "image/vnd.microsoft.icon", "message/http", "message/imdn+xml", "message/partial", "message/rfc822", "model/example", "model/iges", "model/mesh", "model/vrml", "model/x3d+binary", "model/x3d+vrml", "model/x3d+xml", "multipart/mixed", "multipart/alternative", "multipart/related", "multipart/form-data", "multipart/signed", "multipart/encrypted", "text/cmd", "text/css", "text/csv", "text/html", "text/javascript", "text/plain", "text/vcard", "text/xml", "video/mpeg", "video/mp4", "video/ogg", "video/quicktime", "video/webm", "video/x-matroska", "video/x-ms-wmv", "video/x-flv"] 6 | -------------------------------------------------------------------------------- /src/main/resources/en/team.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | team: 4 | creature: ['ants', 'bats', 'bears', 'bees', 'birds', 'buffalo', 'cats', 'chickens', 'cattle', 'dogs', 'dolphins', 'ducks', 'elephants', 'fishes', 'foxes', 'frogs', 'geese', 'goats', 'horses', 'kangaroos', 'lions', 'monkeys', 'owls', 'oxen', 'penguins', 'people', 'pigs', 'rabbits', 'sheep', 'tigers', 'whales', 'wolves', 'zebras', 'banshees', 'crows', 'black cats', 'chimeras', 'ghosts', 'conspirators', 'dragons', 'dwarves', 'elves', 'enchanters', 'exorcists', 'sons', 'foes', 'giants', 'gnomes', 'goblins', 'gooses', 'griffins', 'lycanthropes', 'nemesis', 'ogres', 'oracles', 'prophets', 'sorcerors', 'spiders', 'spirits', 'vampires', 'warlocks', 'vixens', 'werewolves', 'witches', 'worshipers', 'zombies', 'druids'] 5 | name: 6 | - "#{Address.state} #{creature}" 7 | sport: ['baseball', 'basketball', 'football', 'hockey', 'rugby', 'lacrosse', 'soccer', 'buzkashi', 'cricket', 'kabaddi', 'archery', 'field hockey', 'wrestling', 'association', 'sumo', 'dandi biyo', 'league', 'arnis', 'bandy', 'taekwondo', 'volley ball', 'oil wrestling', 'handball', 'pesäpallo', 'rugby union', 'golf', 'bull fighting', 'shooting', 'gymnastics', 'water polo'] 8 | mascot: ['Raymond', 'Bailey', 'Rocky', 'Screech', 'Steely McBeam', 'Nordy', 'Hugo', 'Griz', 'Iceburgh', 'Mr. Redlegs', 'Benny the Bull', 'Big Red', 'Suns Gorilla', 'Pirate Parrot', 'Ragar the Viking', 'JazzBear', 'Wally the Green Monster', 'Burnie', 'K.C. Wolf', 'Sausages', 'Mr. Met', 'Youppi', 'The Raptor', 'Jaxson De Ville', 'Phanatic'] 9 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/ElderScrollsTest.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package com.github.javafaker; 4 | 5 | import org.junit.Test; 6 | 7 | import static org.hamcrest.Matchers.isEmptyOrNullString; 8 | import static org.hamcrest.Matchers.not; 9 | import static org.junit.Assert.assertThat; 10 | 11 | public class ElderScrollsTest extends AbstractFakerTest { 12 | 13 | @Test 14 | public void testCity() { 15 | assertThat(faker.elderScrolls().city(), not(isEmptyOrNullString())); 16 | } 17 | 18 | @Test 19 | public void testCreature() { 20 | assertThat(faker.elderScrolls().creature(), not(isEmptyOrNullString())); 21 | } 22 | 23 | @Test 24 | public void testDragon() { 25 | assertThat(faker.elderScrolls().dragon(), not(isEmptyOrNullString())); 26 | } 27 | 28 | @Test 29 | public void testFirstName() { 30 | assertThat(faker.elderScrolls().firstName(), not(isEmptyOrNullString())); 31 | } 32 | 33 | @Test 34 | public void testLastName() { 35 | assertThat(faker.elderScrolls().lastName(), not(isEmptyOrNullString())); 36 | } 37 | 38 | @Test 39 | public void testRace() { 40 | assertThat(faker.elderScrolls().race(), not(isEmptyOrNullString())); 41 | } 42 | 43 | @Test 44 | public void testRegion() { 45 | assertThat(faker.elderScrolls().region(), not(isEmptyOrNullString())); 46 | } 47 | 48 | @Test 49 | public void testQuote() { 50 | assertThat(faker.elderScrolls().quote(), not(isEmptyOrNullString())); 51 | } 52 | } -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/integration/Issue194SlashFormatRegexIT.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.integration; 2 | 3 | import com.github.javafaker.Faker; 4 | import org.junit.Test; 5 | 6 | import java.util.Locale; 7 | 8 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 9 | import static org.junit.Assert.assertThat; 10 | 11 | public class Issue194SlashFormatRegexIT { 12 | 13 | @Test 14 | public void enGBZipCodeReturnsProperRegexifiedValue() { 15 | final Locale uk = new Locale("en-GB"); 16 | 17 | final String postalCode = new Faker(uk).address().zipCode(); 18 | 19 | assertThat(postalCode, matchesRegularExpression("[A-PR-UWYZ]([A-HK-Y][0-9][ABEHMNPRVWXY0-9]?|[0-9][ABCDEFGHJKPSTUW0-9]?) [0-9][ABD-HJLNP-UW-Z]{2}")); 20 | } 21 | 22 | @Test 23 | public void enCAZipCodeReturnsProperRegexifiedValue() { 24 | final Locale uk = new Locale("en-CA"); 25 | 26 | final String postalCode = new Faker(uk).address().zipCode(); 27 | 28 | assertThat(postalCode, matchesRegularExpression("[A-CEJ-NPR-TVXY][0-9][A-CEJ-NPR-TV-Z] ?[0-9][A-CEJ-NPR-TV-Z][0-9]")); 29 | } 30 | 31 | @Test 32 | public void viZipCodeReturnsProperRegexifiedValue() { 33 | final Locale uk = new Locale("vi"); 34 | 35 | final String postalCode = new Faker(uk).address().zipCode(); 36 | 37 | assertThat(postalCode, matchesRegularExpression("[A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}")); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/matchers/CountOfCharactersMatcher.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker.matchers; 2 | 3 | import org.hamcrest.Description; 4 | import org.hamcrest.Factory; 5 | import org.hamcrest.Matcher; 6 | import org.hamcrest.TypeSafeMatcher; 7 | 8 | public class CountOfCharactersMatcher extends TypeSafeMatcher { 9 | 10 | private final char character; 11 | private Matcher matcher; 12 | 13 | public CountOfCharactersMatcher(char character, Matcher matcher) { 14 | this.character = character; 15 | this.matcher = matcher; 16 | } 17 | 18 | @Factory 19 | public static Matcher countOf(char character, Matcher matcher) { 20 | return new CountOfCharactersMatcher(character, matcher); 21 | } 22 | 23 | @Override 24 | protected boolean matchesSafely(String item) { 25 | int count = count(item); 26 | return matcher.matches(count); 27 | } 28 | 29 | private int count(String item) { 30 | int count = 0; 31 | for (char c : item.toCharArray()) { 32 | count += (c == character) ? 1 : 0; 33 | } 34 | return count; 35 | } 36 | 37 | @Override 38 | public void describeTo(Description description) { 39 | description.appendText("count of " + character + " ").appendDescriptionOf(matcher); 40 | } 41 | 42 | @Override 43 | protected void describeMismatchSafely(String item, Description mismatchDescription) { 44 | mismatchDescription.appendText("count of " + character + " "); 45 | matcher.describeMismatch(count(item), mismatchDescription); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/resources/en/crypto_coin.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | crypto_coin: 4 | coin: 5 | - "Bitcoin, BTC, https://i.imgur.com/psBNOBq.png" 6 | - "Bitcoin Cash, BCC, https://i.imgur.com/ViTjr9u.png" 7 | - "Bitcoin Gold, BTG, https://i.imgur.com/l9cVE7c.png" 8 | - "Bitcoin SV, BSV, https://i.imgur.com/DkixrAc.png" 9 | - "Binance Coin, BNB, https://i.imgur.com/2HJr7OR.png" 10 | - "Cardano, ADA, https://i.imgur.com/8qGU4zg.png" 11 | - "Dash, DASH, https://i.imgur.com/2uX91cb.png" 12 | - "Decred, DCR, https://i.imgur.com/nURXAC2.png" 13 | - "EOS.IO, EOS, https://i.imgur.com/Cr2w77s.png" 14 | - "Ethereum, ETH, https://i.imgur.com/uOPFCXj.png" 15 | - "Ethereum Classic, ETC, https://i.imgur.com/8wBtmQA.png" 16 | - "IOTA, IOT, https://i.imgur.com/DGFCOVt.png" 17 | - "Litecoin, LTC, https://i.imgur.com/EFz61Ei.png" 18 | - "Monero, XMR, https://i.imgur.com/pnupcJM.png" 19 | - "NEM, XEM, https://i.imgur.com/SJ8NteF.png" 20 | - "NEO, NEO, https://i.imgur.com/BmtVrJi.png" 21 | - "Ripple, XRP, https://i.imgur.com/GjAPSsL.png" 22 | - "Stellar, XLM, https://i.imgur.com/COLIHUE.png" 23 | - "Tether, USDT, https://i.imgur.com/xk6pQZy.png" 24 | - "TRON, TRX, https://i.imgur.com/grG05ZK.png" 25 | - "Zcash, ZEC, https://i.imgur.com/mX3r4j9.png" 26 | -------------------------------------------------------------------------------- /src/main/resources/en/stranger_thing.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | stranger_things: 4 | character: [ 5 | "Joyce", 6 | "Lonnie", 7 | "Jonathan", 8 | "Will", 9 | "Nancy", 10 | "Mike", 11 | "Terry", 12 | "Becky", 13 | "Eleven", 14 | "Jim", 15 | "Diane", 16 | "Barbara", 17 | "Steve", 18 | "Dustin", 19 | "Lucas", 20 | "Demogorgon" 21 | ] 22 | quote: [ 23 | "I just didn’t want you to think I was such a wastoid, you know?", 24 | "You’re going to take out the demigorgon with a slingshot?", 25 | "Mornings are for coffee and contemplation.", 26 | "Eggos?", 27 | "This is not yours to fix alone. You act like you’re all alone out there in the world, but you’re not. You’re not alone.", 28 | "My God, is she Russian?", 29 | "Maybe I’m crazy, maybe I’m out of my mind! But God help me, I will keep these lights up until the day I die if I think there’s a chance that Will’s still out there!", 30 | " Am I dreaming, or is that you, Harrington?", 31 | "How do you know it’s not just a lizard?....Because his face opened up and he ate my cat!", 32 | "Use the shampoo and conditioner and when your hair’s damp, not wet, okay? When it’s damp, you do four puffs of the Farrah Fawcett spray.", 33 | "She will not be able to resist these pearls. *Purrs*", 34 | "So, Jonathan, how was the pull-out?", 35 | "I don’t want you to get hurt at all. And I don’t wanna lose you. Just make sure you heat up some real food. Not just Eggos." 36 | ] 37 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/StarCraftTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.hamcrest.Matchers.*; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class StarCraftTest extends AbstractFakerTest { 10 | 11 | private final String noLeadingTrailingWhitespaceRegex = "^(?! )[A-Za-z0-9' ]*(? enDefaultCountries = (List) en.fetchObject("address.default_country"); 33 | final List enUsDefaultCountries = (List) en_US.fetchObject("address.default_country"); 34 | 35 | assertThat(enDefaultCountries, hasSize(1)); 36 | assertThat(enUsDefaultCountries, hasSize(3)); 37 | 38 | assertThat("the default country for en is not en_US", enDefaultCountries, is(not(enUsDefaultCountries))); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/resources/en/family_guy.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | family_guy: 4 | character: ["Peter Griffin", "Lois Griffin", "Meg Griffin", "Chris Griffin", "Stewie Griffin", "Brian Griffin", "Francis Griffin", "Mickey McFinnigan", "Thelma Griffin", "Karen Griffin", "Carter Pewterschmidt", "Barabara Pewterschmidt", "Glenn Quagmire", "Cleveland Brown", "Joe Swanson", "Bonnie Swanson", "Mort Goldman", "Tom Tucker", "Joyce Kinney", "Diane Simmons", "Ollie Williams", "Tricia Takanawa", "Fouad", "Principal Shephard", "Mayor Adam West", "Carl", "Consuela", "God", "Horace", "James Woods", "Evil Monkey"] 5 | location: ["Cleveland's Deli", "Drunken Clam", "Goldman's Pharmacy", "Happy-Go-Lucky Toy Factory", "Jack's Joke Shop", "James Woods High", "Pawtucket Brewery", "Quahog 5 News", "Spooner Street"] 6 | quote: ["It’s Peanut Butter Jelly Time.", "I’ve got an idea–an idea so smart that my head would explode if I even began to know what I’m talking about.", "A degenerate, am I? Well, you are a festisio! See? I can make up words too, sister.", "Now I may be an idiot, but there’s one thing I am not sir, and that sir, is an idiot.", "Isn’t ‘bribe’ just another word for ‘love’?", "I am so not competitive. In fact, I am the least non-competitive. So I win.", "Hey, don't try to take this away from me. This is the only thing I've ever been good at. Well, this and timing my farts to a thunderstorm.", "Joe, gag on my fat dauber.", "People in love can overcome anything.", "Amazing. One second of a stranger's voice on a phone, and you've got full Bollywood.", "You know, this is great guys. Drinking and eating garbage. I'm glad we all took a mental health day."] 7 | 8 | -------------------------------------------------------------------------------- /src/main/resources/en/stargate.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | stargate: 4 | characters: ["Jack O'Neill", "Teal'c", "Daniel Jackson", "Samantha Carter", "Janet Frasier", "George Hammond", "Jonas Quinn", "Cameron Mitchell", "Vala Mal Doran", "Kawalsky", "Jacob Carter", "Kasuf", "Sha're", "Skaara", "Thor", "Anubis", "Apophis", "Ba'al", "Cronus", "Hathor", "Heru-ur", "Klorel", "Ra", "Amonet", "Osiris", "Sokar", "Bra'tac", "Lantash", "Selmak", "Jolinar", "Martouf", "Cassandra", "Harlan"] 5 | planets: ["Abydos", "Altair", "Asuras", "Athos", "Celestis", "Chulak", "Dakara", "Earth", "Langara", "Lantea", "Orilla", "P3X-888", "Sateda", "Tollana", "Vorash"] 6 | quotes: [ 7 | "What is an Oprah?", 8 | "Teal'c, look scary and take point.", 9 | "Things will not calm down, Daniel Jackson. They will, in fact, calm up.", 10 | "Undomesticated equines could not remove me.", 11 | "General, request permission to beat the crap out of this man.", 12 | "In my culture, I would be well within my rights to dismember you.", 13 | "Hey, if you'd been listening, you'd know that Nintendos pass through everything!", 14 | "You know, I've never been on a stakeout before. Shouldn't we have donuts or something?", 15 | "It's always suicide mission this, save the planet that. No one ever just stops by to say hi anymore.", 16 | "I would prefer not to consume bovine lactose at any temperature.", 17 | "I am not Lucy.", 18 | "I did not intend for my statement to be humorous.", 19 | "Indeed.", 20 | "You ended that sentence with a preposition. Bastard!" 21 | ] 22 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/DuneTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import com.github.javafaker.repeating.Repeat; 4 | import org.junit.Test; 5 | 6 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 7 | import static org.junit.Assert.assertThat; 8 | 9 | public class DuneTest extends AbstractFakerTest { 10 | 11 | @Test 12 | public void character() { 13 | assertThat(faker.dune().character(), matchesRegularExpression("[A-Za-z '\\-\"]+")); 14 | } 15 | 16 | @Test 17 | public void title() { 18 | assertThat(faker.dune().title(), matchesRegularExpression("[A-Za-z ]+")); 19 | } 20 | 21 | @Test 22 | public void planet() { 23 | assertThat(faker.dune().planet(), matchesRegularExpression("[A-Za-z ]+")); 24 | } 25 | 26 | @Test 27 | public void quote() { 28 | assertThat(faker.dune().quote(), matchesRegularExpression("\\P{Cc}+")); 29 | } 30 | 31 | @Test 32 | @Repeat(times = 10000) 33 | public void randomQuote() { 34 | assertThat( 35 | faker.dune().quote(faker.options().option(Dune.Quote.class)), 36 | matchesRegularExpression("\\P{Cc}+")); 37 | } 38 | 39 | @Test 40 | public void saying() { 41 | assertThat(faker.dune().saying(), matchesRegularExpression("\\P{Cc}+")); 42 | } 43 | 44 | @Test 45 | @Repeat(times = 10000) 46 | public void randomSaying() { 47 | assertThat( 48 | faker.dune().saying(faker.options().option(Dune.Saying.class)), 49 | matchesRegularExpression("\\P{Cc}+")); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/github/javafaker/Space.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | public class Space { 4 | 5 | private final Faker faker; 6 | 7 | protected Space(Faker faker) { 8 | this.faker = faker; 9 | } 10 | 11 | public String planet() { 12 | return faker.resolve("space.planet"); 13 | } 14 | 15 | public String moon() { 16 | return faker.resolve("space.moon"); 17 | } 18 | 19 | public String galaxy() { 20 | return faker.resolve("space.galaxy"); 21 | } 22 | 23 | public String nebula() { 24 | return faker.resolve("space.nebula"); 25 | } 26 | 27 | public String starCluster() { 28 | return faker.resolve("space.star_cluster"); 29 | } 30 | 31 | public String constellation() { 32 | return faker.resolve("space.constellation"); 33 | } 34 | 35 | public String star() { 36 | return faker.resolve("space.star"); 37 | } 38 | 39 | public String agency() { 40 | return faker.resolve("space.agency"); 41 | } 42 | 43 | public String agencyAbbreviation() { 44 | return faker.resolve("space.agency_abv"); 45 | } 46 | 47 | public String nasaSpaceCraft() { 48 | return faker.resolve("space.nasa_space_craft"); 49 | } 50 | 51 | public String company() { 52 | return faker.resolve("space.company"); 53 | } 54 | 55 | public String distanceMeasurement() { 56 | return faker.number().numberBetween(10, 100) + ' ' + faker.resolve("space.distance_measurement"); 57 | } 58 | 59 | public String meteorite() { 60 | return faker.resolve("space.meteorite"); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/resources/en/grateful_dead.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | grateful_dead: 4 | players: [ "Jerry Garcia", 5 | "Bob Weir", 6 | "Bill Kreutzmann", 7 | "Phil Lesh", 8 | "Ron McKernan", 9 | "Robert Hunter", 10 | "Brent Mydland", 11 | "Donna Jean Godchaux", 12 | "Keith Godchaux", 13 | "Bruce Hornsby", 14 | "John Barlow" ] 15 | songs: [ "Touch of Grey", 16 | "Althea", 17 | "Ripple", 18 | "Truckin", 19 | "Eyes of the World", 20 | "Scarlet Begonias", 21 | "Friend of the Devil", 22 | "Uncle Johns Band", 23 | "China Cat Sunflower", 24 | "Fire on the Mountain", 25 | "Sugar Magnolia", 26 | "I Know You Rider", 27 | "Franklins Tower", 28 | "Me and My Uncle", 29 | "Box of Rain", 30 | "Sugaree", 31 | "St Stephen", 32 | "Jack Straw", 33 | "Morning Dew", 34 | "Wharf Rat", 35 | "The Other One", 36 | "Casey Jones", 37 | "Hurts Me Too", 38 | "Dark Star", 39 | "Brokedown Palace", 40 | "Playing in the Band", 41 | "Cumberland Blues", 42 | "New Speedway Boogie", 43 | "US Blues", 44 | "The Music Never Stopped", 45 | "Black Muddy River", 46 | "Looks Like Rain", 47 | "Bird Song", 48 | "Cassidy"] 49 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/CountryTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import com.github.javafaker.repeating.Repeat; 4 | import org.junit.Test; 5 | 6 | import static com.github.javafaker.matchers.IsStringWithContents.isStringWithContents; 7 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class CountryTest extends AbstractFakerTest { 11 | 12 | @Test 13 | @Repeat(times=10) 14 | public void testFlag() { 15 | String flag = faker.country().flag(); 16 | assertThat(flag, matchesRegularExpression("^http:\\/\\/flags.fmcdn\\.net\\/data\\/flags\\/w580\\/[a-zA-Z0-9_]+\\.png$")); 17 | } 18 | 19 | 20 | @Test 21 | public void testCode2() { 22 | assertThat(faker.country().countryCode2(), matchesRegularExpression("([a-z]{2})")); 23 | } 24 | 25 | @Test 26 | public void testCode3() { 27 | assertThat(faker.country().countryCode3(), matchesRegularExpression("([a-z]{3})")); 28 | } 29 | 30 | @Test 31 | public void testCapital() { 32 | assertThat(faker.country().capital(), matchesRegularExpression("([\\w'-]+ ?)+")); 33 | } 34 | 35 | @Test 36 | public void testCurrency() { 37 | assertThat(faker.country().currency(), matchesRegularExpression("([A-Za-zÀ-ÿ'’()-]+ ?)+")); 38 | } 39 | 40 | @Test 41 | public void testCurrencyCode() { 42 | assertThat(faker.country().currencyCode(), matchesRegularExpression("([\\w-’í]+ ?)+")); 43 | } 44 | 45 | @Test 46 | public void testName() { 47 | assertThat(faker.country().name(), isStringWithContents()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/resources/en-GB.yml: -------------------------------------------------------------------------------- 1 | en-GB: 2 | faker: 3 | address: 4 | postcode: /[A-PR-UWYZ]([A-HK-Y][0-9][ABEHMNPRVWXY0-9]?|[0-9][ABCDEFGHJKPSTUW0-9]?) [0-9][ABD-HJLNP-UW-Z]{2}/ 5 | county: [Avon, Bedfordshire, Berkshire, Borders, Buckinghamshire, Cambridgeshire, Central, Cheshire, Cleveland, Clwyd, Cornwall, County Antrim, County Armagh, County Down, County Fermanagh, County Londonderry, County Tyrone, Cumbria, Derbyshire, Devon, Dorset, Dumfries and Galloway, Durham, Dyfed, East Sussex, Essex, Fife, Gloucestershire, Grampian, Greater Manchester, Gwent, Gwynedd County, Hampshire, Herefordshire, Hertfordshire, Highlands and Islands, Humberside, Isle of Wight, Kent, Lancashire, Leicestershire, Lincolnshire, Lothian, Merseyside, Mid Glamorgan, Norfolk, North Yorkshire, Northamptonshire, Northumberland, Nottinghamshire, Oxfordshire, Powys, Rutland, Shropshire, Somerset, South Glamorgan, South Yorkshire, Staffordshire, Strathclyde, Suffolk, Surrey, Tayside, Tyne and Wear, Warwickshire, West Glamorgan, West Midlands, West Sussex, West Yorkshire, Wiltshire, Worcestershire] 6 | uk_country: [England, Scotland, Wales, Northern Ireland] 7 | country_code: ['GB'] 8 | default_country: [England, Scotland, Wales, Northern Ireland] 9 | internet: 10 | domain_suffix: [co.uk, com, biz, info, name] 11 | phone_number: 12 | formats: ['01#### #####', '01### ######', '01#1 ### ####', '011# ### ####', '02# #### ####', '03## ### ####', '055 #### ####', '056 #### ####', '0800 ### ####', '08## ### ####', '09## ### ####', '016977 ####', '01### #####', '0500 ######', '0800 ######'] 13 | cell_phone: 14 | formats: ['074## ######', '075## ######', '076## ######', '077## ######', '078## ######', '079## ######'] 15 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/FinanceTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit; 4 | import org.junit.Test; 5 | 6 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 7 | import static org.hamcrest.Matchers.is; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class FinanceTest extends AbstractFakerTest { 11 | 12 | @Test 13 | public void creditCard() { 14 | for (int i = 0; i < 100; i++) { 15 | final String creditCard = faker.finance().creditCard(); 16 | assertCardLuhnDigit(creditCard); 17 | } 18 | } 19 | 20 | private void assertCardLuhnDigit(String creditCard) { 21 | final String creditCardStripped = creditCard.replaceAll("-", ""); 22 | assertThat(LuhnCheckDigit.LUHN_CHECK_DIGIT.isValid(creditCardStripped), is(true)); 23 | } 24 | 25 | @Test 26 | public void bic() { 27 | assertThat(faker.finance().bic(), matchesRegularExpression("([A-Z]){4}([A-Z]){2}([0-9A-Z]){2}([0-9A-Z]{3})?")); 28 | } 29 | 30 | @Test 31 | public void iban() { 32 | assertThat(faker.finance().iban(), matchesRegularExpression("[A-Z]{2}\\p{Alnum}{13,30}")); 33 | } 34 | 35 | @Test 36 | public void ibanWithCountryCode() { 37 | assertThat(faker.finance().iban("DE"), matchesRegularExpression("DE\\d{20}")); 38 | } 39 | 40 | @Test 41 | public void creditCardWithType() { 42 | for(CreditCardType type : CreditCardType.values()) { 43 | final String creditCard = faker.finance().creditCard(type); 44 | assertCardLuhnDigit(creditCard); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/resources/en/star_trek.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | star_trek: 4 | character: ["James Tiberius Kirk", "Jean-Luc Picard", "Benjamin Sisko", "Kira Nerys", "Odo", "Jadzia Dax", "Julian Bashir", "Miles O'Brien", "Quark", "Jake Sisko", "Kathryn Janeway", "Chakotay", "Tuvok", "Tom Paris", "B'Elanna Torres", "Harry Kim", "Seven of Nine", "The Doctor", "Neelix", "Kes", "Jonathan Archer", "T'Pol", "Charles Tucker III", "Malcolm Reed", "Travis Mayweather", "Hoshi Sato", "Phlox", "Data", "William T. Riker", "Geordi La Forge", "Worf", "Beverly Crusher", "Deanna Troi", "Natasha Yar", "Wesley Crusher", "Spock", "Leonard McCoy", "Montgomery Scott", "Hikaru Sulu", "Pavel Chekov", "Nyota Uhuru"] 5 | location: ["Qo'noS", "Romulus", "Bajor", "Vulcan", "Neutral Zone", "Alpha Quadrant", "Beta Quadrant", "Delta Quadrant", "Gamma Quadrant", "Tau Ceti Prime", "Wolf 359", "Thalos VII", "Cardassia", "Trillius Prime", "Badlands", "Betazed", "Risa", "Deep Space Nine", "Ferenginar", "The Briar Patch", "Khitomer"] 6 | specie: ["Breen", "El-Aurian", "Jem'Hadar", "Kazon", "Ocampa", "Q", "Ferengi", "Klingon", "Talaxian", "Vidiian", "Cardassian", "Vulcan", "Borg", "Romulan", "Vorta", "Andorian", "Bajoran", "Betazoid"] 7 | villain: ["Q", "Gorn", "Khan Noonien Singh", "Ru'afo", "Maltz", "Kruge", "Ayel", "Admiral Marcus", "Martia", "Lt. Valeris", "V'ger", "God of Sha Ka Ree", "Admiral Dougherty", "Nero", "Krall", "Tolian Soran", "Shinzon", "General Chang", "Lursa", "B'Etor", "Borg Queen"] 8 | klingon: ["tlhIngan maH", "bogh tlhInganpu', SuvwI'pu' moj, Hegh", "SuvmeH 'ej charghmeH bogh tlhInganpu'", "DabuQlu'DI' yISuv", "qa' wIje'meH maSuv", "bI'IQchugh yIvang", "tIqIpqu' 'ej nom tIqIp", "lumbe' tlhInganpu'.", "Dubotchugh yIpummoH", "mataHmeH maSachnIS"] 9 | -------------------------------------------------------------------------------- /src/main/resources/en/greek_philosophers.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | greek_philosophers: 4 | names: ["Plato", "Aristotle", "Pythagoras", "Heraclitus", "Parmenides", "Democritus", "Zeno of Elea", "Epicurus", "Anaxagoras", "Diogenes", "Antisthenes", "Gorgias", "Hippocrates", "Plutarch", "Proclus", "Chrysippus", "Solon", "Archimedes", "Thucydides", "Arcesilaus", "Posidonius", "Galen"] 5 | quotes: [ 6 | "Quality is not an act, it is a habit.", 7 | "Only the educated are free.", 8 | "Control thy passions lest they take vengence on thee.", 9 | "Love is composed of a single soul inhabiting two bodies.", 10 | "Rhetoric is the art of ruling the minds of men.", 11 | "The unexamined life is not worth living.", 12 | "There was never a genius without a tincture of madness.", 13 | "Dignity does not consist in possessing honors, but in deserving them.", 14 | "Most people would rather give than get affection.", 15 | "Beware the barrenness of a busy life.", 16 | "The secret to humor is surprise.", 17 | "Pleasure in the job puts perfection in the work.", 18 | "Philosophy is the highest music.", 19 | "The virtue of justice consists in moderation, as regulated by wisdom.", 20 | "Know how to listen, and you will profit even from those who talk badly.", 21 | "A few vices are sufficient to darken many virtues.", 22 | "It is impossible to begin to learn that which one thinks one already knows.", 23 | "It's not what happens to you, but how you react to it that matters.", 24 | "The mind is not a vessel to be filled but a fire to be kindled.", 25 | "Good habits formed at youth make all the difference.", 26 | ] 27 | -------------------------------------------------------------------------------- /src/main/resources/en/rock_band.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | rock_band: 4 | name: ["Led Zeppelin", "The Beatles", "Pink Floyd", "The Jimi Hendrix Experience", "Van Halen", "Queen", "The Eagles", "Metallica", "U2", "Bob Marley and the Wailers", "The Police", "The Doors", "Stone Temple Pilots", "Rush", "Genesis", "Prince and the Revolution", "Yes", "Earth Wind and Fire", "The Bee Gees", "The Rolling Stones", "The Beach Boys", "Soundgarden", "The Who", "Steely Dan", "James Brown and the JBs", "AC/DC", "Fleetwood Mac", "Crosby, Stills, Nash and Young", "The Allman Brothers", "ZZ Top", "Aerosmith", "Cream", "Bruce Springsteen & The E Street Band", "The Grateful Dead", "Guns 'N Roses", "Pearl Jam", "Boston", "Dire Straits", "King Crimson", "Parliament Funkadelic", "Red Hot Chili Peppers", "Bon Jovi", "Dixie Chicks", "Foreigner", "David Bowie and The Spiders From Mars", "The Talking Heads", "Jethro Tull", "The Band", "The Beastie Boys", "Nirvana", "Rage Against The Machine", "Sly and the Family Stone", "The Clash", "Tool", "Journey", "No Doubt", "Creedence Clearwater Revival", "Deep Purple", "Alice In Chains", "Orbital", "Little Feat", "Duran Duran", "Living Colour", "Frank Zappa and the Mothers of Invention", "The Carpenters", "Audioslave", "The Pretenders", "Primus", "Blondie", "Black Sabbath", "Lynyrd Skynyrd", "Sex Pistols", "Isaac Hayes and the Movement", "R.E.M.", "Traffic", "Buffalo Springfield", "Derek and the Dominos", "The Jackson Five", "The O'Jays", "Harold Melvin and the Blue Notes", "Underworld", "Thievery Corporation", "Motley Crue", "Janis Joplin and Big Brother and the Holding Company", "Blind Faith", "The Animals", "The Roots", "The Velvet Underground", "The Kinks", "Radiohead", "The Scorpions", "Kansas", "Iron Maiden", "Motorhead", "Judas Priest", "The Orb", "The Cure", "Coldplay", "Slayer", "Black Eyed Peas"] 5 | -------------------------------------------------------------------------------- /src/main/resources/tr.yml: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | tr: 3 | faker: 4 | name: 5 | first_name: [Mehmet, Yiğit, Batuhan, Burak, İrem, Buse, Selim, Caner] 6 | last_name: [Davut, Sağdıç, Özdemir, Özkanlı, Ekkaldır, Zengel, Eren] 7 | prefix: [Sn., Av., Dr.] 8 | title: 9 | job: ['Müdür','Şef','Koordinatör', 'Ajan','Hacı','Başkan','Reyiz'] 10 | name: 11 | - "#{prefix} #{first_name} #{last_name}" 12 | - "#{first_name} #{last_name}" 13 | - "#{last_name} #{first_name}" 14 | name_with_middle: 15 | - "#{prefix} #{first_name} #{last_name} #{last_name}" 16 | - "#{first_name} #{last_name} #{last_name}" 17 | - "#{first_name} #{last_name} #{last_name}" 18 | - "#{first_name} #{last_name} #{last_name}" 19 | - "#{first_name} #{last_name} #{last_name}" 20 | 21 | internet: 22 | free_email: [gmail.com, hotmail.com.tr, yandex.com.tr] 23 | domain_suffix: [co, com, com.tr, net, org] 24 | safe_email: ['mesela.com'] 25 | 26 | phone_number: 27 | formats: ["90-###-###-####", "90.###.###.####", "90 ### ### ####", "90##########"] 28 | 29 | address: 30 | city_name: ['İstanbul', 'İzmir', 'Eskişehir', 'Şırnak', 'Edirne', 'Van' ] 31 | city: 32 | - "#{city_name}" 33 | country: [Afganistan, Amerika Birleşik Devletleri, Fransa, Hollanda, Belçika, Nepal, Hindistan, Kuala Lumpur, Rusya] 34 | default_country: [Turkey] 35 | 36 | book: 37 | title: ['Taht Oyunları', 'Maymunlar Gezegeni', 'Benim Adım Kırmızı', 'Uykuların Doğusu', 'Yılanların Öcü'] 38 | author: "#{Name.name}" 39 | publisher: ['Babıali Kültür Yayıncılığı', 'İletişim Yayınları', 'Turkuvaz Kitap', 'Kaynak Yayınları'] 40 | quote: ['Sabır acıdır, meyvesi tatlıdır', 'Dost kara günde belli olur', 'Çıkmayan candan umit kesilmez', 'Gözden uzak olan gönülden de uzak olur.'] 41 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/SlackEmojiTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 6 | import static org.junit.Assert.assertThat; 7 | 8 | public class SlackEmojiTest extends AbstractFakerTest { 9 | 10 | private static final String EMOTICON_REGEX = ":([\\w-]+):"; 11 | 12 | @Test 13 | public void people() { 14 | assertThat(faker.slackEmoji().people(), matchesRegularExpression(EMOTICON_REGEX)); 15 | } 16 | 17 | @Test 18 | public void nature() { 19 | assertThat(faker.slackEmoji().nature(), matchesRegularExpression(EMOTICON_REGEX)); 20 | } 21 | 22 | @Test 23 | public void food_and_drink() { 24 | assertThat(faker.slackEmoji().foodAndDrink(), matchesRegularExpression(EMOTICON_REGEX)); 25 | } 26 | 27 | @Test 28 | public void celebration() { 29 | assertThat(faker.slackEmoji().celebration(), matchesRegularExpression(EMOTICON_REGEX)); 30 | } 31 | 32 | @Test 33 | public void activity() { 34 | assertThat(faker.slackEmoji().activity(), matchesRegularExpression(EMOTICON_REGEX)); 35 | } 36 | 37 | @Test 38 | public void travel_and_places() { 39 | assertThat(faker.slackEmoji().travelAndPlaces(), matchesRegularExpression(EMOTICON_REGEX)); 40 | } 41 | 42 | @Test 43 | public void objects_and_symbols() { 44 | assertThat(faker.slackEmoji().objectsAndSymbols(), matchesRegularExpression(EMOTICON_REGEX)); 45 | } 46 | 47 | @Test 48 | public void custom() { 49 | assertThat(faker.slackEmoji().custom(), matchesRegularExpression(EMOTICON_REGEX)); 50 | } 51 | 52 | @Test 53 | public void emoji() { 54 | assertThat(faker.slackEmoji().emoji(), matchesRegularExpression(EMOTICON_REGEX)); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/resources/en/football.yml: -------------------------------------------------------------------------------- 1 | en: 2 | faker: 3 | football: 4 | teams: ["Real Madrid", "FC Barcelona", "Valencia CF", "Atletico Madrid", "Manchester United", "Chelsea", "Liverpool", "Arsenal", "Tottenham Hotspur", "AC Milan", "Inter Milan", "AS Roma", "Juventus", "Bayern Munich", "Borussia Dortmund", "Schalke 04", "Benfica", "Galatasaray", "PSV Eindhoven", "LA Galaxy"] 5 | players: ["Lionel Messi", "Gerard Pique", "Sergio Ramos", "Cristiano Ronaldo", "David De Gea", "Paul Pogba", "Antoine Griezmann", "Alvaro Morata", "Andres Iniesta", "Roberto Firmino", "Mohammed Salah", "Harry Kane", "Delle Alli", "Arjen Robben", "Franck Ribery", "Marco Reus", "Robert Lewandoski", "Zlatan Ibrahimovic", "Edinson Cavani", "Sergio Aguero", "Neymar", "Mesut Ozil", "Gianluigi Buffon", "Willian", "Manuel Neuer", "Juan Mata", "Manuel Neuer", "Cesc Fabregas", "Gareth Bale", "Eden Hazard", "Mario Mandzukic"] 6 | coaches: ["Ernesto Valverde", "Zinedine Zidane", "Jose Mourinho", "Antonio Conte", "Jurgen Klopp", "Mauricio Pochettino", "Diego Simeone", "Massimiliano Allegri", "Jupp Heyneckes", "Arsene Wenger", "Jorge Sampaoli", "Fernando Santos", "Didier Deschamps", "Joachim Low", "Julen Lopetegui", "Mauricio Pochettino", "Unai Emery", "Massimiliano Allegri" ] 7 | competitions: ["UEFA European Championship", "Asian Cup", "African Cup of Nations", "Copa America", "UEFA Champions League", "FIFA World Cup", "UEFA Europa League", "Serie A", "Barclays Premier League", "Bundesliga", "Liga Santander", "FA Cup", "Ligue 1", "Primeira Liga", "Eredivisie", "Super League", "Major League Soccer", "Coppa Italia", "DFB Pokal", "CONCACAF Gold Cup", "Nations Cup", "Copa del Rey"] 8 | positions: ["Goalkeeper", "Full Back", "Right Back", "Left Back", "Defensive Midfielder", "Midfielder", "Attacking Midfielder", "Right Midfielder", "Left Midfielder", "Right Wing", "Left Wing", "Second Striker", "Centre Forward"] 9 | -------------------------------------------------------------------------------- /src/test/java/com/github/javafaker/PhoneNumberTest.java: -------------------------------------------------------------------------------- 1 | package com.github.javafaker; 2 | 3 | import org.junit.Test; 4 | 5 | import java.util.Locale; 6 | 7 | import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; 8 | import static org.junit.Assert.assertThat; 9 | 10 | public class PhoneNumberTest extends AbstractFakerTest { 11 | 12 | @Test 13 | public void testCellPhone_enUS() { 14 | final Faker f = new Faker(Locale.US); 15 | assertThat(f.phoneNumber().cellPhone(), matchesRegularExpression("\\(?\\d+\\)?([- .]\\d+){1,3}")); 16 | } 17 | 18 | @Test 19 | public void testPhone_esMx() { 20 | final Faker f = new Faker(new Locale("es_MX")); 21 | for (int i=0;i<100;i++) { 22 | assertThat(f.phoneNumber().cellPhone(), matchesRegularExpression("(044 )?\\(?\\d+\\)?([- .]\\d+){1,3}")); 23 | assertThat(f.phoneNumber().phoneNumber(), matchesRegularExpression("\\(?\\d+\\)?([- .]\\d+){1,3}")); 24 | } 25 | } 26 | 27 | @Test 28 | public void testCellPhone() { 29 | assertThat(faker.phoneNumber().cellPhone(), matchesRegularExpression("\\(?\\d+\\)?([- .]\\d+){1,3}")); 30 | } 31 | 32 | @Test 33 | public void testPhoneNumber() { 34 | assertThat(faker.phoneNumber().phoneNumber(), matchesRegularExpression("\\(?\\d+\\)?([- .]x?\\d+){1,5}")); 35 | } 36 | 37 | @Test 38 | public void testExtension() { 39 | assertThat(faker.phoneNumber().extension(), matchesRegularExpression("\\d{4}")); 40 | } 41 | 42 | @Test 43 | public void testSubscriberNumber() { 44 | assertThat(faker.phoneNumber().subscriberNumber(), matchesRegularExpression("\\d{4}")); 45 | } 46 | 47 | @Test 48 | public void testSubscriberNumberWithLength() { 49 | assertThat(faker.phoneNumber().subscriberNumber(10), matchesRegularExpression("\\d{10}")); 50 | } 51 | } 52 | --------------------------------------------------------------------------------