blocoio / faker Goto Github PK
View Code? Open in Web Editor NEWA Kotlin and Android-ready port of the Faker ruby gem
License: MIT License
A Kotlin and Android-ready port of the Faker ruby gem
License: MIT License
Using 2.0.2 version in Unit test
val addressProvider = Faker("ru").address
val address = Address(
territory = addressProvider.city(),
populatedArea = addressProvider.state(),
street = addressProvider.streetAddress(),
building = addressProvider.buildingNumber(),
block = (1..10).random(),
flatNumber = (1..100).random()
)
Unsupported method 'city_name' for component 'address'
java.lang.IllegalArgumentException: Unsupported method 'city_name' for component 'address'
at io.bloco.faker.FakerComponent.callMethod(FakerComponent.kt:80)
at io.bloco.faker.FakerComponent.call(FakerComponent.kt:39)
at io.bloco.faker.FakerComponent$parse$1.invoke(FakerComponent.kt:32)
at io.bloco.faker.FakerComponent$parse$1.invoke(FakerComponent.kt:30)
at kotlin.text.Regex.replace(Regex.kt:193)
at io.bloco.faker.FakerComponent.parse(FakerComponent.kt:30)
at io.bloco.faker.components.Address.city(Address.kt:52)
at FakeAssetsManagerTest.generateCall(FakeAssetsManagerTest.kt:69)
at FakeAssetsManagerTest.generateTherapistCalls(FakeAssetsManagerTest.kt:56)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:108)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:40)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:60)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: java.lang.NoSuchMethodException: io.bloco.faker.components.Address.cityName()
at java.base/java.lang.Class.getDeclaredMethod(Class.java:2675)
at io.bloco.faker.FakerComponent.callMethod(FakerComponent.kt:78)
... 51 more
Not only the address is generated poorly, but also other fields like companies info or first name, which gives the result #{male_first_name}.
When I switch to Dutch lang (nl) it works fine
I came across the following while trying to use this faker 2.0.3 in a newish (API 34) kotlin android app that I'm writing
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.github.bmoliveira:snake-yaml:v1.18-android.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/github/bmoliveira/snake-yaml/v1.18-android/snake-yaml-v1.18-android.pom
- https://repo.maven.apache.org/maven2/com/github/bmoliveira/snake-yaml/v1.18-android/snake-yaml-v1.18-android.pom
Required by:
project :app > io.bloco:faker:2.0.3
This is not an issue with functionality of the library, but the use of the class Random
in class RandomHelper
does not pass security scans. Is it possible to replace Random
with SecureRandom
?
This code:
Faker("de").address.streetAddress()
Throws an IllegalArgumentException
with the message: Unsupported method 'street_name' for component 'address'
.
I believe it's the same for streetName
.
Can the sources be included in the deployment to jitpack.io? Would be easier for IDEs to download directly from the repository.
https://jitpack.io/com/github/blocoio/faker/1.2.7/build.log
Build artifacts:
com.github.blocoio:faker:1.2.7
Files:
com/github/blocoio/faker/1.2.7
com/github/blocoio/faker/1.2.7/build.log
com/github/blocoio/faker/1.2.7/faker-1.2.7.jar
com/github/blocoio/faker/1.2.7/faker-1.2.7.pom
com/github/blocoio/faker/1.2.7/faker-1.2.7.pom.md5
com/github/blocoio/faker/1.2.7/faker-1.2.7.pom.sha1
When doing faker.date.backward(1)
it can throw this expecetion
Random helper should probably protect from dividing by 0
java.lang.ArithmeticException: divide by zero
at io.bloco.faker.helpers.RandomHelper.number(RandomHelper.java:31)
at io.bloco.faker.components.Date.getRandomDate(Date.java:80)
at io.bloco.faker.components.Date.between(Date.java:70)
at io.bloco.faker.components.Date.backward(Date.java:56)
at com.grouse.dr_bill.data.preferences.LoggingPreferencesTest.latestUpload_whenEmpty(LoggingPreferencesTest.kt:39)
Given a Faker initialization as follows:
Faker faker = new Faker("ar-AE");
A runtime exception is thrown.
Appears that If a .yml def is not available for the specified locale, initialization will fail. My expectation would be that default locale would be used instead, especially since it appears to already be pre-loaded at the time of the exception.
Most likely this is a bug but if it's intended behavior I'd lobby for a change as it's common in cloud testing environments to test on a broad range of locales and it's desirable to use localized fake data when available, as opposed to always using us english vals.
Additionally, it would be nice if locale matching was a little more generic. For example, "zh_CN_#Hans" is a common value to retrieve from a device and will be mapped internally by the Android OS to "zh_CN". Ideally Faker would do something similar.
Documentation explicitly lists Food
under available components but it's not available in the lib and I don't see that it's implemented anywhere in the source.
In the method below, in the Faker
class, the contents of the value locale
are not validated. This came up in a security scan (http://cwe.mitre.org/data/definitions/73.html). Though not extremely likely, a malicious locale
could contain something like: ../../../../../etc
. I think the solution here is simply to verify that locale
matches something like [a-zA-Z](-[a-zA-Z][a-zA-Z]+)?
, and if not, throw IllegalArgumentException
.
private InputStream getDataInputStream(String locale) {
InputStream input = getClass().getClassLoader()
.getResourceAsStream("locales/" + locale + ".yml");
try {
if (input != null && input.available() != 0) {
return input;
}
} catch (IOException e) {
}
throw new IllegalArgumentException("Unavailable locale \'" + locale + "\'");
}
When running the following code:
Faker faker = new Faker()
The following exception is thrown:
java.lang.RuntimeException: file:~/.gradle/caches/modules-2/files-2.1/com.github.blocoio/faker/1.2.6/1dca62ce82fe8ddc90195b8f52fcc2d0962a5169/faker-1.2.6.jar!/locales/en.yml (No such file or directory)
at io.bloco.faker.Faker.getDataFromLocaleFile(Faker.java:145)
at io.bloco.faker.Faker.loadData(Faker.java:113)
at io.bloco.faker.Faker.(Faker.java:75)
It seem that this file is missing after a fresh install of the dependency, any input ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.