Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Movie faker #208

Merged
merged 1 commit into from
Jun 8, 2022
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 @@ -251,6 +251,7 @@ Providers
* Mood
* Mountains
* Mountaineering
* Movie
* Music
* Name
* Nation
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 @@ -696,6 +696,10 @@ public Mountaineering mountaineering() {
return getProvider(Mountaineering.class, () -> new Mountaineering(this));
}

public Movie movie() {
return getProvider(Movie.class, () -> new Movie(this));
}

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

public class Movie {

private final Faker faker;

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

/**
* This method generates a random quote from a movie.
*
* @return a string of quote from a movie.
*/
public String quote() {
return faker.fakeValuesService().resolve("movie.quote", this, faker);
}
}
File renamed without changes.
13 changes: 13 additions & 0 deletions src/test/java/net/datafaker/MovieTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package net.datafaker;

import org.junit.jupiter.api.RepeatedTest;

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

class MovieTest extends AbstractFakerTest {

@RepeatedTest(50)
void testName() {
assertThat(faker.movie().quote()).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 @@ -156,6 +156,7 @@ void testAllFakerMethodsThatReturnStrings(Locale locale, Random random) throws E
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.military());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.mountain());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.mountaineering());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.movie());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.music());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.name());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.nation());
Expand Down