Add LordOfTheRings (#217)

This commit is contained in:
Luka
2017-05-16 23:53:34 +02:00
committed by Ricky Yim
parent 675753a4dd
commit dac3d3fb06
4 changed files with 46 additions and 0 deletions
@@ -55,6 +55,7 @@ public class Faker {
private final Cat cat;
private final File file;
private final Stock stock;
private final LordOfTheRings lordOfTheRings;
public Faker() {
this(Locale.ENGLISH);
@@ -111,6 +112,7 @@ public class Faker {
this.university = new University(this);
this.cat = new Cat(this);
this.stock = new Stock(this);
this.lordOfTheRings = new LordOfTheRings(this);
}
/**
@@ -346,6 +348,10 @@ public class Faker {
return stock;
}
public LordOfTheRings lordOfTheRings() {
return lordOfTheRings;
}
public String resolve(String key) {
return this.fakeValuesService.resolve(key, this, this);
}
@@ -0,0 +1,17 @@
package com.github.javafaker;
public class LordOfTheRings {
private final Faker faker;
protected LordOfTheRings(final Faker faker) {
this.faker = faker;
}
public String character() {
return faker.resolve("lord_of_the_rings.characters");
}
public String location() {
return faker.resolve("lord_of_the_rings.locations");
}
}
@@ -0,0 +1,22 @@
package com.github.javafaker;
import org.junit.Test;
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import static org.junit.Assert.assertThat;
/**
* @author Luka Obradovic (luka@vast.com)
*/
public class LordOfTheRingsTest extends AbstractFakerTest {
@Test
public void character() throws Exception {
assertThat(faker.lordOfTheRings().character(), matchesRegularExpression("(?U)([\\w ]+ ?)+"));
}
@Test
public void location() throws Exception {
assertThat(faker.lordOfTheRings().location(), matchesRegularExpression("(?U)([\\w'\\- ]+ ?)+"));
}
}
@@ -124,6 +124,7 @@ public class FakerIT {
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.beer());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.university());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.cat());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.lordOfTheRings());
}
private void testAllMethodsThatReturnStringsActuallyReturnStrings(Object object) throws Exception {