Skip to content

Commit eee881f

Browse files
committed
Added Verb Faker
1 parent 6d64ae4 commit eee881f

File tree

7 files changed

+95
-1
lines changed

7 files changed

+95
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ Providers
260260
* Twitter
261261
* University
262262
* Vehicle
263+
* Verb
263264
* Weather
264265
* Witcher
265266
* Yoda

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

+4
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,10 @@ public Vehicle vehicle() {
836836
return getProvider(Vehicle.class, () -> new Vehicle(this));
837837
}
838838

839+
public Verb verb() {
840+
return getProvider(Verb.class, () -> new Verb(this));
841+
}
842+
839843
public Volleyball volleyball() {
840844
return getProvider(Volleyball.class, () -> new Volleyball(this));
841845
}

src/main/java/net/datafaker/Verb.java

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package net.datafaker;
2+
3+
public class Verb {
4+
5+
private final Faker faker;
6+
7+
protected Verb(Faker faker) {
8+
this.faker = faker;
9+
}
10+
11+
/**
12+
* This method generates the base form of a random verb.
13+
*
14+
* @return a string of base form of a verb.
15+
*/
16+
public String base() {
17+
return faker.fakeValuesService().resolve("verbs.base", this, faker);
18+
}
19+
20+
/**
21+
* This method generates a random verb in past tense.
22+
*
23+
* @return a string of verb in past tense.
24+
*/
25+
public String past() {
26+
return faker.fakeValuesService().resolve("verbs.past", this, faker);
27+
}
28+
29+
/**
30+
* This method generates a random verb in past participle tense.
31+
*
32+
* @return a string of verb in past participle tense.
33+
*/
34+
public String pastParticiple() {
35+
return faker.fakeValuesService().resolve("verbs.past_participle", this, faker);
36+
}
37+
38+
/**
39+
* This method generates a random verb in simple present tense.
40+
*
41+
* @return a string of verb in simple present tense.
42+
*/
43+
public String simplePresent() {
44+
return faker.fakeValuesService().resolve("verbs.simple_present", this, faker);
45+
}
46+
47+
/**
48+
* This method generates a random verb in -ing form.
49+
*
50+
* @return a string of verb in -ing form.
51+
*/
52+
public String ingForm() {
53+
return faker.fakeValuesService().resolve("verbs.ing_form", this, faker);
54+
}
55+
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public String getPath() {
204204
"vehicle.yml",
205205
"volleyball.yml",
206206
// "venture_bros.yml",
207-
// "verbs.yml",
207+
"verbs.yml",
208208
"weather.yml",
209209
"witcher.yml",
210210
"kaamelott.yml",
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 VerbTest extends AbstractFakerTest {
8+
9+
@Test
10+
void testBase() {
11+
assertThat(faker.verb().base()).matches("\\w+");
12+
}
13+
14+
@Test
15+
void testPast() {
16+
assertThat(faker.verb().past()).matches("\\w+");
17+
}
18+
19+
@Test
20+
void testPastParticiple() {
21+
assertThat(faker.verb().pastParticiple()).matches("\\w+");
22+
}
23+
24+
@Test
25+
void testSimplePresent() {
26+
assertThat(faker.verb().simplePresent()).matches("\\w+");
27+
}
28+
29+
@Test
30+
void testIngForm() {
31+
assertThat(faker.verb().ingForm()).matches("\\w+");
32+
}
33+
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ void testAllFakerMethodsThatReturnStrings(Locale locale, Random random) throws E
184184
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.twinPeaks());
185185
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.university());
186186
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.vehicle());
187+
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.verb());
187188
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.weather());
188189
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.witcher());
189190
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.yoda());

0 commit comments

Comments
 (0)