Skip to content

Commit 45c4763

Browse files
rolyatwilsonRicky Yim
authored andcommitted
Add more Faker classes (DiUS#276)
* Add more Faker classes * add unit tests for new classes
1 parent 0b7fe0d commit 45c4763

21 files changed

+513
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,25 @@ Fakers
7272
* Crypto
7373
* DateAndTime
7474
* Demographic
75+
* DragonBall
7576
* Educator
7677
* Esports
7778
* File
7879
* Finance
7980
* Food
8081
* Friends
82+
* FunnyName
8183
* GameOfThrones
8284
* Hacker
8385
* HarryPotter
8486
* Hipster
87+
* HitchhikersGuideToTheGalaxy
88+
* Hobbit
89+
* HowIMetYourMother
8590
* IdNumber
8691
* Internet
8792
* Job
93+
* LeagueOfLegends
8894
* Lebowski
8995
* LordOfTheRings
9096
* Lorem
@@ -93,13 +99,16 @@ Fakers
9399
* Name
94100
* Number
95101
* Options
102+
* Overwatch
96103
* PhoneNumber
97104
* Pokemon
98105
* RickAndMorty
106+
* Robin
99107
* RockBand
100108
* Shakespeare
101109
* SlackEmoji
102110
* Space
111+
* StarTrek
103112
* Stock
104113
* Superhero
105114
* Team
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
}

src/main/java/com/github/javafaker/Faker.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ public class Faker {
7070
private final Yoda yoda;
7171
private final Matz matz;
7272
private final Witcher witcher;
73+
private final DragonBall dragonBall;
74+
private final FunnyName funnyName;
75+
private final HitchhikersGuideToTheGalaxy hitchhikersGuideToTheGalaxy;
76+
private final Hobbit hobbit;
77+
private final HowIMetYourMother howIMetYourMother;
78+
private final LeagueOfLegends leagueOfLegends;
79+
private final Overwatch overwatch;
80+
private final Robin robin;
81+
private final StarTrek starTrek;
7382
private final Weather weather;
7483
private final Lebowski lebowski;
7584

@@ -143,6 +152,15 @@ public Faker(Locale locale, Random random) {
143152
this.yoda = new Yoda(this);
144153
this.matz = new Matz(this);
145154
this.witcher = new Witcher(this);
155+
this.dragonBall = new DragonBall(this);
156+
this.funnyName = new FunnyName(this);
157+
this.hitchhikersGuideToTheGalaxy = new HitchhikersGuideToTheGalaxy(this);
158+
this.hobbit = new Hobbit(this);
159+
this.howIMetYourMother = new HowIMetYourMother(this);
160+
this.leagueOfLegends = new LeagueOfLegends(this);
161+
this.overwatch = new Overwatch(this);
162+
this.robin = new Robin(this);
163+
this.starTrek = new StarTrek(this);
146164
this.weather = new Weather(this);
147165
this.lebowski = new Lebowski(this);
148166
}
@@ -481,6 +499,42 @@ public Witcher witcher() {
481499
return witcher;
482500
}
483501

502+
public DragonBall dragonBall() {
503+
return dragonBall;
504+
}
505+
506+
public FunnyName funnyName() {
507+
return funnyName;
508+
}
509+
510+
public HitchhikersGuideToTheGalaxy hitchhikersGuideToTheGalaxy() {
511+
return hitchhikersGuideToTheGalaxy;
512+
}
513+
514+
public Hobbit hobbit() {
515+
return hobbit;
516+
}
517+
518+
public HowIMetYourMother howIMetYourMother() {
519+
return howIMetYourMother;
520+
}
521+
522+
public LeagueOfLegends leagueOfLegends() {
523+
return leagueOfLegends;
524+
}
525+
526+
public Overwatch overwatch() {
527+
return overwatch;
528+
}
529+
530+
public Robin robin() {
531+
return robin;
532+
}
533+
534+
public StarTrek starTrek() {
535+
return starTrek;
536+
}
537+
484538
public Weather weather() {
485539
return weather;
486540
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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("league_of_legends.champion", this, faker);
12+
}
13+
14+
public String location() {
15+
return faker.fakeValuesService().resolve("league_of_legends.location", this, faker);
16+
}
17+
18+
public String quote() {
19+
return faker.fakeValuesService().resolve("league_of_legends.quote", this, faker);
20+
}
21+
22+
public String summonerSpell() {
23+
return faker.fakeValuesService().resolve("league_of_legends.summoner_spell", this, faker);
24+
}
25+
26+
public String masteries() {
27+
return faker.fakeValuesService().resolve("league_of_legends.masteries", this, faker);
28+
}
29+
30+
public String rank() {
31+
return faker.fakeValuesService().resolve("league_of_legends.rank", this, faker);
32+
}
33+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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("overwatch.heroes", this, faker);
12+
}
13+
14+
public String location() {
15+
return faker.fakeValuesService().resolve("overwatch.locations", this, faker);
16+
}
17+
18+
public String quote() {
19+
return faker.fakeValuesService().resolve("overwatch.quotes", this, faker);
20+
}
21+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}

0 commit comments

Comments
 (0)