diff --git a/README.md b/README.md index 607ae4a09..c57f7c376 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ Fakers * Back To The Future * Aviation * Beer +* Bojack Horseman * Book * Bool * Business diff --git a/src/main/java/com/github/javafaker/BojackHorseman.java b/src/main/java/com/github/javafaker/BojackHorseman.java new file mode 100644 index 000000000..d9ca0e06a --- /dev/null +++ b/src/main/java/com/github/javafaker/BojackHorseman.java @@ -0,0 +1,42 @@ +package com.github.javafaker; + +/** + * Generate random parts in BojackHorseman. + * @author unknown and irakatz + */ +public class BojackHorseman { + private final Faker faker; + + /** + * Create a constructor for BojackHorseman. + * @param faker The Faker instance for generating random parts in BojackHorseman. + */ + protected BojackHorseman(Faker faker) { + this.faker = faker; + } + + /** + * Generate random character's name in BojackHorseman. + * @return Characters in BojackHorseman + */ + public String characters() { + return faker.fakeValuesService().resolve("bojack_horseman.characters", this, faker); + } + + /** + * Generate random quotes in BojackHorseman. + * @return Quotes in BojackHorseman + */ + public String quotes() { + return faker.fakeValuesService().resolve("bojack_horseman.quotes", this, faker); + } + + /** + * Generate random tongue twisters in BojackHorseman. + * @return Tongue twisters in BojackHorseman + */ + public String tongueTwisters() { + return faker.fakeValuesService().resolve("bojack_horseman.tongue_twisters", this, faker); + } + +} diff --git a/src/main/java/com/github/javafaker/Faker.java b/src/main/java/com/github/javafaker/Faker.java index 8942ee820..afa80b701 100644 --- a/src/main/java/com/github/javafaker/Faker.java +++ b/src/main/java/com/github/javafaker/Faker.java @@ -97,6 +97,7 @@ public class Faker { private final AquaTeenHungerForce aquaTeenHungerForce; private final ProgrammingLanguage programmingLanguage; private final Kaamelott kaamelott; + private final BojackHorseman bojackHorseman; public Faker() { this(Locale.ENGLISH); @@ -203,6 +204,7 @@ public Faker(FakeValuesService fakeValuesService, RandomService random) { this.aquaTeenHungerForce = new AquaTeenHungerForce(this); this.programmingLanguage = new ProgrammingLanguage(this); this.kaamelott = new Kaamelott(this); + this.bojackHorseman = new BojackHorseman(this); } /** @@ -491,9 +493,7 @@ public Team team() { return team; } - public Beer beer() { - return beer; - } + public Beer beer() { return beer; } public University university() { return university; @@ -641,6 +641,10 @@ public Kaamelott kaamelott() { return kaamelott; } + + public BojackHorseman bojackHorseman() { return bojackHorseman; } + + public String resolve(String key) { return this.fakeValuesService.resolve(key, this, this); } diff --git a/src/test/java/com/github/javafaker/BojackHorsemanTest.java b/src/test/java/com/github/javafaker/BojackHorsemanTest.java new file mode 100644 index 000000000..5e47149d0 --- /dev/null +++ b/src/test/java/com/github/javafaker/BojackHorsemanTest.java @@ -0,0 +1,62 @@ +package com.github.javafaker; + +import com.github.javafaker.AbstractFakerTest; +import com.github.javafaker.Faker; +import org.junit.Test; + +import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; +import static org.junit.Assert.*; + +public class BojackHorsemanTest extends AbstractFakerTest { + + @Test + public void testCharacters1(){ + Faker faker=new Faker(); + assertThat(faker.bojackHorseman().characters(),matchesRegularExpression("[\\p{L}'()\\., 0-9-’’]+")); } + + @Test + public void testQuotes1(){ + Faker faker=new Faker(); + assertFalse(faker.bojackHorseman().quotes().isEmpty()); } + + @Test + public void testTongueTwisters1(){ + Faker faker=new Faker(); + assertFalse(faker.bojackHorseman().tongueTwisters().isEmpty());} + + @Test + public void testCharactersWith10000Times(){ + Faker faker=new Faker(); + boolean isExist=false; + for(int i=0;i<10000;i++){ + String generateString=faker.bojackHorseman().characters(); + if(generateString.equals("Joseph Sugarman")){isExist=true;} + } + assertTrue(isExist); + } + + @Test + public void testQuotesWith10000Times(){ + Faker faker=new Faker(); + boolean isExist=false; + for(int i=0;i<10000;i++){ + String generateString=faker.bojackHorseman().quotes(); + if(generateString.equals("It gets easier. But you have to do it every day, that's the hard part. But it does get easier")) + {isExist=true;} + } + assertTrue(isExist); + } + + @Test + public void testTongueTwistersWith10000Times(){ + Faker faker=new Faker(); + boolean isExist=false; + for(int i=0;i<10000;i++){ + String generateString=faker.bojackHorseman().tongueTwisters(); + if(generateString.equals("Courtly roles like the formerly portly consort are Courtney Portnoy's forté")) + {isExist=true;} + } + assertTrue(isExist); + } + +} diff --git a/src/test/java/com/github/javafaker/integration/FakerIT.java b/src/test/java/com/github/javafaker/integration/FakerIT.java index 4ca24be01..764c3f812 100644 --- a/src/test/java/com/github/javafaker/integration/FakerIT.java +++ b/src/test/java/com/github/javafaker/integration/FakerIT.java @@ -163,6 +163,7 @@ public void testAllFakerMethodsThatReturnStrings() throws Exception { testAllMethodsThatReturnStringsActuallyReturnStrings(faker.aquaTeenHungerForce()); testAllMethodsThatReturnStringsActuallyReturnStrings(faker.programmingLanguage()); testAllMethodsThatReturnStringsActuallyReturnStrings(faker.kaamelott()); + testAllMethodsThatReturnStringsActuallyReturnStrings(faker.bojackHorseman()); } private void testAllMethodsThatReturnStringsActuallyReturnStrings(Object object) throws Exception {