Skip to content

Commit

Permalink
Merge 8e4cf80 into 1850b03
Browse files Browse the repository at this point in the history
  • Loading branch information
irakatz committed May 8, 2020
2 parents 1850b03 + 8e4cf80 commit 91c5962
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -66,6 +66,7 @@ Fakers
* Back To The Future
* Aviation
* Beer
* Bojack Horseman
* Book
* Bool
* Business
Expand Down
42 changes: 42 additions & 0 deletions 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);
}

}
10 changes: 7 additions & 3 deletions src/main/java/com/github/javafaker/Faker.java
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -491,9 +493,7 @@ public Team team() {
return team;
}

public Beer beer() {
return beer;
}
public Beer beer() { return beer; }

public University university() {
return university;
Expand Down Expand Up @@ -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);
}
Expand Down
62 changes: 62 additions & 0 deletions 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);
}

}
Expand Up @@ -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 {
Expand Down

0 comments on commit 91c5962

Please sign in to comment.