Add a (single) word method to the Lorem generator.

This commit is contained in:
Jason Whittle
2015-11-18 17:58:11 -05:00
parent 39a9d3696b
commit 1f4114100b
2 changed files with 10 additions and 0 deletions
@@ -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());
}
}