Add a (single) word method to the Lorem generator.
This commit is contained in:
@@ -34,6 +34,11 @@ public class Lorem {
|
||||
return words(3);
|
||||
}
|
||||
|
||||
public String word() {
|
||||
List<String> words = (List<String>) fakeValuesService.fetchObject("lorem.words");
|
||||
return words.get(randomService.nextInt(words.size()));
|
||||
}
|
||||
|
||||
public String sentence(int wordCount) {
|
||||
return capitalize(join(words(wordCount + randomService.nextInt(6)), " ") + ".");
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class LoremTest {
|
||||
|
||||
@@ -22,4 +23,8 @@ public class LoremTest {
|
||||
assertEquals(0, faker.lorem().fixedString(-1).length());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wordShouldNotBeNull() {
|
||||
assertNotNull(faker.lorem().word());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user