Compare commits

...

27 Commits

Author SHA1 Message Date
Ricky Yim c07275e4fb Merge branch 'master' into buffy 2019-08-01 19:44:04 +10:00
Ricky 9e23a7a161 added buffy 2019-08-01 18:56:43 +10:00
Ricky Yim f8b4077785 Merge pull request #407 from sachsgit/Relationships
Relationships Terms
2019-07-29 07:15:47 +10:00
SS007979 09f00741cf Relationships.java: Removed unused logger declaration 2019-07-26 10:29:40 -04:00
SS007979 069aed2300 Exclude local bin and META-INF folders;Applied Ricky's suggestions 2019-07-25 20:55:23 -04:00
SS007979 0e60758671 updated gitignore 2019-07-23 16:14:44 -04:00
SS007979 272bd7acee Updated README.md 2019-07-23 16:11:08 -04:00
SS007979 5bbfbeeb39 Created random Relationship terms 2019-07-23 16:08:43 -04:00
SS007979 e6f798f85e Merge branch 'master' of https://github.com/DiUS/java-faker into clean-master
Merge branch 'DiUS:master' into local 'clean-master' on L61102
2019-07-23 12:38:54 -04:00
Ricky Yim 3d92dfb33b Merge pull request #388 from queueseven/master
Added new Faker: Animal + German translation (for creature.animal.name)
2019-07-21 19:21:21 +10:00
Ricky Yim be339360de Merge branch 'master' into master 2019-07-21 19:16:41 +10:00
Ricky f2be8022c2 fixing up elder scroll integration 2019-07-21 17:43:26 +10:00
Ricky Yim 4c61966b1c Merge pull request #368 from CodeAndChoke/elder-scrolls
Added elder scrolls
2019-07-21 17:31:22 +10:00
Ricky Yim 196a5ce4bd Merge pull request #398 from TOEndacott/master
Princess Bride
2019-07-21 17:30:56 +10:00
Ricky Yim cb3cb744e8 Merge pull request #406 from DiUS/updated_resource_files
updated resource files non EN ones
2019-07-21 17:30:31 +10:00
Ricky Yim a0bca97ace Merge branch 'master' into master 2019-07-21 17:27:26 +10:00
Ricky Yim 3d3204b2bc Merge pull request #405 from DiUS/county_by_zipcode_fix
made the countyByZipcode test not random
2019-07-21 17:12:26 +10:00
Ricky Yim 309f109707 Update README.md 2019-07-21 15:23:45 +10:00
Ricky Yim df2876d8dd Update README.md
Added demo web application link
2019-07-20 21:03:15 +10:00
Ricky aa1735a6b5 made the countyByZipcode test not random 2019-07-20 16:02:48 +10:00
Ricky Yim 488048254b Merge branch 'master' into master 2019-06-29 13:51:39 +10:00
Tom Endacott 25dfd23d2c Merge pull request #1 from DiUS/master
Merge pull request #393 from TOEndacott/master
2019-06-25 15:51:24 +01:00
Tom Endacott 9b480b997e update README with back to the future and princess bride 2019-06-25 15:47:38 +01:00
Tom Endacott 02ba126596 PrincessBride added, class and test, added to faker and fakerit 2019-06-25 15:42:54 +01:00
SS007979 b3c6b7c534 Adding folders META-INF and bin 2019-06-19 14:32:46 -04:00
Dominic Kexel 48bbe2aeb9 Added new Faker: Animal + German translation (for creature.animal.name) 2019-06-03 07:45:42 +02:00
Long Nguyen fa44670b41 Added elder scrolls 2019-03-10 02:04:45 +01:00
18 changed files with 370 additions and 4 deletions
+2
View File
@@ -6,3 +6,5 @@ target
*.iml
.java-version
/dependency-reduced-pom.xml
META-INF/
bin/
+8 -2
View File
@@ -17,7 +17,7 @@ In pom.xml, add the following xml stanza between `<dependencies> ... </dependenc
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>0.18</version>
<version>1.0.0</version>
</dependency>
```
@@ -25,7 +25,7 @@ For gradle users, add the following to your build.gradle file.
```groovy
dependencies {
implementation 'com.github.javafaker:javafaker:0.18'
implementation 'com.github.javafaker:javafaker:1.0.0'
}
```
@@ -42,6 +42,8 @@ String lastName = faker.name().lastName(); // Barton
String streetAddress = faker.address().streetAddress(); // 60018 Sawayn Brooks Suite 449
```
This is a [demo web application](https://java-faker.herokuapp.com/) that uses the library.
Javadoc
-----
http://dius.github.io/java-faker/apidocs/index.html
@@ -55,10 +57,12 @@ See [CONTRIBUTING.md](https://github.com/DiUS/java-faker/blob/master/CONTRIBUTIN
Fakers
-----
* Ancient
* Animal
* Address
* App
* Artist
* Avatar
* Back To The Future
* Aviation
* Beer
* Book
@@ -104,6 +108,8 @@ Fakers
* Overwatch
* PhoneNumber
* Pokemon
* Princess Bride
* Relationship Terms
* RickAndMorty
* Robin
* RockBand
@@ -0,0 +1,13 @@
package com.github.javafaker;
public class Animal {
private final Faker faker;
protected Animal(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("creature.animal.name", this, faker);
}
}
@@ -0,0 +1,30 @@
package com.github.javafaker;
public class Buffy {
private final Faker faker;
protected Buffy(Faker faker) {
this.faker = faker;
}
public String characters() {
return faker.fakeValuesService().resolve("buffy.characters", this, faker);
}
public String quotes() {
return faker.fakeValuesService().resolve("buffy.quotes", this, faker);
}
public String celebrities() {
return faker.fakeValuesService().resolve("buffy.celebrities", this, faker);
}
public String bigBads() {
return faker.fakeValuesService().resolve("buffy.big_bads", this, faker);
}
public String episodes() {
return faker.fakeValuesService().resolve("buffy.episodes", this, faker);
}
}
@@ -0,0 +1,38 @@
package com.github.javafaker;
public class ElderScrolls {
private final Faker faker;
protected ElderScrolls(Faker faker) {
this.faker = faker;
}
public String race() {
return faker.fakeValuesService().resolve("games.elder_scrolls.race", this, faker);
}
public String creature() {
return faker.fakeValuesService().resolve("games.elder_scrolls.creature", this, faker);
}
public String region() {
return faker.fakeValuesService().resolve("games.elder_scrolls.region", this, faker);
}
public String dragon() {
return faker.fakeValuesService().resolve("games.elder_scrolls.dragon", this, faker);
}
public String city() {
return faker.fakeValuesService().resolve("games.elder_scrolls.city", this, faker);
}
public String firstName() {
return faker.fakeValuesService().resolve("games.elder_scrolls.first_name", this, faker);
}
public String lastName() {
return faker.fakeValuesService().resolve("games.elder_scrolls.last_name", this, faker);
}
}
@@ -49,6 +49,7 @@ public class Faker {
private final Demographic demographic;
private final Dog dog;
private final Educator educator;
private final ElderScrolls elderScrolls;
private final Shakespeare shakespeare;
private final SlackEmoji slackEmoji;
private final Space space;
@@ -85,7 +86,11 @@ public class Faker {
private final Weather weather;
private final Lebowski lebowski;
private final Medical medical;
private final Animal animal;
private final BackToTheFuture backToTheFuture;
private final PrincessBride princessBride;
private final Buffy buffy;
private final Relationships relationships;
public Faker() {
this(Locale.ENGLISH);
@@ -124,6 +129,7 @@ public class Faker {
this.hacker = new Hacker(this);
this.company = new Company(this);
this.crypto = new Crypto(this);
this.elderScrolls = new ElderScrolls(this);
this.commerce = new Commerce(this);
this.currency = new Currency(this);
this.options = new Options(this);
@@ -172,7 +178,11 @@ public class Faker {
this.lebowski = new Lebowski(this);
this.medical = new Medical(this);
this.country = new Country(this);
this.animal = new Animal(this);
this.backToTheFuture = new BackToTheFuture(this);
this.princessBride = new PrincessBride(this);
this.buffy = new Buffy(this);
this.relationships = new Relationships(this);
}
/**
@@ -353,6 +363,10 @@ public class Faker {
return book;
}
public Buffy buffy() {
return buffy;
}
public Business business() {
return business;
}
@@ -405,6 +419,10 @@ public class Faker {
return food;
}
public ElderScrolls elderScrolls() {
return elderScrolls;
}
public GameOfThrones gameOfThrones() {
return gameOfThrones;
}
@@ -565,10 +583,20 @@ public class Faker {
public Country country(){ return country;}
public Animal animal(){ return animal; }
public BackToTheFuture backToTheFuture() {
return backToTheFuture;
}
public PrincessBride princessBride() {
return princessBride;
}
public Relationships relationships() {
return relationships;
}
public String resolve(String key) {
return this.fakeValuesService.resolve(key, this, this);
}
@@ -0,0 +1,17 @@
package com.github.javafaker;
public class PrincessBride {
private final Faker faker;
protected PrincessBride(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.resolve("princess_bride.characters");
}
public String quote() {
return faker.resolve("princess_bride.quotes");
}
}
@@ -0,0 +1,60 @@
package com.github.javafaker;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.commons.lang3.ArrayUtils;
public class Relationships {
private final Faker faker;
protected Relationships(final Faker faker) {
this.faker = faker;
}
public String direct() {
return faker.resolve("relationship.familial.direct");
}
public String extended() {
return faker.resolve("relationship.familial.extended");
}
public String inLaw() {
return faker.resolve("relationship.in_law");
}
public String spouse() {
return faker.resolve("relationship.spouse");
}
public String parent() {
return faker.resolve("relationship.parent");
}
public String sibling() {
return faker.resolve("relationship.sibling");
}
public String any() {
Method currentMethod = Relationships.class.getClass().getEnclosingMethod();
try {
Method[] methods = Relationships.class.getDeclaredMethods();
methods = ArrayUtils.removeElement(methods, currentMethod);
int indx = faker.random().nextInt(methods.length);
Method runMethod = methods[indx];
Relationships relationships = new Relationships(faker);
return (String)runMethod.invoke(relationships);
} catch (SecurityException e) {
throw new RuntimeException("SecurityException: " + e.getMessage());
} catch (IllegalArgumentException e) {
throw new RuntimeException("IllegalArgumentException: " + e.getMessage());
} catch (IllegalAccessException e) {
throw new RuntimeException("IllegalAccessException: " + e.getMessage());
} catch (InvocationTargetException e) {
throw new RuntimeException("InvocationTargetException: " + e.getMessage());
}
}
}
@@ -177,6 +177,7 @@ public class EnFile {
// files where the search path can't be derived from the filename
private static List<EnFile> FILES_WITH_A_DIFFERENT_PATH = Arrays.asList(
new EnFile("animal.yml", "creature"),
new EnFile("cat.yml", "creature"),
new EnFile("dog.yml", "creature"),
new EnFile("league_of_legends.yml", "games"),
@@ -184,6 +185,7 @@ public class EnFile {
new EnFile("pokemon.yml", "games"),
new EnFile("witcher.yml", "games"),
new EnFile("zelda.yml", "games"),
new EnFile("elder_scrolls.yml", "games"),
new EnFile("phone_number.yml", "cell_phone")); // load phone number again with a differen path
+4
View File
@@ -65,6 +65,10 @@ de:
- "#{half_wind_azimuth}"
- "#{quarter_wind_azimuth}"
creature:
animal:
name: ["Aal", "Adler", "Affe", "Affe", "Alligator", "Alpaka", "Ameise", "Antilope", "Ara", "Auster", "Biber", "Biene", "Bisamratte", "Bär", "Büffel", "Chinchilla", "Dachs", "Delphin", "Dinosaurier", "Eichhörnchen", "Eidechse", "Elch", "Elch", "Elch", "Elefant", "Ente", "Esel", "Fisch", "Fledermaus", "Fliege", "Forelle", "Frettchen", "Frosch", "Fuchs", "Gans", "Gepard", "Giraffe", "Gnu", "Goldfisch", "Gorilla", "Grille", "Gürteltier", "Hai", "Hamster", "Hase", "Hering", "Heuschrecke", "Heuschrecke", "Hirsch", "Hornisse", "Hund", "Hyäne", "Igel", "Impala", "Jagdhund", "Kabeljau", "Kakerlake", "Kamel", "Kaninchen", "Karibu", "Katze", "Koala", "Kojote", "Krabbe", "Krokodil", "Krähe", "Kröte", "Käfer", "Känguru", "Lachs", "Lama", "Landschildkröte", "Laus", "Leopard", "Löwe", "Mammut", "Marder", "Maultier", "Maulwurf", "Maus", "Meerschweinchen", "Mops", "Muschel", "Mücke", "Mücke", "Nashorn", "Nerz", "Nilpferd", "Otter", "Panda", "Pavian", "Pferd", "Präriehund", "Qualle", "Rabe", "Ratte", "Rennmaus", "Rentier", "Rind", "Rind", "Robbe", "Sardine", "Schaf", "Schakal", "Schildkröte", "Schimpanse", "Schlange", "Schmetterling", "Schnabeltier", "Schnecke", "Schwan", "Schwein", "Schweinswal", "Seekuh", "Seelöwe", "Serval", "Skorpion", "Spinne", "Stachelschwein", "Stinktier", "Stockente", "Termite", "Tiger", "Wal", "Waldmurmeltier", "Wallaby", "Walross", "Waschbär", "Wasserbüffel", "Wespe", "Wespe", "Wiesel", "Wolf", "Wombat", "Wurm", "Yak", "Zebra", "Ziege", "Zikade"]
internet:
free_email: [gmail.com, yahoo.com, hotmail.com, gmx.de, web.de, mail.de, freenet.de]
domain_suffix: [com, info, name, net, org, de, ch]
Executable → Regular
View File
@@ -110,6 +110,6 @@ public class AddressTest extends AbstractFakerTest {
@Test
public void testCountyByZipCode() {
faker = new Faker(new Locale("en-US"));
assertThat(faker.address().countyByZipCode(faker.address().zipCodeByState(faker.address().stateAbbr())), not(isEmptyOrNullString()));
assertThat(faker.address().countyByZipCode("47732"), not(isEmptyOrNullString()));
}
}
@@ -0,0 +1,15 @@
package com.github.javafaker;
import org.junit.Test;
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import static org.junit.Assert.assertThat;
public class AnimalTest extends AbstractFakerTest {
@Test
public void name() {
assertThat(faker.animal().name(), matchesRegularExpression("[A-Za-z ]+"));
}
}
@@ -0,0 +1,33 @@
package com.github.javafaker;
import org.junit.Test;
import static com.github.javafaker.matchers.IsStringWithContents.isStringWithContents;
import static org.junit.Assert.assertThat;
public class BuffyTest extends AbstractFakerTest {
@Test
public void testCharacters() {
assertThat(faker.buffy().characters(), isStringWithContents());
}
@Test
public void testQuotes() {
assertThat(faker.buffy().quotes(), isStringWithContents());
}
@Test
public void testCelebrities() {
assertThat(faker.buffy().celebrities(), isStringWithContents());
}
@Test
public void testBigBads() {
assertThat(faker.buffy().bigBads(), isStringWithContents());
}
@Test
public void testEpisodes() {
assertThat(faker.buffy().episodes(), isStringWithContents());
}
}
@@ -0,0 +1,47 @@
package com.github.javafaker;
import org.junit.Test;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
public class ElderScrollsTest extends AbstractFakerTest {
@Test
public void testCity() {
assertThat(faker.elderScrolls().city(), not(isEmptyOrNullString()));
}
@Test
public void testCreature() {
assertThat(faker.elderScrolls().creature(), not(isEmptyOrNullString()));
}
@Test
public void testDragon() {
assertThat(faker.elderScrolls().dragon(), not(isEmptyOrNullString()));
}
@Test
public void testFirstName() {
assertThat(faker.elderScrolls().firstName(), not(isEmptyOrNullString()));
}
@Test
public void testLastName() {
assertThat(faker.elderScrolls().lastName(), not(isEmptyOrNullString()));
}
@Test
public void testRace() {
assertThat(faker.elderScrolls().race(), not(isEmptyOrNullString()));
}
@Test
public void testRegion() {
assertThat(faker.elderScrolls().region(), not(isEmptyOrNullString()));
}
}
@@ -0,0 +1,20 @@
package com.github.javafaker;
import org.junit.Test;
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
public class PrincessBrideTest extends AbstractFakerTest {
@Test
public void character() {
assertThat(faker.princessBride().character(), matchesRegularExpression("[A-Za-z .-]+"));
}
@Test
public void quote() {
assertThat(faker.princessBride().quote(), not(isEmptyOrNullString()));
}
}
@@ -0,0 +1,46 @@
package com.github.javafaker;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
import org.junit.Test;
public class RelationshipTest extends AbstractFakerTest {
@Test
public void anyTest() {
assertThat(faker.relationships().any(), not(isEmptyOrNullString()));
}
@Test
public void directTest() {
assertThat(faker.relationships().direct(), not(isEmptyOrNullString()));
}
@Test
public void extendedTest() {
assertThat(faker.relationships().extended(), not(isEmptyOrNullString()));
}
@Test
public void inLawTest() {
assertThat(faker.relationships().inLaw(), not(isEmptyOrNullString()));
}
@Test
public void spouseTest() {
assertThat(faker.relationships().spouse(), not(isEmptyOrNullString()));
}
@Test
public void parentTest() {
assertThat(faker.relationships().parent(), not(isEmptyOrNullString()));
}
@Test
public void siblingTest() {
assertThat(faker.relationships().sibling(), not(isEmptyOrNullString()));
}
}
@@ -36,7 +36,7 @@ public class FakerIT {
/**
* a collection of Locales -> Exceptions.
* In the case of 'pt', city_prefix is '' by design. This test fails because it's testing that all string returning
* methods return a non blank string. But pt city_prefix is blank ,but the test shouldn't fail. So we add put
* methods return a non blank string. But pt city_prefix is blank ,but the test shouldn't fail. So we add put
* exceptions like this into this collection.
*/
private static final Map<Locale, List<String>> exceptions = Maps.newHashMap();
@@ -152,6 +152,11 @@ public class FakerIT {
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.witcher());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.weather());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.lebowski());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.animal());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.princessBride());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.elderScrolls());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.buffy());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.relationships());
}
private void testAllMethodsThatReturnStringsActuallyReturnStrings(Object object) throws Exception {