Skip to content

Commit

Permalink
Merge pull request #170 from Tahanima/feature/add-verb-faker
Browse files Browse the repository at this point in the history
Added Verb Faker
  • Loading branch information
bodiam authored May 24, 2022
2 parents 6d64ae4 eee881f commit 7f73607
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 1 deletion.
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

0 comments on commit 7f73607

Please sign in to comment.