Merge pull request #485 from wetHands04/coin-faker

Added new Coin class
This commit is contained in:
Ricky Yim
2020-03-17 14:16:29 +11:00
committed by GitHub
6 changed files with 41 additions and 3 deletions
+1
View File
@@ -72,6 +72,7 @@ Fakers
* ChuckNorris
* Cat
* Code
* Coin
* Color
* Commerce
* Company
@@ -0,0 +1,17 @@
package com.github.javafaker;
public class Coin {
private final Faker faker;
protected Coin(Faker faker) {
this.faker = faker;
}
/**
* @return coin side e.g. "Heads", "Tails".
*/
public String flip() {
return faker.fakeValuesService().resolve("coin.flip", this, faker);
}
}
@@ -42,6 +42,7 @@ public class Faker {
private final Hacker hacker;
private final Options options;
private final Code code;
private final Coin coin;
private final Finance finance;
private final Food food;
private final GameOfThrones gameOfThrones;
@@ -158,6 +159,7 @@ public class Faker {
this.shakespeare = new Shakespeare(this);
this.slackEmoji = new SlackEmoji(this);
this.space = new Space(this);
this.coin = new Coin(this);
this.superhero = new Superhero(this);
this.team = new Team(this);
this.bool = new Bool(this);
@@ -425,6 +427,10 @@ public class Faker {
return code;
}
public Coin coin() {
return coin;
}
public File file() {
return file;
}
+2 -3
View File
@@ -1,6 +1,5 @@
en:
faker:
coin:
flip:
- Heads
- Tails
flip: ["Heads", "Tails"]
@@ -0,0 +1,14 @@
package com.github.javafaker;
import static org.junit.Assert.assertThat;
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import org.junit.Test;
public class CoinTest extends AbstractFakerTest {
@Test
public void coinFlip() {
assertThat(faker.coin().flip(), matchesRegularExpression("\\w+"));
}
}
@@ -135,6 +135,7 @@ public class FakerIT {
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.superhero());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.team());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.beer());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.coin());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.university());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.cat());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.lordOfTheRings());