Compare commits

...

51 Commits

Author SHA1 Message Date
Ricky a568d925cc [maven-release-plugin] prepare release javafaker-0.18 2019-05-10 20:25:11 +10:00
Ricky Yim 0eba56018b Merge pull request #375 from srikarn/master
Added support for date expressions like #{date.future '10','TimeUnit.DAYS'}
2019-05-06 00:54:58 +02:00
Ricky Yim aa64edf17c Merge pull request #364 from haruntuncay/master
Add digit constraint for passwords, issue #360
2019-04-26 13:19:45 +02:00
Srikar Nadipally 6a2123b3d7 Added tests for the date expression support 2019-04-23 15:33:20 -05:00
Ricky Yim 81e1f86db2 Merge pull request #370 from haruntuncay/issue#282
Add hex value generation, both for as color and as random, see issue #282
2019-04-17 20:08:47 +10:00
Srikar Nadipally 23fd6e63f9 Added support for date expressions like #{date.future '10','TimeUnit.DAYS'} 2019-04-12 15:03:39 -05:00
Ricky Yim 06ece70248 Merge pull request #374 from DiUS/performance
lazy loading.. to improve performance so faker doesn't load up all YMLs at once
2019-04-12 10:53:49 +10:00
Ricky 056e67f5d7 added in testing 2019-04-12 10:39:01 +10:00
Ricky 381501666c refactored to return maps 2019-03-31 16:01:08 +11:00
Ricky 381879331f first cut of lazy loading to speed up faker 2019-03-30 20:19:05 +11:00
Ricky Yim 85a3464e71 trying to extract refactor the fetching logic 2019-03-29 08:18:31 +11:00
haruntuncay 357d0c4333 Fixed code review requests. 2019-03-25 14:22:02 +03:00
Ricky Yim 154335e4a9 Merge pull request #366 from andeb/master
Fix intermittent failing tests
2019-03-25 19:57:37 +11:00
haruntuncay 8b34ad5983 Change hard-coded random integer upper-bound. 2019-03-14 23:23:31 +03:00
haruntuncay 6440b082ec Add hex value generation, both for as color and as random, see issue #282 2019-03-14 23:09:15 +03:00
Anderson de Borba 45a5315cd4 Adding missing characters to the regex 2019-03-07 23:02:15 +00:00
Anderson de Borba 4296a648a4 Fix intermittent failing test by supporting words with dash like "First-Class" in the regex 2019-03-07 22:43:03 +00:00
haruntuncay e2eec2f552 Add digit constraint for passwords, issue #360 2019-02-28 00:30:21 +03:00
Ricky Yim b18526f360 Merge pull request #358 from haruntuncay/master
Add a convenient way to get USER_AGENT values and add new fake user_agent values, see issue #336
2019-02-14 19:30:59 +11:00
haruntuncay 99bcbd4e74 Fixed the issues that are pointed out in PR review. 2019-02-14 11:24:07 +03:00
haruntuncay 0da6663c1e Add convenient way to get USER_AGENT values, see issue #336 2019-02-13 19:01:04 +03:00
Ricky Yim 8013b21745 Merge pull request #353 from ckurtm/master
added Country property
2019-02-10 15:25:28 +11:00
ckurtm 1f75676a77 - use camelCase for Country 2019-02-10 05:25:46 +02:00
ckurtm d10a91628c - update FakerIt to include Country 2019-02-10 03:53:34 +02:00
ckurtm f377b486e3 - added currency and currency code to Country 2019-02-10 02:59:43 +02:00
ckurtm 1031135026 - add Country
capital - names of capital cities
      code2 - 2 letter country code
      code3 - 3 letter country code
      flag - country flag url
      name - country name
