Skip to content

Commit 441e1d7

Browse files
authored
Merge pull request #171 from Tahanima/feature/add-famous-last-words-faker
Added Famous Last Words faker
2 parents 0279d57 + 30a08fc commit 441e1d7

File tree

7 files changed

+39
-1
lines changed

7 files changed

+39
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ Providers
198198
* EnglandFootBall
199199
* ElectricalComponents
200200
* Esports
201+
* Famous Last Words
201202
* File
202203
* Finance
203204
* Food

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,10 @@ public FakeDuration duration() {
506506
return getProvider(FakeDuration.class, () -> new FakeDuration(this));
507507
}
508508

509+
public FamousLastWords famousLastWords() {
510+
return getProvider(FamousLastWords.class, () -> new FamousLastWords(this));
511+
}
512+
509513
public File file() {
510514
return getProvider(File.class, () -> new File(this));
511515
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package net.datafaker;
2+
3+
public class FamousLastWords {
4+
5+
private final Faker faker;
6+
7+
protected FamousLastWords(Faker faker) {
8+
this.faker = faker;
9+
}
10+
11+
/**
12+
* This method generates random famous last words.
13+
*
14+
* @return a string of last words.
15+
*/
16+
public String lastWords() {
17+
return faker.fakeValuesService().resolve("famous_last_words.last_words", this, faker);
18+
}
19+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public String getPath() {
9090
"englandfootball.yml",
9191
// "fallout.yml",
9292
// "family_guy.yml",
93-
// "famous_last_words.yml",
93+
"famous_last_words.yml",
9494
"file.yml",
9595
"finance.yml",
9696
"food.yml",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package net.datafaker;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.assertj.core.api.Assertions.assertThat;
6+
7+
class FamousLastWordsTest extends AbstractFakerTest {
8+
9+
@Test
10+
void testLastWords() {
11+
assertThat(faker.famousLastWords().lastWords()).matches("^[A-Za-z- .,'!?-]+$");
12+
}
13+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ void testAllFakerMethodsThatReturnStrings(Locale locale, Random random) throws E
119119
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.electricalComponents());
120120
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.englandfootball());
121121
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.esports());
122+
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.famousLastWords());
122123
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.file());
123124
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.finance());
124125
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.food());

0 commit comments

Comments
 (0)