Fix 483
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.github.javafaker;
|
||||
|
||||
/**
|
||||
* Generate random parts in BojackHorseman.
|
||||
* @author 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;
|
||||
|
||||
public Faker() {
|
||||
this(Locale.ENGLISH);
|
||||
@@ -203,6 +204,7 @@ public class Faker {
|
||||
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 class Faker {
|
||||
return team;
|
||||
}
|
||||
|
||||
public Beer beer() {
|
||||
return beer;
|
||||
}
|
||||
public Beer beer() { return beer; }
|
||||
|
||||
public University university() {
|
||||
return university;
|
||||
@@ -641,6 +641,10 @@ public class Faker {
|
||||
return kaamelott;
|
||||
}
|
||||
|
||||
|
||||
public BojackHorseman bojackHorseman() { return bojackHorseman; }
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
private void testAllMethodsThatReturnStringsActuallyReturnStrings(Object object) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user