Skip to content

Commit 2351634

Browse files
committed
Added Departed Faker
1 parent 35537f2 commit 2351634

File tree

7 files changed

+67
-0
lines changed

7 files changed

+67
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ Providers
194194
* Currency
195195
* DateAndTime
196196
* Demographic
197+
* Departed
197198
* Dessert
198199
* Device
199200
* Disease
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package net.datafaker;
2+
3+
public class Departed {
4+
5+
private final Faker faker;
6+
7+
protected Departed(Faker faker) {
8+
this.faker = faker;
9+
}
10+
11+
/**
12+
* This method generates a random actor's name from The Departed.
13+
*
14+
* @return a string of actor's name from The Departed.
15+
*/
16+
public String actor() {
17+
return faker.fakeValuesService().resolve("departed.actors", this, faker);
18+
}
19+
20+
/**
21+
* This method generates a random character's name from The Departed.
22+
*
23+
* @return a string of character's name from The Departed.
24+
*/
25+
public String character() {
26+
return faker.fakeValuesService().resolve("departed.characters", this, faker);
27+
}
28+
29+
/**
30+
* This method generates a random quote from The Departed.
31+
*
32+
* @return a string of quote from The Departed.
33+
*/
34+
public String quote() {
35+
return faker.fakeValuesService().resolve("departed.quotes", this, faker);
36+
}
37+
}

src/main/java/net/datafaker/Faker.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,10 @@ public Demographic demographic() {
474474
return getProvider(Demographic.class, () -> new Demographic(this));
475475
}
476476

477+
public Departed departed() {
478+
return getProvider(Departed.class, () -> new Departed(this));
479+
}
480+
477481
public Dessert dessert() {
478482
return getProvider(Dessert.class, () -> new Dessert(this));
479483
}

src/main/java/net/datafaker/service/files/EnFile.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public String getPath() {
7575
// "dc_comics.yml",
7676
"dark_soul.yml",
7777
"demographic.yml",
78+
"departed.yml",
7879
"dessert.yml",
7980
"device.yml",
8081
"disease.yml",
File renamed without changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package net.datafaker;
2+
3+
import org.junit.jupiter.api.RepeatedTest;
4+
5+
import static org.assertj.core.api.Assertions.assertThat;
6+
7+
class DepartedTest extends AbstractFakerTest {
8+
9+
@RepeatedTest(100)
10+
void testActor() {
11+
assertThat(faker.departed().actor()).matches("^[a-zA-Z ']+$");
12+
}
13+
14+
@RepeatedTest(100)
15+
void testCharacter() {
16+
assertThat(faker.departed().character()).matches("^[a-zA-Z ]+$");
17+
}
18+
19+
@RepeatedTest(100)
20+
void testQuote() {
21+
assertThat(faker.departed().quote()).matches("^[a-zA-Z '.?!,]+$");
22+
}
23+
}

src/test/java/net/datafaker/integration/FakerIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ void testAllFakerMethodsThatReturnStrings(Locale locale, Random random) throws E
108108
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.company());
109109
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.country());
110110
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.demographic());
111+
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.departed());
111112
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.dessert());
112113
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.device());
113114
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.disease());

0 commit comments

Comments
 (0)