Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ Providers
* EnglandFootBall
* ElectricalComponents
* Esports
* Famous Last Words
* File
* Finance
* Food
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/datafaker/Faker.java
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ public FakeDuration duration() {
return getProvider(FakeDuration.class, () -> new FakeDuration(this));
}

public FamousLastWords famousLastWords() {
return getProvider(FamousLastWords.class, () -> new FamousLastWords(this));
}

public File file() {
return getProvider(File.class, () -> new File(this));
}
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/net/datafaker/FamousLastWords.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package net.datafaker;

public class FamousLastWords {

private final Faker faker;

protected FamousLastWords(Faker faker) {
this.faker = faker;
}

/**
* This method generates random famous last words.
*
* @return a string of last words.
*/
public String lastWords() {
return faker.fakeValuesService().resolve("famous_last_words.last_words", this, faker);
}
}
2 changes: 1 addition & 1 deletion src/main/java/net/datafaker/service/files/EnFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public String getPath() {
"englandfootball.yml",
// "fallout.yml",
// "family_guy.yml",
// "famous_last_words.yml",
"famous_last_words.yml",
"file.yml",
"finance.yml",
"food.yml",
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/net/datafaker/FamousLastWordsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package net.datafaker;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class FamousLastWordsTest extends AbstractFakerTest {

@Test
void testLastWords() {
assertThat(faker.famousLastWords().lastWords()).matches("^[A-Za-z- .,'!?-]+$");
}
}
1 change: 1 addition & 0 deletions src/test/java/net/datafaker/integration/FakerIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void testAllFakerMethodsThatReturnStrings(Locale locale, Random random) throws E
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.electricalComponents());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.englandfootball());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.esports());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.famousLastWords());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.file());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.finance());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.food());
Expand Down