* 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
* 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.
FixesDiUS/java-faker#168
* Quiet down the logs for tests, there is too much logging
* 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.
* Add es-MX and en-ZA yml files.
FixesDiUS/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
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.
FixesDiUS/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).
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.
resolvesDiUS/java-faker#121fixesDiUS/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.
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.
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