Merge pull request #518 from irakatz/real_483
Fix Bojack Horseman feature
This commit is contained in:
@@ -67,6 +67,7 @@ Fakers
|
||||
* Aviation
|
||||
* Basketball
|
||||
* Beer
|
||||
* Bojack Horseman
|
||||
* Book
|
||||
* Bool
|
||||
* Business
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -97,6 +97,7 @@ public class Faker {
|
||||
private final AquaTeenHungerForce aquaTeenHungerForce;
|
||||
private final ProgrammingLanguage programmingLanguage;
|
||||
private final Kaamelott kaamelott;
|
||||
private final BojackHorseman bojackHorseman;
|
||||
private final Basketball basketball;
|
||||
|
||||
public Faker() {
|
||||
@@ -204,6 +205,7 @@ public class Faker {
|
||||
this.aquaTeenHungerForce = new AquaTeenHungerForce(this);
|
||||
this.programmingLanguage = new ProgrammingLanguage(this);
|
||||
this.kaamelott = new Kaamelott(this);
|
||||
this.bojackHorseman = new BojackHorseman(this);
|
||||
this.basketball = new Basketball(this);
|
||||
}
|
||||
|
||||
@@ -641,7 +643,10 @@ public class Faker {
|
||||
return kaamelott;
|
||||
}
|
||||
|
||||
public BojackHorseman bojackHorseman() { return bojackHorseman; }
|
||||
|
||||
public Basketball basketball() { return basketball; }
|
||||
|
||||
public String resolve(String key) {
|
||||
return this.fakeValuesService.resolve(key, this, this);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -163,6 +163,7 @@ public class FakerIT {
|
||||
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.aquaTeenHungerForce());
|
||||
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.programmingLanguage());
|
||||
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.kaamelott());
|
||||
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.bojackHorseman());
|
||||
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.basketball());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user