2019-02-10 02:32:05 +02:00
Ricky Yim 6e06c52b7a Update README.md
Updated to latest version and updated the gradle syntax
2019-02-09 16:56:44 +11:00
Ricky 5264f3c8a9 [maven-release-plugin] prepare for next development iteration 2019-02-09 16:28:46 +11:00
Ricky 5aacf67554 [maven-release-plugin] prepare release javafaker-0.17.2 2019-02-09 16:28:30 +11:00
Ricky eb693c37cc simplified en yml file loading so it will work on android as well 2019-02-09 16:14:24 +11:00
Ricky 78c43e3037 [maven-release-plugin] prepare for next development iteration 2019-02-02 11:04:59 +11:00
Ricky 3127b80b00 [maven-release-plugin] prepare release javafaker-0.17.1 2019-02-02 11:04:43 +11:00
Ricky eb66eb9385 fixing NPE 2019-02-02 10:52:09 +11:00
Ricky df8c46da88 [maven-release-plugin] prepare for next development iteration 2019-02-01 20:34:25 +11:00
Ricky 8684b65838 [maven-release-plugin] prepare release javafaker-0.17 2019-02-01 20:34:09 +11:00
Ricky Yim 364126bf65 Merge pull request #330 from alonhartman/he_additions
Some Heb additions
2019-01-30 06:23:53 +11:00
Ricky Yim 370d956289 Merge pull request #329 from matthewtraughber/master
Added ability to get county via zip (en-US locale only)
2019-01-30 06:19:40 +11:00
Ricky Yim f4c3fff71b Merge pull request #345 from longnguyen2306/master
Add more beer brand name of beer, add more adjectives and noun of commerce. Added more quotes to witcher
2019-01-30 06:14:01 +11:00
Ricky Yim 6986a53d9f Merge pull request #347 from valfirst/patch-1
Fix weather descriptions for Russian locale
2019-01-30 06:11:51 +11:00
Valery Yatsynovich e0963d6bbc Fix weather descriptions for Russian locale 2019-01-23 15:51:22 +03:00
Long Nguyen 4e78791a53 Added more quotes for witcher 2019-01-19 11:07:53 +01:00
Long Nguyen d78b7d029c Added more adjective and nouns to commerce 2019-01-19 10:53:54 +01:00
Long Nguyen 13a30260af Update beer brand. Added some popular german brands 2019-01-19 10:44:57 +01:00
Ricky Yim c175aabd16 Merge pull request #339 from codingricky/travis-jdk
Travis jdk
2018-12-20 21:28:42 +11:00
Ricky 3aaef1b527 fixing more asserts 2018-12-20 21:19:06 +11:00
Ricky 7d5c263d8e updated jdk and fixed assert 2018-12-20 21:07:51 +11:00
Ricky Yim ac6d4cdf6f removing jdk 2018-12-20 11:50:53 +11:00
Ricky Yim 9ff4d1647a added more jdk versions into travis 2018-12-20 11:39:51 +11:00
Ricky Yim 4c8b7406f1 Merge pull request #338 from DiUS/new-loading
New loading
2018-12-19 20:54:07 +11:00
alon f024d82908 Some Heb additions 2018-11-09 00:13:42 +02:00
Matthew Traughber f73dd19086 Added ability to get county via zip (en-US locale only) 2018-11-08 14:58:02 -05:00
40 changed files with 41919 additions and 224 deletions
+3
View File
@@ -3,6 +3,8 @@ dist: trusty
jdk:
- oraclejdk8
- openjdk7
- openjdk10
- oraclejdk11
script: "mvn verify failsafe:integration-test failsafe:verify"
branches:
except:
@@ -11,3 +13,4 @@ notifications:
email: false
after_success:
- mvn clean cobertura:cobertura coveralls:cobertura
+2 -6
View File
@@ -17,19 +17,15 @@ In pom.xml, add the following xml stanza between `<dependencies> ... </dependenc
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>0.16</version>
<version>0.17.2</version>
</dependency>
```
For gradle users, add the following to your build.gradle file.
```groovy
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'com.github.javafaker', name: 'javafaker', version: '0.16'
implementation 'com.github.javafaker:javafaker:0.17.2'
}
```
+1 -1
View File
@@ -3,7 +3,7 @@
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<packaging>jar</packaging>
<version>0.17-SNAPSHOT</version>
<version>0.18</version>
<name>Java Faker</name>
<description>
This library is a port of Ruby's stympy/faker gem (as well as Perl's Data::Faker library) that generates fake data.
@@ -35,7 +35,13 @@ public class Address {
return faker.bothify(faker.fakeValuesService().resolve("address.postcode", this,faker));
}
public String zipCodeByState(String stateAbbr) { return faker.fakeValuesService().resolve("address.postcode_by_state." + stateAbbr, this, faker); }
public String zipCodeByState(String stateAbbr) {
return faker.fakeValuesService().resolve("address.postcode_by_state." + stateAbbr, this, faker);
}
public String countyByZipCode(String postCode) {
return faker.fakeValuesService().resolve("address.county_by_postcode." + postCode, this, faker);
}
public String streetSuffix() {
return faker.fakeValuesService().resolve("address.street_suffix", this, faker);
@@ -10,4 +10,15 @@ public class Color {
public String name() {
return faker.fakeValuesService().resolve("color.name", this, faker);
}
public String hex() {
return hex(true);
}
public String hex(boolean includeHashSign) {
String hexString = faker.random().hex(6);
if(includeHashSign)
return "#" + hexString;
return hexString;
}
}
@@ -0,0 +1,36 @@
package com.github.javafaker;
public class Country {
private final Faker faker;
private final String flagUrl;
protected Country(Faker faker) {
this.faker = faker;
this.flagUrl = "http://flags.fmcdn.net/data/flags/w580/";
}
public String flag() {
return flagUrl + faker.fakeValuesService().resolve("country.code2", this, faker) + ".png";
}
public String countryCode2() {
return faker.fakeValuesService().resolve("country.code2", this, faker);
}
public String countryCode3() {
return faker.fakeValuesService().resolve("country.code3", this, faker);
}
public String capital() {
return faker.fakeValuesService().resolve("country.capital", this, faker);
}
public String currency() {
return faker.fakeValuesService().resolve("country.currency", this, faker);
}
public String currencyCode() {
return faker.fakeValuesService().resolve("country.currency_code", this, faker);
}
}
@@ -33,6 +33,7 @@ public class Faker {
private final ChuckNorris chuckNorris;
private final Color color;
private final Commerce commerce;
private final Country country;
private final Currency currency;
private final Company company;
private final Crypto crypto;
@@ -167,6 +168,7 @@ public class Faker {
this.weather = new Weather(this);
this.lebowski = new Lebowski(this);
this.medical = new Medical(this);
this.country = new Country(this);
}
/**
@@ -553,6 +555,8 @@ public class Faker {
public Medical medical(){return medical;}
public Country country(){ return country;}
public String resolve(String key) {
return this.fakeValuesService.resolve(key, this, this);
}
@@ -110,6 +110,10 @@ public class Internet {
return password(8, 16);
}
public String password(boolean includeDigit) {
return password(8, 16, false, false, includeDigit);
}
public String password(int minimumLength, int maximumLength) {
return password(minimumLength, maximumLength, false);
}
@@ -119,15 +123,19 @@ public class Internet {
}
public String password(int minimumLength, int maximumLength, boolean includeUppercase, boolean includeSpecial) {
return password(minimumLength, maximumLength, includeUppercase, includeSpecial, true);
}
public String password(int minimumLength, int maximumLength, boolean includeUppercase, boolean includeSpecial, boolean includeDigit) {
if (includeSpecial) {
char[] password = faker.lorem().characters(minimumLength, maximumLength, includeUppercase).toCharArray();
char[] password = faker.lorem().characters(minimumLength, maximumLength, includeUppercase, includeDigit).toCharArray();
char[] special = new char[]{'!', '@', '#', '$', '%', '^', '&', '*'};
for (int i = 0; i < faker.random().nextInt(minimumLength); i++) {
password[faker.random().nextInt(password.length)] = special[faker.random().nextInt(special.length)];
}
return new String(password);
} else {
return faker.lorem().characters(minimumLength, maximumLength, includeUppercase);
return faker.lorem().characters(minimumLength, maximumLength, includeUppercase, includeDigit);
}
}
@@ -297,4 +305,47 @@ public class Internet {
private <T> T random(T[] src) {
return src[faker.random().nextInt(src.length)];
}
public String userAgent(UserAgent userAgent) {
UserAgent agent = userAgent;
if(agent == null) {
agent = UserAgent.any();
}
String userAgentKey = "internet.user_agent." + agent.toString();
return faker.fakeValuesService().resolve(userAgentKey, this, faker);
}
public String userAgentAny() {
return userAgent(null);
}
public enum UserAgent {
AOL("aol"),
CHROME("chrome"),
FIREFOX("firefox"),
INTERNET_EXPLORER("internet_explorer"),
NETSCAPE("netscape"),
OPERA("opera"),
SAFARI("safari");
//Browser's name in corresponding yaml (internet.yml) file.
private String browserName;
UserAgent(String browserName) {
this.browserName = browserName;
}
private static UserAgent any() {
UserAgent[] agents = UserAgent.values();
int randomIndex = (int)(Math.random() * agents.length);
return agents[randomIndex];
}
@Override
public String toString() {
return browserName;
}
}
}
+21 -4
View File
@@ -39,17 +39,32 @@ public class Lorem {
return characters(faker.random().nextInt(maximumLength - minimumLength) + minimumLength, includeUppercase);
}
public String characters(int minimumLength, int maximumLength, boolean includeUppercase, boolean includeDigit) {
return characters(faker.random().nextInt(maximumLength - minimumLength) + minimumLength, includeUppercase, includeDigit);
}
public String characters(int fixedNumberOfCharacters) {
return characters(fixedNumberOfCharacters, false);
}
public String characters(int fixedNumberOfCharacters, boolean includeUppercase) {
return characters(fixedNumberOfCharacters, includeUppercase, true);
}
public String characters(int fixedNumberOfCharacters, boolean includeUppercase, boolean includeDigit) {
if (fixedNumberOfCharacters < 1) {
return "";
}
char[] buffer = new char[fixedNumberOfCharacters];
for (int i = 0; i < buffer.length; i++) {
char randomCharacter = characters[faker.random().nextInt(characters.length)];
char randomCharacter;
if (includeDigit) {
randomCharacter = characters[faker.random().nextInt(characters.length)];
} else {
randomCharacter = letters[faker.random().nextInt(letters.length)];
}
if (includeUppercase && faker.bool().bool()) {
randomCharacter = Character.toUpperCase(randomCharacter);
}
@@ -145,15 +160,17 @@ public class Lorem {
static {
StringBuilder builder = new StringBuilder(36);
for (char number = '0'; number <= '9'; number++) {
builder.append(number);
}
for (char character = 'a'; character <= 'z'; character++) {
builder.append(character);
}
letters = builder.toString().toCharArray();
for (char number = '0'; number <= '9'; number++) {
builder.append(number);
}
characters = builder.toString().toCharArray();
}
private static final char[] letters;
private static final char[] characters;
}
@@ -0,0 +1,92 @@
package com.github.javafaker.service;
import org.yaml.snakeyaml.Yaml;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
public class FakeValues implements FakeValuesInterface {
private final Locale locale;
private final String filename;
private final String path;
private Map values;
FakeValues(Locale locale) {
this(locale, getFilename(locale), getFilename(locale));
}
private static String getFilename(Locale locale) {
final StringBuilder filename = new StringBuilder(language(locale));
if (!"".equals(locale.getCountry())) {
filename.append("-").append(locale.getCountry());
}
return filename.toString();
}
/**
* If you new up a locale with "he", it gets converted to "iw" which is old.
* This addresses that unfortunate condition.
*/
private static String language(Locale l) {
if (l.getLanguage().equals("iw")) {
return "he";
}
return l.getLanguage();
}
FakeValues(Locale locale, String filename, String path) {
this.locale = locale;
this.filename = filename;
this.path = path;
}
@Override
public Map get(String key) {
if (values == null) {
values = loadValues();
}
return values == null ? null : (Map) values.get(key);
}
private Map loadValues() {
String pathWithLocaleAndFilename = "/" + locale.getLanguage() + "/" + this.filename;
String pathWithFilename = "/" + filename + ".yml";
String pathWithLocale = "/" + locale.getLanguage() + ".yml";
List<String> paths = Arrays.asList(pathWithLocaleAndFilename, pathWithFilename, pathWithLocale);
InputStream stream = null;
for (String path : paths) {
stream = findStream(path);
if (stream != null) {
break;
}
}
if (stream == null) {
return null;
}
final Map valuesMap = new Yaml().loadAs(stream, Map.class);
Map localeBased = (Map) valuesMap.get(locale.getLanguage());
if (localeBased == null) {
localeBased = (Map) valuesMap.get(filename);
}
return (Map) localeBased.get("faker");
}
private InputStream findStream(String filename) {
InputStream streamOnClass = getClass().getResourceAsStream(filename);
if (streamOnClass != null) {
return streamOnClass;
}
return getClass().getClassLoader().getResourceAsStream(filename);
}
boolean supportsPath(String path) {
return this.path.equals(path);
}
}
@@ -0,0 +1,31 @@
package com.github.javafaker.service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class FakeValuesGrouping implements FakeValuesInterface {
private List<FakeValues> fakeValuesList = new ArrayList<FakeValues>();
public void add(FakeValues fakeValues) {
fakeValuesList.add(fakeValues);
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Map get(String key) {
Map result = null;
for (FakeValues fakeValues : fakeValuesList) {
if (fakeValues.supportsPath(key)) {
if (result != null) {
final Map newResult = fakeValues.get(key);
result.putAll(newResult);
} else {
result = fakeValues.get(key);
}
}
}
return result;
}
}
@@ -0,0 +1,7 @@
package com.github.javafaker.service;
import java.util.Map;
public interface FakeValuesInterface {
Map get(String key);
}
@@ -3,18 +3,21 @@ package com.github.javafaker.service;
import com.github.javafaker.Address;
import com.github.javafaker.Faker;
import com.github.javafaker.Name;
import com.github.javafaker.service.files.EnFile;
import com.mifmif.common.regex.Generex;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
import org.yaml.snakeyaml.Yaml;
import java.io.File;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
@@ -24,28 +27,28 @@ public class FakeValuesService {
private static final Pattern EXPRESSION_PATTERN = Pattern.compile("#\\{([a-z0-9A-Z_.]+)\\s?(?:'([^']+)')?(?:,'([^']+)')*\\}");
private final Logger log = Logger.getLogger("faker");
private final List<Map<String, Object>> fakeValuesMaps;
private final List<FakeValuesInterface> fakeValuesList;
private final RandomService randomService;
/**
* <p>
* Resolves YAML file using the most specific path first based on language and country code.
* 'en_US' would resolve in the following order:
* <ol>
* <li>/en-US.yml</li>
* <li>/en.yml</li>
* </ol>
* The search is case-insensitive, so the following will all resolve correctly. Also, either a hyphen or
* an underscore can be used when constructing a {@link Locale} instance. This is legacy behavior and not
* condoned, but it will work.
* <ul>
* <li>EN_US</li>
* <li>En-Us</li>
* <li>eN_uS</li>
* </ul>
* Resolves YAML file using the most specific path first based on language and country code.
* 'en_US' would resolve in the following order:
* <ol>
* <li>/en-US.yml</li>
* <li>/en.yml</li>
* </ol>
* The search is case-insensitive, so the following will all resolve correctly. Also, either a hyphen or
* an underscore can be used when constructing a {@link Locale} instance. This is legacy behavior and not
* condoned, but it will work.
* <ul>
* <li>EN_US</li>
* <li>En-Us</li>
* <li>eN_uS</li>
* </ul>
* </p>
*
* @param locale
* @param randomService
*/
@@ -58,80 +61,29 @@ public class FakeValuesService {
locale = normalizeLocale(locale);
final List<Locale> locales = localeChain(locale);
final List<Map<String,Object>> all = new ArrayList(locales.size());
final Set<Locale> loadedLocales = new HashSet<Locale>();
final List<FakeValuesInterface> all = new ArrayList(locales.size());
for (final Locale l : locales) {
final StringBuilder filename = new StringBuilder(language(l));
if (!"".equals(l.getCountry())) {
filename.append("-").append(l.getCountry());
}
// list the files on the classpath... so if we pass in "en"
// it will look for a folder "en" and list all the files underneath it
File[] files = listFilesInDirectoryOnClasspath(filename.toString());
for (File resourceFolderFile : files) {
String fileToLoad = filename + "/" + resourceFolderFile.getName();
final InputStream stream = getClass().getClassLoader().getResourceAsStream(fileToLoad);
if (stream != null) {
Map map = fakerFromStream(stream, filename.toString());
all.add(map);
loadedLocales.add(l);
boolean isEnglish = l.equals(Locale.ENGLISH);
if (isEnglish) {
FakeValuesGrouping fakeValuesGrouping = new FakeValuesGrouping();
for (EnFile file : EnFile.getFiles()) {
fakeValuesGrouping.add(new FakeValues(l, file.getFile(), file.getPath()));
}
}
final InputStream stream = findStream(filename.toString());
if (stream != null) {
all.add(fakerFromStream(stream, filename.toString()));
loadedLocales.add(l);
all.add(fakeValuesGrouping);
} else {
all.add(new FakeValues(locale));
}
}
if (loadedLocales.size() == 1 && loadedLocales.contains(Locale.ENGLISH) && !locale.equals(Locale.ENGLISH)) {
// if we have only successfully loaded ENGLISH and the requested locale
// wasn't english that means we were unable to load the requested locale
// in that case we vomit.
// If someone requests FRANCE ("fr","FR") and we can't load fr_FR but we
// load "fr", then that's ok. we picked up a variant. only if we ONLY pick up
// the default do we throw that exception.
throw new LocaleDoesNotExistException(locale.toString() + " does not exist");
}
this.fakeValuesMaps = Collections.unmodifiableList(all);
}
private File[] listFilesInDirectoryOnClasspath(String dir) {
ClassLoader loader = getClass().getClassLoader();
URL url = loader.getResource(dir);
return (url != null) ? new File(url.getPath()).listFiles() : new File[0];
}
/**
* If you new up a locale with "he", it gets converted to "iw" which is old.
* This addresses that unfortunate condition.
*/
private String language(Locale l) {
if (l.getLanguage().equals("iw")) {
return "he";
}
return l.getLanguage();
}
/**
* @return the embedded faker: clause from the loaded Yml by the localeName, so .yml > en-us: > faker:
*/
protected Map fakerFromStream(InputStream stream, String localeName) {
final Map valuesMap = new Yaml().loadAs(stream, Map.class);
final Map localeBased = (Map) valuesMap.get(localeName);
return (Map) localeBased.get("faker");
this.fakeValuesList = Collections.unmodifiableList(all);
}
/**
* Convert the specified locale into a chain of locales used for message resolution. For example:
*
* {@link Locale#FRANCE} (fr_FR) -> [ fr_FR, fr, en ]
*
* <p>
* {@link Locale#FRANCE} (fr_FR) -> [ fr_FR, anotherTest, en ]
*
* @return a list of {@link Locale} instances
*/
protected List<Locale> localeChain(Locale from) {
@@ -149,31 +101,22 @@ public class FakeValuesService {
chain.add(Locale.ENGLISH); // default
return chain;
}
/**
* @return a proper {@link Locale} instance with language and country code set regardless of how
* it was instantiated. new Locale("pt-br") will be normalized to a locale constructed
* with new Locale("pt","BR").
* it was instantiated. new Locale("pt-br") will be normalized to a locale constructed
* with new Locale("pt","BR").
*/
private Locale normalizeLocale(Locale locale) {
final String[] parts = locale.toString().split("[-\\_]");
if (parts.length == 1) {
return new Locale(parts[0]);
} else {
return new Locale(parts[0],parts[1]);
return new Locale(parts[0], parts[1]);
}
}
private InputStream findStream(String filename) {
String filenameWithExtension = "/" + filename + ".yml";
InputStream streamOnClass = getClass().getResourceAsStream(filenameWithExtension);
if (streamOnClass != null) {
return streamOnClass;
}
return getClass().getClassLoader().getResourceAsStream(filenameWithExtension);
}
/**
* Fetch a random value from an array item specified by the key
*
@@ -240,10 +183,15 @@ public class FakeValuesService {
String[] path = key.split("\\.");
Object result = null;
for (Map<String, Object> fakeValuesMap : fakeValuesMaps) {
Object currentValue = fakeValuesMap;
for (FakeValuesInterface fakeValuesInterface : fakeValuesList) {
Object currentValue = fakeValuesInterface;
for (int p = 0; currentValue != null && p < path.length; p++) {
currentValue = ((Map<String, Object>) currentValue).get(path[p]);
String currentPath = path[p];
if (currentValue instanceof Map) {
currentValue = ((Map) currentValue).get(currentPath);
} else {
currentValue = ((FakeValuesInterface) currentValue).get(currentPath);
}
}
result = currentValue;
if (result != null) {
@@ -286,7 +234,7 @@ public class FakeValuesService {
}
/**
* Applies both a {@link #numerify(String)} and a {@link #letterify(String,boolean)}
* Applies both a {@link #numerify(String)} and a {@link #letterify(String, boolean)}
* over the incoming string.
*
* @param string
@@ -326,7 +274,7 @@ public class FakeValuesService {
* For example, the string "12??34" could be replaced with a string like "12AB34".
*
* @param letterString
* @param isUpper specifies whether or not letters should be upper case
* @param isUpper specifies whether or not letters should be upper case
* @return
*/
public String letterify(String letterString, boolean isUpper) {
@@ -348,14 +296,14 @@ public class FakeValuesService {
/**
* Resolves a key to a method on an object.
*
* <p>
* #{hello} with result in a method call to current.hello();
*
* <p>
* #{Person.hello_someone} will result in a method call to person.helloSomeone();
*
*/
public String resolve(String key, Object current, Faker root) {
final String expression = safeFetch(key, null);
if (expression == null) {
throw new RuntimeException(key + " resulted in null expression");
}
@@ -365,6 +313,7 @@ public class FakeValuesService {
/**
* resolves an expression using the current faker.
*
* @param expression
* @param faker
* @return
@@ -372,22 +321,23 @@ public class FakeValuesService {
public String expression(String expression, Faker faker) {
return resolveExpression(expression, null, faker);
}
/**
* <p>processes a expression in the style #{X.y} using the current objects as the 'current' location
* within the yml file (or the {@link Faker} object hierarchy as it were).
* </p>
* <p>
* #{Address.streetName} would get resolved to {@link Faker#address()}'s {@link Address#streetName()}
* #{Address.streetName} would get resolved to {@link Faker#address()}'s {@link Address#streetName()}
* </p>
* <p>
* #{address.street} would get resolved to the YAML > locale: faker: address: street:
* #{address.street} would get resolved to the YAML > locale: faker: address: street:
* </p>
* <p>
* Combinations are supported as well: "#{x} #{y}"
* Combinations are supported as well: "#{x} #{y}"
* </p>
* <p>
* Recursive templates are supported. if "#{x}" resolves to "#{Address.streetName}" then "#{x}" resolves to
* {@link Faker#address()}'s {@link Address#streetName()}.
* Recursive templates are supported. if "#{x}" resolves to "#{Address.streetName}" then "#{x}" resolves to
* {@link Faker#address()}'s {@link Address#streetName()}.
* </p>
*/
protected String resolveExpression(String expression, Object current, Faker root) {
@@ -398,10 +348,10 @@ public class FakeValuesService {
final String escapedDirective = matcher.group(0);
final String directive = matcher.group(1);
List<String> args = new ArrayList<String>();
for (int i=2;i < matcher.groupCount()+1 && matcher.group(i) != null;i++) {
for (int i = 2; i < matcher.groupCount() + 1 && matcher.group(i) != null; i++) {
args.add(matcher.group(i));
}
// resolve the expression and reprocess it to handle recursive templates
String resolved = resolveExpression(directive, args, current, root);
if (resolved == null) {
@@ -417,20 +367,21 @@ public class FakeValuesService {
/**
* <h1>Search Order</h1>
* <ul>
* <li>Search for methods on the current object</li>
* <li>local keys in Yaml File</li>
* <li>Search for methods on faker child objects</li>
* <li>Search for keys in yaml file by transforming object reference to yaml reference</li>
* <li>Search for methods on the current object</li>
* <li>local keys in Yaml File</li>
* <li>Search for methods on faker child objects</li>
* <li>Search for keys in yaml file by transforming object reference to yaml reference</li>
* </ul>
*
* @return null if unable to resolve
*/
private String resolveExpression(String directive, List<String> args, Object current, Faker root) {
// name.name (resolve locally)
// Name.first_name (resolve to faker.name().firstName())
final String simpleDirective = (isDotDirective(directive) || current == null)
? directive
final String simpleDirective = (isDotDirective(directive) || current == null)
? directive
: classNameToYamlName(current) + "." + directive;
String resolved = null;
// resolve method references on CURRENT object like #{number_between '1','10'} on Number or
// #{ssn_valid} on IdNumber
@@ -439,7 +390,7 @@ public class FakeValuesService {
}
// simple fetch of a value from the yaml file. the directive may have been mutated
// such that if the current yml object is car: and directive is #{wheel} then
// such that if the current yml object is car: and directive is #{wheel} then
// car.wheel will be looked up in the YAML file.
if (resolved == null) {
resolved = safeFetch(simpleDirective, null);
@@ -454,16 +405,16 @@ public class FakeValuesService {
if (resolved == null && isDotDirective(directive)) {
resolved = resolveFakerObjectAndMethod(root, directive, args);
}
// last ditch effort. Due to Ruby's dynamic nature, something like 'Address.street_title' will resolve
// because 'street_title' is a dynamic method on the Address object. We can't do this in Java so we go
// because 'street_title' is a dynamic method on the Address object. We can't do this in Java so we go
// thru the normal resolution above, but if we will can't resolve it, we once again do a 'safeFetch' as we
// did first but FIRST we change the Object reference Class.method_name with a yml style internal refernce ->
// class.method_name (lowercase)
if (resolved == null && isDotDirective(directive)) {
resolved = safeFetch(javaNameToYamlName(simpleDirective), null);
}
return resolved;
}
@@ -478,6 +429,7 @@ public class FakeValuesService {
/**
* Given a {@code slashDelimitedRegex} such as {@code /[ab]/}, removes the slashes and returns only {@code [ab]}
*
* @param slashDelimitedRegex a non null slash delimited regex (ex. {@code /[ab]/})
* @return the regex without the slashes (ex. {@code [ab]})
*/
@@ -490,14 +442,14 @@ public class FakeValuesService {
}
/**
* @return a yaml style name from the classname of the supplied object (PhoneNumber => phone_number)
* @return a yaml style name from the classname of the supplied object (PhoneNumber => phone_number)
*/
private String classNameToYamlName(Object current) {
return javaNameToYamlName(current.getClass().getSimpleName());
}
/**
* @return a yaml style name like 'phone_number' from a java style name like 'PhoneNumber'
* @return a yaml style name like 'phone_number' from a java style name like 'PhoneNumber'
*/
private String javaNameToYamlName(String expression) {
return expression.replaceAll("([A-Z])", "_$1")
@@ -506,7 +458,6 @@ public class FakeValuesService {
}
/**
* Given a directive like 'firstName', attempts to resolve it to a method. For example if obj is an instance of
* {@link Name} then this method would return {@link Name#firstName()}. Returns null if the directive is nested
@@ -526,15 +477,16 @@ public class FakeValuesService {
return null;
}
}
/**
* Accepts a {@link Faker} instance and a name.firstName style 'key' which is resolved to the return value of:
* {@link Faker#name()}'s {@link Name#firstName()} method.
*
* @throws RuntimeException if there's a problem invoking the method or it doesn't exist.
*/
private String resolveFakerObjectAndMethod(Faker faker, String key, List<String> args) {
final String[] classAndMethod = key.split("\\.", 2);
try {
String fakerMethodName = classAndMethod[0].replaceAll("_", "");
MethodAndCoercedArgs fakerAccessor = accessor(faker, fakerMethodName, Collections.<String>emptyList());
@@ -558,15 +510,15 @@ public class FakeValuesService {
}
}
/**
* Find an accessor by name ignoring case.
*/
private MethodAndCoercedArgs accessor(Object onObject, String name, List<String> args) {
log.log(Level.FINE, "Find accessor named " + name + " on " + onObject.getClass().getSimpleName() + " with args " + args);
for (Method m : onObject.getClass().getMethods()) {
if (m.getName().equalsIgnoreCase(name)
if (m.getName().equalsIgnoreCase(name)
&& m.getParameterTypes().length == args.size()) {
final List<Object> coercedArguments = coerceArguments(m, args);
if (coercedArguments != null) {
@@ -584,6 +536,7 @@ public class FakeValuesService {
/**
* Coerce arguments in <em>args</em> into the appropriate types (if possible) for the parameter arguments
* to <em>accessor</em>.
*
* @return array of coerced values if successful, null otherwise
* @throws Exception if unable to coerce
*/
@@ -593,10 +546,16 @@ public class FakeValuesService {
Class<?> toType = ClassUtils.primitiveToWrapper(accessor.getParameterTypes()[i]);
try {
final Constructor<?> ctor = toType.getConstructor(String.class);
final Object coercedArgument = ctor.newInstance(args.get(i));
coerced.add(coercedArgument);
if (toType.isEnum()) {
Method method = toType.getMethod( "valueOf", String.class );
String enumArg = args.get( i ).substring( args.get( i ).indexOf( "." ) + 1 );
Object coercedArg = method.invoke( null, enumArg );
coerced.add( coercedArg );
} else {
final Constructor<?> ctor = toType.getConstructor(String.class);
final Object coercedArgument = ctor.newInstance(args.get(i));
coerced.add(coercedArgument);
}
} catch (Exception e) {
log.fine("Unable to coerce " + args.get(i) + " to " + toType.getSimpleName() + " via " + toType.getSimpleName() + "(String) constructor.");
return null;
@@ -604,7 +563,7 @@ public class FakeValuesService {
}
return coerced;
}
private String string(Object obj) {
return (obj == null) ? null : obj.toString();
}
@@ -617,14 +576,14 @@ public class FakeValuesService {
private class MethodAndCoercedArgs {
private final Method method;
private final List<Object> coerced;
private MethodAndCoercedArgs(Method m, List<Object> coerced) {
this.method = requireNonNull(m, "method cannot be null");
this.coerced = requireNonNull(coerced, "coerced arguments cannot be null");
}
private Object invoke(Object on) throws InvocationTargetException, IllegalAccessException {
return method.invoke(on, coerced.toArray());
}
@@ -1,7 +0,0 @@
package com.github.javafaker.service;
public class LocaleDoesNotExistException extends RuntimeException {
public LocaleDoesNotExistException(String message) {
super(message);
}
}
@@ -54,4 +54,17 @@ public class RandomService {
public Integer nextInt(int min, int max) {
return random.nextInt((max - min) + 1) + min;
}
public String hex() {
return hex(8);
}
public String hex(int length) {
char[] hexValues = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
StringBuilder hexString = new StringBuilder();
for(int i = 0; i < length; i++) {
hexString.append(hexValues[nextInt(hexValues.length)]);
}
return hexString.toString();
}
}
@@ -0,0 +1,198 @@
package com.github.javafaker.service.files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class EnFile {
private final String file;
private final String path;
private EnFile(String file) {
this(file, file.replaceFirst(".yml", ""));
}
private EnFile(String file, String path) {
this.file = file;
this.path = path;
}
public String getFile() {
return file;
}
public String getPath() {
return path;
}
private static List<String> FILES = Arrays.asList("address.yml",
"ancient.yml",
"animal.yml",
"app.yml",
"appliance.yml",
"aqua_teen_hunger_force.yml",
"artist.yml",
"back_to_the_future.yml",
"bank.yml",
"beer.yml",
"bojack_horseman.yml",
"book.yml",
"bossa_nova.yml",
"breaking_bad.yml",
"buffy.yml",
"business.yml",
"cannabis.yml",
"chuck_norris.yml",
"code.yml",
"coffee.yml",
"coin.yml",
"color.yml",
"commerce.yml",
"community.yml",
"company.yml",
"compass.yml",
"construction.yml",
"cosmere.yml",
"country.yml",
"crypto_coin.yml",
"currency.yml",
"dc_comics.yml",
"demographic.yml",
"dessert.yml",
"device.yml",
"dota.yml",
"dr_who.yml",
"dragon_ball.yml",
"dumb_and_dumber.yml",
"dune.yml",
"educator.yml",
"elder_scrolls.yml",
"electrical_components.yml",
"esport.yml",
"fallout.yml",
"family_guy.yml",
"famous_last_words.yml",
"file.yml",
"finance.yml",
"food.yml",
"football.yml",
"fresh_prince_of_bel_air.yml",
"friends.yml",
"funny_name.yml",
"game_of_thrones.yml",
"gender.yml",
"ghostbusters.yml",
"grateful_dead.yml",
"greek_philosophers.yml",
"hacker.yml",
"half_life.yml",
"harry_potter.yml",
"heroes.yml",
"heroes_of_the_storm.yml",
"hey_arnold.yml",
"hipster.yml",
"hitchhikers_guide_to_the_galaxy.yml",
"hobbit.yml",
"house.yml",
"how_i_met_your_mother.yml",
"id_number.yml",
"industry_segments.yml",
"internet.yml",
"invoice.yml",
"job.yml",
"kpop.yml",
"lebowski.yml",
"lord_of_the_rings.yml",
"lorem.yml",
"lovecraft.yml",
"markdown.yml",
"marketing.yml",
"matz.yml",
"measurement.yml",
"medical.yml",
"michael_scott.yml",
"military.yml",
"most_interesting_man_in_the_world.yml",
"movie.yml",
"music.yml",
"myst.yml",
"name.yml",
"nation.yml",
"nato_phonetic_alphabet.yml",
"new_girl.yml",
"one_piece.yml",
"overwatch.yml",
"parks_and_rec.yml",
"phish.yml",
"phone_number.yml",
"pokemon.yml",
"princess_bride.yml",
"programming_language.yml",
"relationship.yml",
"restaurant.yml",
"rick_and_morty.yml",
"robin.yml",
"rock_band.yml",
"rupaul.yml",
"science.yml",
"seinfeld.yml",
"shakespeare.yml",
"silicon_valley.yml",
"simpsons.yml",
"singular_siegler.yml",
"slack_emoji.yml",
"sonic_the_hedgehog.yml",
"source.yml",
"south_park.yml",
"space.yml",
"star_trek.yml",
"star_wars.yml",
"stargate.yml",
"stock.yml",
"stranger_thing.yml",
"stripe.yml",
"subscription.yml",
"super_smash_bros.yml",
"superhero.yml",
"sword_art_online.yml",
"team.yml",
"the_expanse.yml",
"the_it_crowd.yml",
"the_thick_of_it.yml",
"twin_peaks.yml",
"umphreys_mcgee.yml",
"university.yml",
"v_for_vendetta.yml",
"vehicle.yml",
"venture_bros.yml",
"verbs.yml",
"weather.yml",
"witcher.yml",
"world_cup.yml",
"world_of_warcraft.yml",
"yoda.yml",
"zelda.yml");
// 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("cat.yml", "creature"),
new EnFile("dog.yml", "creature"),
new EnFile("league_of_legends.yml", "games"),
new EnFile("overwatch.yml", "games"),
new EnFile("pokemon.yml", "games"),
new EnFile("witcher.yml", "games"),
new EnFile("zelda.yml", "games"),
new EnFile("phone_number.yml", "cell_phone")); // load phone number again with a differen path
public static List<EnFile> getFiles() {
List<EnFile> files = new ArrayList<EnFile>();
for (String file : FILES) {
files.add(new EnFile(file));
}
files.addAll(FILES_WITH_A_DIFFERENT_PATH);
return files;
}
}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,7 +1,7 @@
en:
faker:
beer:
brand: ['Corona Extra', 'Heineken', 'Budweiser', 'Becks', 'BudLight', 'Pabst Blue Ribbon', 'Dos Equis', 'Blue Moon', 'Stella Artois', 'Miller Draft', 'Coors lite' , 'Amstel', 'Guinness', 'Kirin Inchiban', 'Tsingtao', 'Sierra Nevada', 'Rolling Rock', 'Red Stripe', 'Paulaner', 'Patagonia', 'Delirium Tremens', 'Delirium Noctorum', 'Samuel Adams', 'Sapporo Premium', 'Carlsberg', 'Pacifico', 'Quimes', 'Murphys', 'Birra Moretti', 'Harp', 'Fosters', 'Hoegaarden', 'Leffe', 'Lowenbrau']
brand: ['Corona Extra', 'Heineken', 'Budweiser', 'Becks', 'BudLight', 'Pabst Blue Ribbon', 'Dos Equis', 'Blue Moon', 'Stella Artois', 'Miller Draft', 'Coors lite' , 'Amstel', 'Guinness', 'Kirin Inchiban', 'Tsingtao', 'Sierra Nevada', 'Rolling Rock', 'Red Stripe', 'Paulaner', 'Patagonia', 'Delirium Tremens', 'Delirium Noctorum', 'Samuel Adams', 'Sapporo Premium', 'Carlsberg', 'Pacifico', 'Quimes', 'Murphys', 'Birra Moretti', 'Harp', 'Fosters', 'Hoegaarden', 'Leffe', 'Lowenbrau', 'Becks', 'Bitburger', 'Koenig Pilsener', 'Vitamalz', 'Schluessel Alt', 'Charlottenburger Pilsener', 'Brinkhoffs', 'Oettinger', 'Krombacher', 'Veltins', 'Warsteiner']
name: ['Pliny The Elder', 'Founders Kentucky Breakfast', 'Trappistes Rochefort 10', 'HopSlam Ale', 'Stone Imperial Russian Stout', 'St. Bernardus Abt 12', 'Founders Breakfast Stout', 'Weihenstephaner Hefeweissbier', 'Péché Mortel', 'Celebrator Doppelbock', 'Duvel', 'Dreadnaught IPA', 'Nugget Nectar', 'La Fin Du Monde', 'Bourbon County Stout', 'Old Rasputin Russian Imperial Stout', 'Two Hearted Ale', 'Ruination IPA', 'Schneider Aventinus', 'Double Bastard Ale', '90 Minute IPA', 'Hop Rod Rye', 'Trappistes Rochefort 8', 'Chimay Grande Réserve', 'Stone IPA', 'Arrogant Bastard Ale', 'Edmund Fitzgerald Porter', 'Chocolate St', 'Oak Aged Yeti Imperial Stout', 'Ten FIDY', 'Storm King Stout', 'Shakespeare Oatmeal', 'Alpha King Pale Ale', 'Westmalle Trappist Tripel', 'Samuel Smiths Imperial IPA', 'Yeti Imperial Stout', 'Hennepin', 'Samuel Smiths Oatmeal Stout', 'Brooklyn Black', 'Oaked Arrogant Bastard Ale', 'Sublimely Self-Righteous Ale', 'Trois Pistoles', 'Bells Expedition', 'Sierra Nevada Celebration Ale', 'Sierra Nevada Bigfoot Barleywine Style Ale', 'Racer 5 India Pale Ale, Bear Republic Bre', 'Orval Trappist Ale', 'Hercules Double IPA', 'Maharaj', 'Maudite']
hop: ['Ahtanum', 'Amarillo', 'Bitter Gold', 'Bravo', 'Brewers Gold', 'Bullion', 'Cascade', 'Cashmere', 'Centennial', 'Chelan', 'Chinook', 'Citra', 'Cluster', 'Columbia', 'Columbus', 'Comet', 'Crystal', 'Equinox', 'Eroica', 'Fuggle', 'Galena', 'Glacier', 'Golding', 'Hallertau', 'Horizon', 'Liberty', 'Magnum', 'Millennium', 'Mosaic', 'Mt. Hood', 'Mt. Rainier', 'Newport', 'Northern Brewer', 'Nugget', 'Olympic', 'Palisade', 'Perle', 'Saaz', 'Santiam', 'Simcoe', 'Sorachi Ace', 'Sterling', 'Summit', 'Tahoma', 'Tettnang', 'TriplePearl', 'Ultra', 'Vanguard', 'Warrior', 'Willamette', 'Yakima Gol']
yeast: ['1007 - German Ale', '1010 - American Wheat', '1028 - London Ale', '1056 - American Ale', '1084 - Irish Ale', '1098 - British Ale', '1099 - Whitbread Ale', '1187 - Ringwood Ale', '1272 - American Ale II', '1275 - Thames Valley Ale', '1318 - London Ale III', '1332 - Northwest Ale', '1335 - British Ale II', '1450 - Dennys Favorite 50', '1469 - West Yorkshire Ale', '1728 - Scottish Ale', '1968 - London ESB Ale', '2565 - Kölsch', '1214 - Belgian Abbey', '1388 - Belgian Strong Ale', '1762 - Belgian Abbey II', '3056 - Bavarian Wheat Blend', '3068 - Weihenstephan Weizen', '3278 - Belgian Lambic Blend', '3333 - German Wheat', '3463 - Forbidden Fruit', '3522 - Belgian Ardennes', '3638 - Bavarian Wheat', '3711 - French Saison', '3724 - Belgian Saison', '3763 - Roeselare Ale Blend', '3787 - Trappist High Gravity', '3942 - Belgian Wheat', '3944 - Belgian Witbier', '2000 - Budvar Lager', '2001 - Urquell Lager', '2007 - Pilsen Lager', '2035 - American Lager', '2042 - Danish Lager', '2112 - California Lager', '2124 - Bohemian Lager', '2206 - Bavarian Lager', '2278 - Czech Pils', '2308 - Munich Lager', '2633 - Octoberfest Lager Blend', '5112 - Brettanomyces bruxellensis', '5335 - Lactobacillus', '5526 - Brettanomyces lambicus', '5733 - Pediococcus']
+2 -2
View File
@@ -7,5 +7,5 @@ en:
material: [Steel, Wooden, Concrete, Plastic, Cotton, Granite, Rubber, Leather, Silk, Wool, Linen, Marble, Iron, Bronze, Copper, Aluminum, Paper]
product: [Chair, Car, Computer, Gloves, Pants, Shirt, Table, Shoes, Hat, Plate, Knife, Bottle, Coat, Lamp, Keyboard, Bag, Bench, Clock, Watch, Wallet]
promotion_code:
adjective: ['Amazing', 'Awesome', 'Cool', 'Good', 'Great', 'Incredible', 'Killer', 'Premium', 'Special', 'Stellar', 'Sweet']
noun: ['Code', 'Deal', 'Discount', 'Price', 'Promo', 'Promotion', 'Sale', 'Savings']
adjective: ['Amazing', 'Awesome', 'Cool', 'Good', 'Great', 'Incredible', 'Special', 'Surprising', 'Wonderful', 'Marvelous', 'Unbelievable', 'Stunning', 'Spectacular', 'Breathtaking', 'Exciting', 'Impressive', 'Overwhelming', 'Thrilling', 'First-Class']
noun: ['Code', 'Deal', 'Discount', 'Price', 'Promo', 'Promotion', 'Sale', 'Savings', 'Rebate', 'Bonus', 'Benefit', 'Bounty', 'Perk', 'Reward', 'Winning']
+9
View File
@@ -0,0 +1,9 @@
en:
faker:
country:
code2: ['af', 'al', 'dz', 'ad', 'ao', 'ag', 'ar', 'am', 'au', 'at', 'az', 'bs', 'bh', 'bd', 'bb', 'by', 'be', 'bz', 'bj', 'bt', 'bo', 'ba', 'bw', 'br', 'bn', 'bg', 'bf', 'bi', 'cv', 'kh', 'cm', 'ca', 'cf', 'td', 'cl', 'cn', 'co', 'km', 'cg', 'cd', 'cr', 'ci', 'hr', 'cu', 'cy', 'cz', 'dk', 'dj', 'dm', 'do', 'ec', 'eg', 'sv', 'gq', 'er', 'ee', 'sz', 'et', 'fj', 'fi', 'fr', 'ga', 'gm', 'ge', 'de', 'gh', 'gr', 'gd', 'gt', 'gn', 'gw', 'gy', 'ht', 'hn', 'hu', 'is', 'in', 'id', 'ir', 'iq', 'ie', 'il', 'it', 'jm', 'jp', 'jo', 'kz', 'ke', 'ki', 'kp', 'kr', 'kw', 'kg', 'la', 'lv', 'lb', 'ls', 'lr', 'ly', 'li', 'lt', 'lu', 'mk', 'mg', 'mw', 'my', 'mv', 'ml', 'mt', 'mh', 'mr', 'mu', 'mx', 'fm', 'md', 'mc', 'mn', 'me', 'ma', 'mz', 'mm', 'na', 'nr', 'np', 'nl', 'nz', 'ni', 'ne', 'ng', 'no', 'om', 'pk', 'pw', 'pa', 'pg', 'py', 'pe', 'ph', 'pl', 'pt', 'qa', 'ro', 'ru', 'rw', 'kn', 'lc', 'vc', 'ws', 'sm', 'st', 'sa', 'sn', 'rs', 'sc', 'sl', 'sg', 'sk', 'si', 'sb', 'so', 'za', 'ss', 'es', 'lk', 'sd', 'sr', 'se', 'ch', 'sy', 'tj', 'tz', 'th', 'tl', 'tg', 'to', 'tt', 'tn', 'tr', 'tm', 'tv', 'ug', 'ua', 'ae', 'gb', 'us', 'uy', 'uz', 'vu', 've', 'vn', 'ye', 'zm', 'zw']
code3: ['afg', 'alb', 'dza', 'and', 'ago', 'atg', 'arg', 'arm', 'aus', 'aut', 'aze', 'bhs', 'bhr', 'bgd', 'brb', 'blr', 'bel', 'blz', 'ben', 'btn', 'bol', 'bih', 'bwa', 'bra', 'brn', 'bgr', 'bfa', 'bdi', 'cpv', 'khm', 'cmr', 'can', 'caf', 'tcd', 'chl', 'chn', 'col', 'com', 'cog', 'cod', 'cri', 'civ', 'hrv', 'cub', 'cyp', 'cze', 'dnk', 'dji', 'dma', 'dom', 'ecu', 'egy', 'slv', 'gnq', 'eri', 'est', 'swz', 'eth', 'fji', 'fin', 'fra', 'gab', 'gmb', 'geo', 'deu', 'gha', 'grc', 'grd', 'gtm', 'gin', 'gnb', 'guy', 'hti', 'hnd', 'hun', 'isl', 'ind', 'idn', 'irn', 'irq', 'irl', 'isr', 'ita', 'jam', 'jpn', 'jor', 'kaz', 'ken', 'kir', 'prk', 'kor', 'kwt', 'kgz', 'lao', 'lva', 'lbn', 'lso', 'lbr', 'lby', 'lie', 'ltu', 'lux', 'mkd', 'mdg', 'mwi', 'mys', 'mdv', 'mli', 'mlt', 'mhl', 'mrt', 'mus', 'mex', 'fsm', 'mda', 'mco', 'mng', 'mne', 'mar', 'moz', 'mmr', 'nam', 'nru', 'npl', 'nld', 'nzl', 'nic', 'ner', 'nga', 'nor', 'omn', 'pak', 'plw', 'pan', 'png', 'pry', 'per', 'phl', 'pol', 'prt', 'qat', 'rou', 'rus', 'rwa', 'kna', 'lca', 'vct', 'wsm', 'smr', 'stp', 'sau', 'sen', 'srb', 'syc', 'sle', 'sgp', 'svk', 'svn', 'slb', 'som', 'zaf', 'ssd', 'esp', 'lka', 'sdn', 'sur', 'swe', 'che', 'syr', 'tjk', 'tza', 'tha', 'tls', 'tgo', 'ton', 'tto', 'tun', 'tur', 'tkm', 'tuv', 'uga', 'ukr', 'are', 'gbr', 'usa', 'ury', 'uzb', 'vut', 'ven', 'vnm', 'yem', 'zmb', 'zwe']
name: ["Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia (Plurinational State of)", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo", "Congo, Democratic Republic of the", "Costa Rica", "Côte d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czechia", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Eswatini", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran (Islamic Republic of)", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea (Democratic People's Republic of)", "Korea, Republic of", "Kuwait", "Kyrgyzstan", "Lao People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia, the former Yugoslav Republic of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia (Federated States of)", "Moldova, Republic of", "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russian Federation", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Sweden", "Switzerland", "Syrian Arab Republic", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom of Great Britain and Northern Ireland", "United States of America", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela (Bolivarian Republic of)", "Viet Nam", "Yemen", "Zambia", "Zimbabwe"]
capital: ["Hargeisa", "King Edward Point", "Port-aux-Français", "Jerusalem", "Mariehamn", "Yaren", "Marigot", "Atafu", "El-Aaiún", "Kabul", "Tirana", "Algiers", "Pago Pago", "Andorra la Vella", "Luanda", "The Valley", "Saint John's", "Buenos Aires", "Yerevan", "Oranjestad", "Canberra", "Vienna", "Baku", "Nassau", "Manama", "Dhaka", "Bridgetown", "Minsk", "Brussels", "Belmopan", "Porto-Novo", "Hamilton", "Thimphu", "La Paz", "Sarajevo", "Gaborone", "Brasilia", "Road Town", "Bandar Seri Begawan", "Sofia", "Ouagadougou", "Rangoon", "Bujumbura", "Phnom Penh", "Yaounde", "Ottawa", "Praia", "George Town", "Bangui", "N'Djamena", "Santiago", "Beijing", "The Settlement", "West Island", "Bogota", "Moroni", "Kinshasa", "Brazzaville", "Avarua", "San Jose", "Yamoussoukro", "Zagreb", "Havana", "Willemstad", "Nicosia", "Prague", "Copenhagen", "Djibouti", "Roseau", "Santo Domingo", "Quito", "Cairo", "San Salvador", "Malabo", "Asmara", "Tallinn", "Addis Ababa", "Stanley", "Torshavn", "Suva", "Helsinki", "Paris", "Papeete", "Libreville", "Banjul", "Tbilisi", "Berlin", "Accra", "Gibraltar", "Athens", "Nuuk", "Saint George's", "Hagatna", "Guatemala City", "Saint Peter Port", "Conakry", "Bissau", "Georgetown", "Port-au-Prince", "Vatican City", "Tegucigalpa", "Budapest", "Reykjavik", "New Delhi", "Jakarta", "Tehran", "Baghdad", "Dublin", "Douglas", "Jerusalem", "Rome", "Kingston", "Tokyo", "Saint Helier", "Amman", "Astana", "Nairobi", "Tarawa", "Pyongyang", "Seoul", "Pristina", "Kuwait City", "Bishkek", "Vientiane", "Riga", "Beirut", "Maseru", "Monrovia", "Tripoli", "Vaduz", "Vilnius", "Luxembourg", "Skopje", "Antananarivo", "Lilongwe", "Kuala Lumpur", "Male", "Bamako", "Valletta", "Majuro", "Nouakchott", "Port Louis", "Mexico City", "Palikir", "Chisinau", "Monaco", "Ulaanbaatar", "Podgorica", "Plymouth", "Rabat", "Maputo", "Windhoek", "Kathmandu", "Amsterdam", "Noumea", "Wellington", "Managua", "Niamey", "Abuja", "Alofi", "Kingston", "Saipan", "Oslo", "Muscat", "Islamabad", "Melekeok", "Panama City", "Port Moresby", "Asuncion", "Lima", "Manila", "Adamstown", "Warsaw", "Lisbon", "San Juan", "Doha", "Bucharest", "Moscow", "Kigali", "Gustavia", "Jamestown", "Basseterre", "Castries", "Saint-Pierre", "Kingstown", "Apia", "San Marino", "Sao Tome", "Riyadh", "Dakar", "Belgrade", "Victoria", "Freetown", "Singapore", "Philipsburg", "Bratislava", "Ljubljana", "Honiara", "Mogadishu", "Pretoria", "Juba", "Madrid", "Colombo", "Khartoum", "Paramaribo", "Longyearbyen", "Mbabane", "Stockholm", "Bern", "Damascus", "Taipei", "Dushanbe", "Dar es Salaam", "Bangkok", "Dili", "Lome", "Nuku'alofa", "Port of Spain", "Tunis", "Ankara", "Ashgabat", "Grand Turk", "Funafuti", "Kampala", "Kyiv", "Abu Dhabi", "London", "Washington", "Montevideo", "Tashkent", "Port-Vila", "Caracas", "Hanoi", "Charlotte Amalie", "Mata-Utu", "Sanaa", "Lusaka", "Harare", "Washington", "North Nicosia", "Diego Garcia"]
currency: ["Afghani", "Euro", "Lek", "Algerian Dinar", "US Dollar", "Euro", "Kwanza", "East Caribbean Dollar", "No universal currency", "East Caribbean Dollar", "Argentine Peso", "Armenian Dram", "Aruban Florin", "Australian Dollar", "Euro", "Azerbaijan Manat", "Bahamian Dollar", "Bahraini Dinar", "Taka", "Barbados Dollar", "Belarusian Ruble", "Euro", "Belize Dollar", "CFA Franc BCEAO", "Bermudian Dollar", "Indian Rupee", "Ngultrum", "Boliviano", "Mvdol", "US Dollar", "Convertible Mark", "Pula", "Norwegian Krone", "Brazilian Real", "US Dollar", "Brunei Dollar", "Bulgarian Lev", "CFA Franc BCEAO", "Burundi Franc", "Cabo Verde Escudo", "Riel", "CFA Franc BEAC", "Canadian Dollar", "Cayman Islands Dollar", "CFA Franc BEAC", "CFA Franc BEAC", "Chilean Peso", "Unidad de Fomento", "Yuan Renminbi", "Australian Dollar", "Australian Dollar", "Colombian Peso", "Unidad de Valor Real", "Comorian Franc ", "Congolese Franc", "CFA Franc BEAC", "New Zealand Dollar", "Costa Rican Colon", "CFA Franc BCEAO", "Kuna", "Cuban Peso", "Peso Convertible", "Netherlands Antillean Guilder", "Euro", "Czech Koruna", "Danish Krone", "Djibouti Franc", "East Caribbean Dollar", "Dominican Peso", "US Dollar", "Egyptian Pound", "El Salvador Colon", "US Dollar", "CFA Franc BEAC", "Nakfa", "Euro", "Ethiopian Birr", "Euro", "Falkland Islands Pound", "Danish Krone", "Fiji Dollar", "Euro", "Euro", "Euro", "CFP Franc", "Euro", "CFA Franc BEAC", "Dalasi", "Lari", "Euro", "Ghana Cedi", "Gibraltar Pound", "Euro", "Danish Krone", "East Caribbean Dollar", "Euro", "US Dollar", "Quetzal", "Pound Sterling", "Guinean Franc", "CFA Franc BCEAO", "Guyana Dollar", "Gourde", "US Dollar", "Australian Dollar", "Euro", "Lempira", "Hong Kong Dollar", "Forint", "Iceland Krona", "Indian Rupee", "Rupiah", "SDR (Special Drawing Right)", "Iranian Rial", "Iraqi Dinar", "Euro", "Pound Sterling", "New Israeli Sheqel", "Euro", "Jamaican Dollar", "Yen", "Pound Sterling", "Jordanian Dinar", "Tenge", "Kenyan Shilling", "Australian Dollar", "North Korean Won", "Won", "Kuwaiti Dinar", "Som", "Lao Kip", "Euro", "Lebanese Pound", "Loti", "Rand", "Liberian Dollar", "Libyan Dinar", "Swiss Franc", "Euro", "Euro", "Pataca", "Denar", "Malagasy Ariary", "Malawi Kwacha", "Malaysian Ringgit", "Rufiyaa", "CFA Franc BCEAO", "Euro", "US Dollar", "Euro", "Ouguiya", "Mauritius Rupee", "Euro", "ADB Unit of Account", "Mexican Peso", "Mexican Unidad de Inversion (UDI)", "US Dollar", "Moldovan Leu", "Euro", "Tugrik", "Euro", "East Caribbean Dollar", "Moroccan Dirham", "Mozambique Metical", "Kyat", "Namibia Dollar", "Rand", "Australian Dollar", "Nepalese Rupee", "Euro", "CFP Franc", "New Zealand Dollar", "Cordoba Oro", "CFA Franc BCEAO", "Naira", "New Zealand Dollar", "Australian Dollar", "US Dollar", "Norwegian Krone", "Rial Omani", "Pakistan Rupee", "US Dollar", "No universal currency", "Balboa", "US Dollar", "Kina", "Guarani", "Sol", "Philippine Peso", "New Zealand Dollar", "Zloty", "Euro", "US Dollar", "Qatari Rial", "Euro", "Romanian Leu", "Russian Ruble", "Rwanda Franc", "Euro", "Saint Helena Pound", "East Caribbean Dollar", "East Caribbean Dollar", "Euro", "Euro", "East Caribbean Dollar", "Tala", "Euro", "Dobra", "Saudi Riyal", "CFA Franc BCEAO", "Serbian Dinar", "Seychelles Rupee", "Leone", "Singapore Dollar", "Netherlands Antillean Guilder", "Sucre", "Euro", "Euro", "Solomon Islands Dollar", "Somali Shilling", "Rand", "No universal currency", "South Sudanese Pound", "Euro", "Sri Lanka Rupee", "Sudanese Pound", "Surinam Dollar", "Norwegian Krone", "Lilangeni", "Swedish Krona", "Swiss Franc", "WIR Euro", "WIR Franc", "Syrian Pound", "New Taiwan Dollar", "Somoni", "Tanzanian Shilling", "Baht", "US Dollar", "CFA Franc BCEAO", "New Zealand Dollar", "Paanga", "Trinidad and Tobago Dollar", "Tunisian Dinar", "Turkish Lira", "Turkmenistan New Manat", "US Dollar", "Australian Dollar", "Uganda Shilling", "Hryvnia", "UAE Dirham", "Pound Sterling", "US Dollar", "US Dollar", "US Dollar (Next day)", "Peso Uruguayo", "Uruguay Peso en Unidades Indexadas (UI)", "Unidad Previsional", "Uzbekistan Sum", "Vatu", "Bolívar Soberano", "Dong", "US Dollar", "US Dollar", "CFP Franc", "Moroccan Dirham", "Yemeni Rial", "Zambian Kwacha", "Zimbabwe Dollar"]
currency_code: ["AFN", "EUR", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "XCD", "ARS", "AMD", "AWG", "AUD", "EUR", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "EUR", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "USD", "BAM", "BWP", "NOK", "BRL", "USD", "BND", "BGN", "XOF", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "XAF", "XAF", "CLP", "CLF", "CNY", "AUD", "AUD", "COP", "COU", "KMF", "CDF", "XAF", "NZD", "CRC", "XOF", "HRK", "CUP", "CUC", "ANG", "EUR", "CZK", "DKK", "DJF", "XCD", "DOP", "USD", "EGP", "SVC", "USD", "XAF", "ERN", "EUR", "ETB", "EUR", "FKP", "DKK", "FJD", "EUR", "EUR", "EUR", "XPF", "EUR", "XAF", "GMD", "GEL", "EUR", "GHS", "GIP", "EUR", "DKK", "XCD", "EUR", "USD", "GTQ", "GBP", "GNF", "XOF", "GYD", "HTG", "USD", "AUD", "EUR", "HNL", "HKD", "HUF", "ISK", "INR", "IDR", "XDR", "IRR", "IQD", "EUR", "GBP", "ILS", "EUR", "JMD", "JPY", "GBP", "JOD", "KZT", "KES", "AUD", "KPW", "KRW", "KWD", "KGS", "LAK", "EUR", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "EUR", "EUR", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "XOF", "EUR", "USD", "EUR", "MRU", "MUR", "EUR", "XUA", "MXN", "MXV", "USD", "MDL", "EUR", "MNT", "EUR", "XCD", "MAD", "MZN", "MMK", "NAD", "ZAR", "AUD", "NPR", "EUR", "XPF", "NZD", "NIO", "XOF", "NGN", "NZD", "AUD", "USD", "NOK", "OMR", "PKR", "USD", "PAB", "USD", "PGK", "PYG", "PEN", "PHP", "NZD", "PLN", "EUR", "USD", "QAR", "EUR", "RON", "RUB", "RWF", "EUR", "SHP", "XCD", "XCD", "EUR", "EUR", "XCD", "WST", "EUR", "STN", "SAR", "XOF", "RSD", "SCR", "SLL", "SGD", "ANG", "XSU", "EUR", "EUR", "SBD", "SOS", "ZAR", "SSP", "EUR", "LKR", "SDG", "SRD", "NOK", "SZL", "SEK", "CHF", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "USD", "XOF", "NZD", "TOP", "TTD", "TND", "TRY", "TMT", "USD", "AUD", "UGX", "UAH", "AED", "GBP", "USD", "USD", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VND", "USD", "USD", "XPF", "MAD", "YER", "ZMW", "ZWL"]
+63
View File
@@ -10,16 +10,79 @@ en:
user_agent:
aol:
- Mozilla/5.0 (compatible; MSIE 9.0; AOL 9.7; AOLBuild 4343.19; Windows NT 6.1; WOW64; Trident/5.0; FunWebProducts)
- Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
- Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; SV1)
- Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1)
- Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; .NET CLR 1.1.4322)
- Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; SV1; FunWebProducts; .NET CLR 1.1.4322)
- Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.0; Windows NT 5.1; .NET CLR 1.1.4322)
- Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows 98)
- Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; .NET CLR 1.0.3705)
- Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)
chrome:
- Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36
- Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
- Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36
- Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36
- Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36
- Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
- Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
- Mozilla/5.0 (Windows NT 5.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36
- Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36
- Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
firefox:
- Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0
- Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0
- Mozilla/5.0 (Windows NT 5.1; rv:33.0) Gecko/20100101 Firefox/33.0
- Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
- Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0
- Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0
- Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
- Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0
- Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1
- Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0
internet_explorer:
- Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko
- Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
- Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
- Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
- Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
- Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)
- Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
- Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; 125LA; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
- Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)
- Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
netscape:
- Mozilla/5.0 (Windows; U; Win 9x 4.90; SG; rv:1.9.2.4) Gecko/20101104 Netscape/9.1.0285
- Mozilla/4.5 (compatible; HTTrack 3.0x; Windows 98)
- Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)
- Mozilla/5.0 (compatible; Linux x86_64; Mail.RU_Bot/2.0; +http://go.mail.ru/help/robots)
- Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
- Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
- Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101
- Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02
- Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.11) Gecko GranParadiso/3.0.11
- Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201
opera:
- Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16
- Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.18
- Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.991
- Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 OPR/56.0.3051.52
- Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36 OPR/36.0.2130.32
- Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.991
- Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14
- Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36 OPR/42.0.2393.94
- Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3198.0 Safari/537.36 OPR/49.0.2711.0
- Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36 OPR/42.0.2393.94
safari:
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A
- Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1
- Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-en) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4
- Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1
- Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.1 Safari/605.1.15
- Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.0 Mobile/14G60 Safari/602.1
- Mozilla/5.0 (iPhone; CPU iPhone OS 12_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.59.10 (KHTML, like Gecko) Version/5.1.9 Safari/534.59.10
- Mozilla/5.0 (iPad; CPU OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13G36 Safari/601.1
+35 -1
View File
@@ -6,6 +6,40 @@ en:
witchers: ["Geralt of Rivia", "Coën", "Vesemir", "Eskel", "Lambert", "Letho of Gulet","Ciri","George of Kagen","Jerome Moreau","Auckes","Serrit","Kolgrim","Ivar Evil-Eye","Junod of Belhaven","Gerd"]
schools: ["Wolf", "Griffin", "Cat", "Viper", "Manticore", "Bear"]
locations: ["Aedd Gynvael","Aldersberg","Beauclair","Cidaris","Cintra","Gors Velen","Maribor","Novigrad","Oxenfurt","Tretogor","Vengerberg","Vizima","Ard Carraigh","Bremervoord","Brugge","Claremont","Creyden","Fen Aspra","Hengfors","Lan Exeter","Pont Vanis","Lyria","Maecht","Malleore","Metinna","Nilfgaard","Neunreuth","Rakverelin","Rivia","Thurn","Acorn Bay","Anchor","Assengard","Attre","Ban Ard","Ban Gleán","Barefield","Belhaven","Blaviken","Brenna","Breza","Burdorff","Caelf","Carreras","Craag An","Crinfrid","Daevon","Dillingen","Dorian","Druigh","Dudno","Duén Canell","Dun Dâre","Ellander","Eysenlaan","Fano","Foam","Forgeham","Fox Hollow","Ghelibol","Glyswen","Gulet","Hochebuz","Jealousy","Kaczan","Kagen","Kerack","Kernow","Klucz","Knotweed Meadow","Little Marsh","Lower Posada","Malhoun","Mirt","Murivel","New Ironworks","Porog","Riedbrune","Rinde","Roggeveen","Tegamo","Tigg","Tridam","Tyffi","Unicorn","Upper Posada","Vattweir","Vole","White Bridge","Zavada","Armeria","Baldhorn","Ban Gleán","Beauclair","Bodrog","Carcano","Castel Ravello","Darn Dyffra","Darn Rowan","Darn Ruach","Dillingen","Dorndal","Drakenborg","Fen Aspra","Glevitzingen","Gwendeith","Hagge","Houtborg","Kaer Morhen","Kaer Trolde","Leyda","Loc Grim","Mayena","Mirt","Montecalvo","Montsalvat","Nastrog","Razwan","Red Binduga","Rocayne","Rhys-Rhun","Riedbrune","Rozrog","Sarda","Scala","Schwemmland","Spalla","Stygga","Tigg","Vartburg","Vedette","Vidort","Winneburg","Zurbarran","Est Haemlet","Loc Muinne","Shaerrawedd"]
quotes: ["Just five more minutes… Is it 1358 yet? No? Then fuck off!","Finish all your business before you die. Bid loved ones farewell. Write your will. Apologize to those youve wronged. Otherwise, youll never truly leave this world.","Hide the wenches, Witcher's coming!!","Oh year... the Elder Blood can be fiery","Damn, Eskel... you got an hourglass figure","No Lollygagin'!","You get what you get and be happy with it","I'll stick me boot so far up yer arse your tongue'll taste like wench twat"]
quotes: [
"Just five more minutes… Is it 1358 yet? No? Then fuck off!",
"Finish all your business before you die. Bid loved ones farewell. Write your will. Apologize to those youve wronged. Otherwise, youll never truly leave this world.",
"Hide the wenches, Witcher's coming!!","Oh year... the Elder Blood can be fiery",
"Damn, Eskel... you got an hourglass figure","No Lollygagin'!",
"You get what you get and be happy with it","I'll stick me boot so far up yer arse your tongue'll taste like wench twat",
"Evil is evil, Stregobor. Lesser, greater, middling, it's all the same. Proportions are negotiated, boundaries blurred. I'm not a pious hermit, I haven't done only good in my life. But if I'm to choose between one evil and another, then I prefer not to choose at all.",
"One hand washes the other. Freedom and contempt have their limits. In the end, it is always the case that one is someone else's tool.",
"You cannot do it. You cannot do it, witcheress. In Kaer Morhen, they taught you to kill, so you kill like a machine. Instinctively. To kill yourself takes character, strength, determination and courage. But that, that they could not teach you.",
"Death, the final judgement. The Beast has met its end once. It doesn't fear death, it is death. How will you defeat human villainy? With your sword? You who died and still walk amongst the living?",
"Well, theres a war, so theres orphans. Didnt [you] know that?",
"Know when a legend becomes a prophecy? When it gains believers.",
"You dont need mutations to strip men of their humanity. Ive seen plenty of examples.",
"To be neutral does not mean to be indifferent or insensitive. You don't have to kill your feelings. It's enough to kill hatred within yourself.",
"There is never a second opportunity to make a first impression.",
"People”—Geralt turned his head—“like to invent monsters and monstrosities. Then they seem less monstrous themselves.",
"A mother, you son-of-a-bitch, is sacred!",
"Only Evil and Greater Evil exist and beyond them, in the shadows, lurks True Evil. True Evil, Geralt, is something you can barely imagine, even if you believe nothing can still surprise you. And sometimes True Evil seizes you by the throat and demands that you choose between it and another, slightly lesser, Evil.",
"Only death can finish the fight, everything else only interrupts the fighting.",
"Mistakes, he said with effort, are also important to me. I dont cross them out of my life, or memory. And I never blame others for them.",
"What is truth? The negation of lies? Or the statement of a fact? And if the fact is a lie, what then is the truth?",
"They weren't lying. They firmly believed it all. Which doesn't change the facts.",
"There's a grain of truth in every fairy tale.",
"I need this conversation. They say silence is golden. Maybe it is, although I'm not sure it's worth that much. It has its price certainly; you have to pay for it.",
"Youve mistaken the stars reflected on the surface of the lake at night for the heavens.",
"It is easy to kill with a bow, girl. How easy it is to release the bowstring and think, it is not I, it is the arrow. The blood of that boy is not on my hands. The arrow killed him, not I. But the arrow does not dream anything in the night.",
"The sword of destiny has two edges. You are one of them.",
"When you know about something it stops being a nightmare. When you know how to fight something, it stops being so threatening.",
"As usual, cats and children noticed him first.",
"Thats the role of poetry, Ciri. To say what others cannot utter.",
"No one wants to suffer. But that is the fate of each. And some suffer more. Not necessarily of their own volition. It's not about to enduring the suffering. It's about how you endure it.",
"Destiny has many faces. Mine is beautiful on the outside and hideous on the inside. She has stretched her bloody talons toward me—",
"A coward,' he declared with dignity, when he'd stopped coughing and had got his breath back, 'dies a hundred times. A brave man dies but once. But Dame Fortune favours the brave and holds the coward in contempt.'",
"I thought I was choosing the lesser evil. I chose the lesser evil. Lesser evil! Im Geralt! Witcher…Im the Butcher of Blaviken—"
]
monsters: ["Archespore","Berserker","Botchling","Lubberkin","Ulfhedinn","Werewolf","The Toad Prince","Basilisk","Cockatrice","Forktail","Royal Wyvern","Shrieker","Silver Basilisk","Slyzard Matriarch","Slyzard","Dragon of Fyresdal","Wyvern","Djinn","Earth Elemental","Fire Elemental","Gargoyle","Golem","Hound of the Wild Hunt","Ice Elemental","Pixie","Apiarian Phantom","Therazane","Ekhidnae","Erynias","Griffin","Harpy","Melusine","Opinicus","Salma","Siren","Succubus","Arachas","Arachnomorph","Endrega Drone","Endrega Warrior","Endrega Worker","Giant Centipede","Kikimore","Kikimore Worker","Pale Widow","Abaya","Alghoul","Drowner","Foglet","Ghoul","Grave Hag","Ignis Fatuus","Mourntart","Mucknixer","Rotfiend","Scurver","Spotted Wight","Water Hag","Wight","Cloud Giant","Cyclopse","Golyat","Hagubman","Ice Giant","Ice Troll","Nekker","Rock Troll","Wham-a-Wham","Chort","Crone","Doppler","Fiend","Fugas","Godling","Grottore","Howler","Imp","Kernun","Leshen","Morvudd","Shaelmaar","Spriggan","Sylvan","The Caretaker","Barghests","Ethereal","Hym","Longlocks","Nightwraith","Noonwraith","Penitent","Plague Maiden","Umbra","Wraith","Alp","Bruxa","Ekimmara","Gael","Garkain","Higher Vampire","Katakan"]
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -74,7 +74,7 @@ ru:
- "#{prefix} #{Address.city_name}#{suffix}#{suffix}#{suffix}"
weather:
description: ["Ясно","Солнечно","Хмарно з проясненнями","Мінлива хмарність","Переважно хмарно","Пасмурно","Злива","Дощ","Мряка","Грози","Сніг","Мокрий сніг","Град"]
description: ["Ясно","Солнечно","Облачно с прояснениями","Переменная облачность","Облачно","Пасмурно","Ливень","Дождь","Туман","Грозы","Снег","Мокрый снег","Град"]
temperature:
celsius: °C
fahrenheit: °F
@@ -106,4 +106,10 @@ public class AddressTest extends AbstractFakerTest {
faker = new Faker(new Locale("en-US"));
assertThat(faker.address().zipCodeByState(faker.address().stateAbbr()), matchesRegularExpression("[0-9]{5}"));
}
@Test
public void testCountyByZipCode() {
faker = new Faker(new Locale("en-US"));
assertThat(faker.address().countyByZipCode(faker.address().zipCodeByState(faker.address().stateAbbr())), not(isEmptyOrNullString()));
}
}
@@ -11,4 +11,14 @@ public class ColorTest extends AbstractFakerTest {
public void testName() {
assertThat(faker.color().name(), matchesRegularExpression("(\\w+ ?){1,2}"));
}
@Test
public void testHex() {
assertThat(faker.color().hex(), matchesRegularExpression("^#[0-9A-F]{6}$"));
}
@Test
public void testHexNoHashSign() {
assertThat(faker.color().hex(false), matchesRegularExpression("^[0-9A-F]{6}$"));
}
}
@@ -11,6 +11,10 @@ public class CommerceTest extends AbstractFakerTest {
private static final char decimalSeparator = new DecimalFormatSymbols().getDecimalSeparator();
private static final String CAPITALIZED_WORD_REGEX = "[A-Z][a-z]+";
private static final String PROMOTION_CODE_REGEX = CAPITALIZED_WORD_REGEX + "(-" + CAPITALIZED_WORD_REGEX + ")*";
@Test
public void testColor() {
assertThat(faker.commerce().color(), matchesRegularExpression("(\\w+ ?){1,2}"));
@@ -43,11 +47,11 @@ public class CommerceTest extends AbstractFakerTest {
@Test
public void testPromotionCode() {
assertThat(faker.commerce().promotionCode(), matchesRegularExpression("[A-Z][a-z]+[A-Z][a-z]+\\d{6}"));
assertThat(faker.commerce().promotionCode(), matchesRegularExpression(PROMOTION_CODE_REGEX + PROMOTION_CODE_REGEX + "\\d{6}"));
}
@Test
public void testPromotionCodeDigits() {
assertThat(faker.commerce().promotionCode(3), matchesRegularExpression("[A-Z][a-z]+[A-Z][a-z]+\\d{3}"));
assertThat(faker.commerce().promotionCode(3), matchesRegularExpression(PROMOTION_CODE_REGEX + PROMOTION_CODE_REGEX + "\\d{3}"));
}
}
@@ -0,0 +1,43 @@
package com.github.javafaker;
import com.github.javafaker.repeating.Repeat;
import org.junit.Test;
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import static org.junit.Assert.assertThat;
public class CountryTest extends AbstractFakerTest {
@Test
@Repeat(times=10)
public void testFlag() {
String flag = faker.country().flag();
assertThat(flag, matchesRegularExpression("^http:\\/\\/flags.fmcdn\\.net\\/data\\/flags\\/w580\\/[a-zA-Z0-9_]+\\.png$"));
}
@Test
public void testCode2() {
assertThat(faker.country().countryCode2(), matchesRegularExpression("([a-z]{2})"));
}
@Test
public void testCode3() {
assertThat(faker.country().countryCode3(), matchesRegularExpression("([a-z]{3})"));
}
@Test
public void testCapital() {
assertThat(faker.country().capital(), matchesRegularExpression("([\\w'-]+ ?)+"));
}
@Test
public void testCurrency() {
assertThat(faker.country().currency(), matchesRegularExpression("([\\w-]+ ?)+"));
}
@Test
public void testCurrencyCode() {
assertThat(faker.country().currencyCode(), matchesRegularExpression("([\\w-]+ ?)+"));
}
}
@@ -11,7 +11,7 @@ public class FriendsTest extends AbstractFakerTest {
@Test
public void character() {
assertThat(faker.friends().character(), matchesRegularExpression("[A-Za-z ]+"));
assertThat(faker.friends().character(), matchesRegularExpression("[A-Za-z .,]+"));
}
@Test
@@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.apache.commons.validator.routines.EmailValidator;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsNot;
import org.junit.Test;
import java.util.List;
@@ -123,6 +124,12 @@ public class InternetTest extends AbstractFakerTest {
assertThat(faker.internet().password(), matchesRegularExpression("[a-z\\d]{8,16}"));
}
@Test
public void testPasswordIncludeDigit() {
assertThat(faker.internet().password(), matchesRegularExpression("[a-z\\d]{8,16}"));
assertThat(faker.internet().password(false), matchesRegularExpression("[a-z]{8,16}"));
}
@Test
public void testPasswordMinLengthMaxLength() {
assertThat(faker.internet().password(10, 25), matchesRegularExpression("[a-z\\d]{10,25}"));
@@ -141,6 +148,14 @@ public class InternetTest extends AbstractFakerTest {
assertThat(faker.internet().password(10, 25, true, true), matchesRegularExpression("[a-zA-Z\\d!@#$%^&*]{10,25}"));
}
@Test
public void testPasswordMinLengthMaxLengthIncludeUpperCaseIncludeSpecialIncludeDigit() {
assertThat(faker.internet().password(10, 25, false, false, false), matchesRegularExpression("[a-z]{10,25}"));
assertThat(faker.internet().password(10, 25, false, true, true), matchesRegularExpression("[a-z\\d!@#$%^&*]{10,25}"));
assertThat(faker.internet().password(10, 25, true, true, false), matchesRegularExpression("[a-zA-Z!@#$%^&*]{10,25}"));
assertThat(faker.internet().password(10, 25, true, true, true), matchesRegularExpression("[a-zA-Z\\d!@#$%^&*]{10,25}"));
}
@Test
public void testMacAddress() {
assertThat(faker.internet().macAddress(), countOf(':', is(5)));
@@ -276,4 +291,15 @@ public class InternetTest extends AbstractFakerTest {
assertThat(f.internet().safeEmailAddress(), not(isEmptyOrNullString()));
assertThat(f.internet().url(), not(isEmptyOrNullString()));
}
@Test
public void testUserAgent() {
Internet.UserAgent[] agents = Internet.UserAgent.values();
for(Internet.UserAgent agent : agents) {
assertThat(faker.internet().userAgent(agent), not(isEmptyOrNullString()));
}
//Test faker.internet().userAgentAny() for random user_agent retrieval.
assertThat(faker.internet().userAgentAny(), not(isEmptyOrNullString()));
}
}
@@ -74,6 +74,12 @@ public class LoremTest extends AbstractFakerTest {
assertThat(faker.lorem().characters(1, 10), matchesRegularExpression("[a-zA-Z\\d]{1,10}"));
}
@Test
public void testCharactersMinimumMaximumLengthIncludeUppercaseIncludeDigit() {
assertThat(faker.lorem().characters(1, 10, false, false), matchesRegularExpression("[a-zA-Z]{1,10}"));
assertThat(faker.lorem().characters(1, 10, true, true), matchesRegularExpression("[a-zA-Z\\d]{1,10}"));
}
@Test
public void testSentence() {
assertThat(faker.lorem().sentence(), matchesRegularExpression("(\\w+\\s?){4,10}\\."));
@@ -24,6 +24,6 @@ public class TeamTest extends AbstractFakerTest {
@Test
public void testSport() {
assertThat(faker.team().sport(), matchesRegularExpression("(\\w|\\s)+"));
assertThat(faker.team().sport(), matchesRegularExpression("(\\p{L}|\\s)+"));
}
}
@@ -29,7 +29,7 @@ public class WitcherTest extends AbstractFakerTest {
@Test
public void testQuote() {
assertThat(faker.witcher().quote(), matchesRegularExpression("[A-Za-z0-9 …\\?\\!\\.',]+"));
assertThat(faker.witcher().quote(), matchesRegularExpression("[-A-Za-z0-9 —;\\?\\!\\.'”“,\\[\\]]+"));
}
@Test
@@ -100,6 +100,7 @@ public class FakerIT {
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.color());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.commerce());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.company());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.country());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.crypto());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.demographic());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.dragonBall());
@@ -0,0 +1,41 @@
package com.github.javafaker.service;
import org.junit.Before;
import org.junit.Test;
import java.util.Locale;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
public class FakeValuesGroupingTest {
private FakeValuesGrouping fakeValuesGrouping;
private FakeValues addressValues;
@Before
public void before() {
fakeValuesGrouping = new FakeValuesGrouping();
addressValues = new FakeValues(Locale.ENGLISH, "address.yml", "address");
fakeValuesGrouping.add(addressValues);
}
@Test
public void handlesOneFakeValue() {
assertThat(fakeValuesGrouping.get("address"), is(addressValues.get("address")));
assertThat(fakeValuesGrouping.get("address"), is(notNullValue()));
}
@Test
public void handlesMultipleFakeValues() {
FakeValues catValues = new FakeValues(Locale.ENGLISH, "cat.yml", "creature");
fakeValuesGrouping.add(catValues);
assertThat(fakeValuesGrouping.get("address"), is(addressValues.get("address")));
assertThat(fakeValuesGrouping.get("address"), is(notNullValue()));
assertThat(fakeValuesGrouping.get("creature"), is(catValues.get("creature")));
assertThat(fakeValuesGrouping.get("creature"), is(notNullValue()));
}
}
@@ -10,7 +10,10 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Locale;
@@ -22,6 +25,9 @@ import static org.mockito.Mockito.*;
public class FakeValuesServiceTest extends AbstractFakerTest {
private static final Long MILLIS_IN_AN_HOUR = 1000 * 60 * 60L;
private static final Long MILLIS_IN_A_DAY = MILLIS_IN_AN_HOUR * 24;
@Mock
private RandomService randomService;
@@ -34,13 +40,8 @@ public class FakeValuesServiceTest extends AbstractFakerTest {
// always return the first element
when(randomService.nextInt(anyInt())).thenReturn(0);
fakeValuesService = spy(new FakeValuesService(new Locale("test"), randomService));
}
@Test(expected = LocaleDoesNotExistException.class)
public void localeShouldThrowException() {
new FakeValuesService(new Locale("Does not exist"), randomService);
fakeValuesService = spy(new FakeValuesService(new Locale("test"), randomService));
}
@Test
@@ -73,11 +74,11 @@ public class FakeValuesServiceTest extends AbstractFakerTest {
public void safeFetchShouldReturnEmptyStringWhenPropertyDoesntExist() {
assertThat(fakeValuesService.safeFetch("property.dummy2", ""), isEmptyString());
}
@Test
public void bothify2Args() {
final DummyService dummy = mock(DummyService.class);
Faker f = new Faker();
String value = fakeValuesService.resolve("property.bothify_2", dummy, f);
@@ -190,30 +191,30 @@ public class FakeValuesServiceTest extends AbstractFakerTest {
assertThat(chain, contains(Locale.SIMPLIFIED_CHINESE, Locale.CHINESE, Locale.ENGLISH));
}
@Test
public void testLocaleChainEnglish() {
final List<Locale> chain = fakeValuesService.localeChain(Locale.ENGLISH);
assertThat(chain, contains(Locale.ENGLISH));
}
@Test
public void testLocaleChainLanguageOnly() {
final List<Locale> chain = fakeValuesService.localeChain(Locale.CHINESE);
assertThat(chain, contains(Locale.CHINESE, Locale.ENGLISH));
}
@Test
public void expressionWithInvalidFakerObject() {
expressionShouldFailWith("#{ObjectNotOnFaker.methodName}",
expressionShouldFailWith("#{ObjectNotOnFaker.methodName}",
"Unable to resolve #{ObjectNotOnFaker.methodName} directive.");
}
@Test
public void expressionWithValidFakerObjectButInvalidMethod() {
expressionShouldFailWith("#{Name.nonExistentMethod}",
expressionShouldFailWith("#{Name.nonExistentMethod}",
"Unable to resolve #{Name.nonExistentMethod} directive.");
}
@@ -227,15 +228,41 @@ public class FakeValuesServiceTest extends AbstractFakerTest {
*/
@Test
public void expressionWithValidFakerObjectValidMethodInvalidArgs() {
expressionShouldFailWith("#{Number.number_between 'x','y'}",
expressionShouldFailWith("#{Number.number_between 'x','y'}",
"Unable to resolve #{Number.number_between 'x','y'} directive.");
}
@Test
public void futureDateExpression() throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE MMM dd HH:mm:ss z yyyy" );
Date now = new Date();
Date nowPlus10Days = new Date( now.getTime() + MILLIS_IN_A_DAY * 10 );
Date date = dateFormat.parse( fakeValuesService.expression( "#{date.future '10','TimeUnit.DAYS'}", faker ));
assertThat( date.getTime(), greaterThan( now.getTime() ));
assertThat( date.getTime(), lessThan( nowPlus10Days.getTime() ));
}
@Test
public void pastDateExpression() throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE MMM dd HH:mm:ss z yyyy" );
Date now = new Date();
Date nowMinus5Hours = new Date( now.getTime() - MILLIS_IN_AN_HOUR * 5 );
Date date = dateFormat.parse( fakeValuesService.expression( "#{date.past '5','TimeUnit.HOURS'}", faker ));
assertThat( date.getTime(), greaterThan( nowMinus5Hours.getTime() ));
assertThat( date.getTime(), lessThan( now.getTime() ));
}
/**
* Two things are important here:
* 1) the message in the exception should be USEFUL
* 2) a {@link RuntimeException} should be thrown.
*
*
* if the message changes, it's ok to update the test provided
* the two conditions above are still true.
*/
@@ -243,7 +270,7 @@ public class FakeValuesServiceTest extends AbstractFakerTest {
public void expressionCompletelyUnresolvable() {
expressionShouldFailWith("#{x}", "Unable to resolve #{x} directive.");
}
private void expressionShouldFailWith(String expression, String errorMessage) {
try {
fakeValuesService.expression(expression, faker);
@@ -276,21 +303,9 @@ public class FakeValuesServiceTest extends AbstractFakerTest {
public String lastName() {
return "Smith";
}
public String hello() {
return "Hello";
}
}
@Test
public void resolveWithLocaleSimpleValuesInAnotherFile() {
assertThat(fakeValuesService.safeFetch("other1.simple", null), is("hello"));
assertThat(fakeValuesService.safeFetch("other2.simple", null), is("goodbye"));
}
@Test
public void resolveWithLocaleSimpleArrayValuesInAnotherFile() {
assertThat(fakeValuesService.fetchObject("other1.dummy"), Is.<Object>is(Arrays.asList("x", "y", "z")));
assertThat(fakeValuesService.fetchObject("other2.dummy"), Is.<Object>is(Arrays.asList(1, 2, 3)));
}
}
@@ -0,0 +1,60 @@
package com.github.javafaker.service;
import org.junit.Before;
import org.junit.Test;
import java.util.Locale;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
public class FakeValuesTest {
private static final String PATH = "address";
private FakeValues fakeValues;
@Before
public void before() {
fakeValues = new FakeValues(Locale.ENGLISH, "address.yml", PATH);
}
@Test
public void supportsPathIsTrueWithTheSameValueAsThePath() {
assertThat(fakeValues.supportsPath(PATH), is(true));
}
@Test
public void supportsPathIsFalseWhenValueIsNotTheSame() {
assertThat(fakeValues.supportsPath("dog"), is(false));
}
@Test
public void getAValueReturnsAValue() {
assertThat(fakeValues.get(PATH), is(notNullValue()));
}
@Test
public void getAValueDoesNotReturnAValue() {
assertThat(fakeValues.get("dog"), is(nullValue()));
}
@Test
public void getAValueWithANonEnglishFile() {
FakeValues frenchFakeValues = new FakeValues(Locale.FRENCH);
assertThat(frenchFakeValues.get(PATH), is(notNullValue()));
}
@Test
public void getAValueForHebrewLocale() {
FakeValues hebrew = new FakeValues(new Locale("iw"));
assertThat(hebrew.get(PATH), is(notNullValue()));
}
@Test
public void getAValueFromALocaleThatCantBeLoaded() {
FakeValues fakeValues = new FakeValues(new Locale("nothing"));
assertThat(fakeValues.get(PATH), is(nullValue()));
}
}
@@ -9,6 +9,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Random;
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.core.CombinableMatcher.both;
@@ -62,4 +63,9 @@ public class RandomServiceTest extends AbstractFakerTest {
assertThat(randomService.nextInt(-5, 5), both(lessThanOrEqualTo(5)).and(greaterThanOrEqualTo(-5)));
}
}
@Test
public void testHex() {
assertThat(randomService.hex(8), matchesRegularExpression("^[0-9A-F]{8}$"));
}
}
-5
View File
@@ -1,5 +0,0 @@
test:
faker:
other1:
dummy: [x, y, z]
simple: "hello"
-5
View File
@@ -1,5 +0,0 @@
test:
faker:
other2:
dummy: [1, 2, 3]
simple: "goodbye"