187 Commits

Author SHA1 Message Date
Ricky
694ea43e2b closes #214 around boundary conditions of numberBetween 2017-04-21 13:36:05 +10:00
André Miranda
bff9eee757 Add birthday generator (#209) 2017-03-27 10:26:12 +11:00
Pascal Schumacher
69fad8f8da add Artist (#205) 2017-03-13 08:33:40 +11:00
Pascal Schumacher
8caa5a5841 add Music#chord (#204) 2017-03-13 08:32:46 +11:00
Pascal Schumacher
061d3a5ba0 add Space#meteorite (#203) 2017-03-13 08:32:29 +11:00
Pascal Schumacher
2f0e6d0e75 update test dependency versions (#202)
remove usage of javax.annotation.Nullable in tests, as this transitive test dependency does not exit anymore
2017-03-13 08:31:50 +11:00
Pascal Schumacher
f6a2339131 use updated yml files from (ruby) faker (#201)
* use updated yml files from (ruby) faker

* add demographic
2017-03-13 08:31:10 +11:00
Pascal Schumacher
9500fc2395 FakeValuesServiceTest: simplify some assertions (#197) 2017-03-01 16:49:07 +11:00
Pascal Schumacher
e6333c20b6 minimal improvement of FakerIt#testAllMethodsThatReturnStringsActuallyReturnStrings (#196) 2017-02-20 10:24:58 +11:00
Trever Shick
0acfd1e823 Fixes #194 handle slash format regex in yml (#195)
* Fixes #194 handle slash format regex in yml

Handle slash format (ex. /[a-b]+/) regular expressions in .yml files.
This is handled internally in the safeFetch method by converting the statement from the /x/ format to
the #{regexify 'x'} directive format.

* Addresses #194 further.  Adds slash checks to FakerIT
2017-02-20 09:27:37 +11:00
Pascal Schumacher
779c9aae06 AncientTest#hero: fix regular expression (#193) 2017-02-06 11:18:35 +11:00
Pascal Schumacher
33e09fcf0f add Lorem#sentence(int wordCount, int randomWordsToAdd) (fixes #190) (#192) 2017-02-03 08:13:49 +11:00
Pascal Schumacher
1ad1adc4ab add Address#fullAddress (#189) 2017-01-24 09:53:30 +11:00
Pascal Schumacher
bb4efb6bd3 add GameOfThrones#quote (#191) 2017-01-24 09:53:15 +11:00
Andrii
46926e9d5b improve readability of code: (#186)
- replace obvious fori with for each statements
 - add uppercase L to long literals
2016-12-23 08:41:13 +11:00
Ricky
bba74389a9 switched the en, en-US yml files back to their original state whilst maintaining compatibility for the new SvSEIdNumbers 2016-12-19 14:20:42 +11:00
Ricky
6c244c4cec Merge branch 'swedish-id-number' of git://github.com/tsundberg/java-faker into tsundberg-swedish-id-number 2016-12-19 10:17:53 +11:00
Pascal Schumacher
3eb2ad300b add GameOfThrones#dragon (#185) 2016-12-18 11:05:29 +11:00
Pascal Schumacher
b0897a05ca add Ancient (#184) 2016-12-18 10:57:17 +11:00
Pascal Schumacher
118cedbb7b use new and updated YML files from (ruby) faker (#183) 2016-12-18 08:34:39 +11:00
Thomas Sundberg
c7cd8bafcf Added runtime resolution for the id number generator 2016-12-15 20:55:25 +01:00
Thomas Sundberg
b9b1411007 Implemented a faker for Swedish id number 2016-12-12 22:18:37 +01:00
Pascal Schumacher
07cdbbec2b use ISBNValidator in isbn(10|13)DefaultIsNoSeparator tests (#179)
let ISBNValidator test ISBN-10 codes directly (do not convert to ISBN-13 codes before validation)
2016-12-02 11:45:19 +11:00
Pascal Schumacher
b71203d57c add Stock to integration test and readme (#180) 2016-12-02 11:43:36 +11:00
noelo
e4b0e6d9b5 Added NYSE & Nasdaq stock symbols (#174)
* Added NYSE & Nasdaq stock symbols

* updated unit test to use matcher and removed unused imports
2016-12-01 10:36:04 +11:00
Trever Shick
a837e1cb02 Always return valid ISBN Numbers (#172)
* Allow digits to be in expression names like isbn_gs1

* Always return valid ISBN numbers

Implement valid ISBN numbers.  The implementation will always return valid ISBN numbers for english speaking books.  There is support
for other countries via overrides in the yml files but the values are not currently set.  Default values are constructed in the
Java so that the functionality doesn't break if we bring over the yml files from the stympy/faker project.

A test is included however to show that the values can be customized via yml if we choose to do so.

Fixes DiUS/java-faker#168

* Quiet down the logs for tests, there is too much logging
2016-11-30 15:23:08 +11:00
Pascal Schumacher
6f99bef9a9 fix App#author (#171) 2016-11-23 17:01:02 +11:00
Pascal Schumacher
29d3f0dd17 add SlackEmoji (#170) 2016-11-23 17:00:38 +11:00
Pascal Schumacher
cf7dc5e120 add Code#asin and Code#imei (#167)
* add Code#asin and Code#imei

* add Code#ean8, Code#gtin8, Code#ean13 and Code#gtin13
2016-11-23 17:00:09 +11:00
Pascal Schumacher
69ad288f3a add Pokemon (#166) 2016-11-23 16:59:10 +11:00
Pascal Schumacher
5ee72af8aa add Space (#165) 2016-11-18 08:31:54 +11:00
Pascal Schumacher
6315478306 fix some compiler warnings (#164) 2016-11-18 08:31:17 +11:00
Pascal Schumacher
bd6a9c7c08 add Music (#163) 2016-11-17 09:32:16 +11:00
Pascal Schumacher
b6b49becf1 add Commerce#promotionCode (#162) 2016-11-17 09:23:30 +11:00
Pascal Schumacher
e931bd1e60 add GameOfThrones (#161) 2016-11-17 09:23:13 +11:00
Pascal Schumacher
23e2408dac add faker#file to README.md (#160)
* add faker#file to README.md

* add dependency-reduced-pom.xml produced by maven shade-plugin to .gitignore

* add file to integration tests
2016-11-17 09:22:56 +11:00
Trever Shick
75751192a1 Add File to Faker from stympy/faker (#155)
* Add File to Faker from stympy/faker

Added File to faker (ported from stympy/faker)
Also, added a test repeater borrowed from https://gist.github.com/fappel/8bcb2aea4b39ff9cfb6e
Updated Internet with slug() (implementation ported from stympy/faker)

* Fix an issue with expression resolution order.

The expression resolution was checking the yml file BEFORE the current object.
That's a problem because of something like 'building_number'.  building_number is
implemented in address by calling numerify(resolve('building_number')) but
the resolution order had yml first instead of the object, so calling address.streetAddress() was returning
 ### my street name instead of a random number like '104 my street name'

This commit fixes this issue

* Add explicit test for street_address

Ensure ### is getting resolved as a number instead of being returned
as ###

* Hopefully fix the Farsi issue for good.
2016-11-11 09:55:29 +11:00
Trever Shick
dba083f66b Add es-MX and en-ZA yml files. (#154)
* Add es-MX and en-ZA yml files.

Fixes DiUS/java-faker#153

The problem was with a fix in de89bf74 .  The fix used a simple toLowerCase
on the directive which didn't adequetly transform it.  This manifested itself
in an unresolved directive value in the en-ZA an es-MX file.  The es-MX file
contained #{PhoneNumber.lada_tres} as a directive and did contain phone_number > lada_tres
but when the FakeValueService attempted to transform the directive it transformed it to
phonenumber.lada_tres erroneously.  The fix in this commit properly converts
PhoneNumber.lada_tres > phone_number.lada_tres which then properly resolves as a simple
reference within the yml file.

* Add locale specific tests for phone es-MX and en-ZA
2016-11-01 11:14:45 +11:00
Trever Shick
38aeff6119 Fix FoodTest#spice, the regex was overly strict 2016-10-31 00:13:30 +01:00
Trever Shick
de89bf740b Resolve object style references as simple references
Addresses DiUS/java-faker#148

If the yml contains an object style reference like Address.street_title which doesn't
resolve to a method name on Address, then try 'address.street_title' as a last ditch effort
which is probably how it should be encoded in the yml anyhow.
2016-10-31 00:13:30 +01:00
Trever Shick
f7f499681d Fix an issue with it.yml suffix, also with method exceptions 2016-10-31 00:13:30 +01:00
Pascal Schumacher
f89510c4d6 FakerIT: excluded ukrainian address methods without data from testing 2016-10-31 00:11:30 +01:00
Pascal Schumacher
af6cf12784 extend integration tests to cover all locales with a yml file 2016-10-31 00:11:30 +01:00
Trever Shick
078d44e232 Fix method resolution with overloaded methods (#147)
Fixes DiUS/java-faker#143

There was an intermittent test failure where the error message would say :
Expected: is "Unable to coerce x to Long via Long(String) constructor."
but: was "Unable to coerce x to Integer via Integer(String) constructor."

The issue is getMethod() returning the methods in a non-deterministic order.
Fixing this could have been easy by simply changing the check to look for Long or Integer but
this would hide a real issue where by methodName(int) called via methodName(Long.MAX_VALUE) would
die even if methodName(long) existed because it would attempt to coerce the arguments
to int ONLY and ignore the long variation.

I altered the logic to attempt to coerce the arguments at the same time the method is located
by name.  This means that methodName(Long.MAX_VALUE) will skip over methodName(int) because it would
fail and will continue to find methodName(int).
2016-10-23 13:40:49 +11:00
Pascal Schumacher
b2f756cb9d add food (similar to f3e08e67e8) (#146) 2016-10-23 10:16:05 +11:00
Pascal Schumacher
2e6c7f7a10 update Mockito version to 2.2.6 (#144)
Remove PowerMock dependency as it does not work with Mockito 2. Remove CryptoTest#missingAlgorithVomitsHorribly which was the only test using PowerMock did not really test anything anyway.
2016-10-23 06:24:00 +11:00
Trever Shick
e1151d6cca Fix Number randomization quality and correctness (#136)
resolves DiUS/java-faker#121
fixes DiUS/java-faker#120

Number#numberBetween and Number#randomDouble exhibited poor behavior when using extremes for
their min/max values.  In the worst case, it would return the same number over and over and in
other cases (maybe this is the worst) it would die.  As a library used to generating fake data,
the library should do its best to not throw errors around min/max ranges, etc., instead
returning usable fake values that best fit the parameters passed in.

This PR fixes the issues with random number generation and a good number of tests were added
to ensure the quality of the randomization by ensuring that 90% of random series are 80% unique.
This should be sufficient for most uses.

Also, the Number class itself was refactored to reuse decimalBetween as the primary number generator
to ensure this randomization quality across all the random* number methods.
2016-10-18 09:48:36 +11:00
Trever Shick
d21f85249e Speed up the Internet implementation (#140)
I originally crated the Internet implementation directly from the stimpy/faker project
but it's too slow.  It looped over regexes until it found one.  In a quick test i found it
sometimes looping > 100 times to find a private IP address.

I replaced the implementation with a very fast very direct implementation since we know
exactly why octets are used to create a private address.

The tests run now in 60+ms instead of 2000+ms.
2016-10-17 09:31:57 +11:00
Trever Shick
dee2a88a3f Ensure error messages are useful (#141)
* Add corner case test for CryptoTest

* Add RandomService tests using default constructor

* Improve FakeValueService error messaging and add tests
2016-10-17 09:30:08 +11:00
Trever Shick
2614053b9a Fix safeEmailAddress to use internet.safe_email (#139)
safeEmailAddress was simply delegating to emailAddress which was not using
internet.safe_email as I assume it was intended.

it now uses internet.safe_email
2016-10-17 09:19:27 +11:00