Skip to content

Added Verb Faker #170

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

Merged
merged 1 commit into from
May 24, 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 @@ -260,6 +260,7 @@ Providers
* Twitter
* University
* Vehicle
* Verb
* Weather
* Witcher
* Yoda
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 @@ -836,6 +836,10 @@ public Vehicle vehicle() {
return getProvider(Vehicle.class, () -> new Vehicle(this));
}

public Verb verb() {
return getProvider(Verb.class, () -> new Verb(this));
}

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

public class Verb {

private final Faker faker;

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

/**
* This method generates the base form of a random verb.
*
* @return a string of base form of a verb.
*/
public String base() {
return faker.fakeValuesService().resolve("verbs.base", this, faker);
}

/**
* This method generates a random verb in past tense.
*
* @return a string of verb in past tense.
*/
public String past() {
return faker.fakeValuesService().resolve("verbs.past", this, faker);
}

/**
* This method generates a random verb in past participle tense.
*
* @return a string of verb in past participle tense.
*/
public String pastParticiple() {
return faker.fakeValuesService().resolve("verbs.past_participle", this, faker);
}

/**
* This method generates a random verb in simple present tense.
*
* @return a string of verb in simple present tense.
*/
public String simplePresent() {
return faker.fakeValuesService().resolve("verbs.simple_present", this, faker);
}

/**
* This method generates a random verb in -ing form.
*
* @return a string of verb in -ing form.
*/
public String ingForm() {
return faker.fakeValuesService().resolve("verbs.ing_form", 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 @@ -204,7 +204,7 @@ public String getPath() {
"vehicle.yml",
"volleyball.yml",
// "venture_bros.yml",
// "verbs.yml",
"verbs.yml",
"weather.yml",
"witcher.yml",
"kaamelott.yml",
Expand Down
File renamed without changes.
33 changes: 33 additions & 0 deletions src/test/java/net/datafaker/VerbTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.datafaker;

import org.junit.jupiter.api.Test;

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

class VerbTest extends AbstractFakerTest {

@Test
void testBase() {
assertThat(faker.verb().base()).matches("\\w+");
}

@Test
void testPast() {
assertThat(faker.verb().past()).matches("\\w+");
}

@Test
void testPastParticiple() {
assertThat(faker.verb().pastParticiple()).matches("\\w+");
}

@Test
void testSimplePresent() {
assertThat(faker.verb().simplePresent()).matches("\\w+");
}

@Test
void testIngForm() {
assertThat(faker.verb().ingForm()).matches("\\w+");
}
}
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 @@ -184,6 +184,7 @@ void testAllFakerMethodsThatReturnStrings(Locale locale, Random random) throws E
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.twinPeaks());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.university());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.vehicle());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.verb());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.weather());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.witcher());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.yoda());
Expand Down