Git Product home page Git Product logo

jfairy's Introduction

jFairy by Devskiller

Build Status Maven Central Javadocs Coverage Status Stack Overflow Join the chat at https://gitter.im/Codearte/jfairy

Java fake data generator. Based on Wikipedia:

Fairyland, in folklore, is the fabulous land or abode of fairies or fays.

Try jFairy online!

https://devskiller.com/datafairy/

Usage

Creating simple objects:

Fairy fairy = Fairy.create();
Person person = fairy.person();

System.out.println(person.getFirstName());            
// Chloe Barker
System.out.println(person.getEmail());               
// [email protected]
System.out.println(person.getTelephoneNumber());     
// 690-950-802

Person adultMale = fairy.person(PersonProperties.male(), PersonProperties.minAge(21));
System.out.println(adultMale.isMale());           
// true
System.out.println(adultMale.getDateOfBirth());      
// at least 21 years earlier

Creating related objects:

Fairy fairy = Fairy.create();
Company company = fairy.company();
System.out.println(company.getName());          
// Robuten Associates
System.out.println(company.getUrl());           
// http://www.robuteniaassociates.com

Person salesman = fairy.person(PersonProperties.withCompany(company));
System.out.println(salesman.getFullName());     
// Juan Camacho
System.out.println(salesman.getCompanyEmail()); 
// [email protected]

Locale support:

Fairy enFairy = Fairy.create();                               
// Locale.ENGLISH is default
Fairy plFairy = Fairy.create(Locale.forLanguageTag("pl"));    
// Polish version

Other samples

Look into code samples

Building

This project can be built using maven command:

./mvnw install

jfairy's People

Contributors

andidev avatar armujahid avatar benmccann avatar briacp avatar ccjmne avatar djechelon avatar eduardrindt-4f avatar elnur avatar gitter-badger avatar jkubrynski avatar kdebski85 avatar mariuszs avatar olgamaciaszek avatar pascalschumacher avatar piotrpietrzak avatar rweisleder avatar szpak avatar tvedeane avatar zhangmx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jfairy's Issues

java.lang.NoSuchMethodError when upgrading to guava 22.0

Using jfairy 0.5.7. The following exception is triggered by Fairy.create().

java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
	at io.codearte.jfairy.data.MapBasedDataMaster.getData(MapBasedDataMaster.java:87)
	at io.codearte.jfairy.data.MapBasedDataMaster.getString(MapBasedDataMaster.java:73)
	at io.codearte.jfairy.producer.text.TextProducerInternal.<init>(TextProducerInternal.java:51)
	at io.codearte.jfairy.producer.text.TextProducerInternal$$FastClassByGuice$$1d020c2d.newInstance(<generated>)
	at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
	at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)
	at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
	at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
	at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
	at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
	at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
	at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
	at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
	at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
	at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
	at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
	at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
	at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
	at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
	at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
	at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
	at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
	at com.google.inject.assistedinject.FactoryProvider2.invoke(FactoryProvider2.java:770)
	at io.codearte.jfairy.$Proxy50.createFairy(Unknown Source)
	at io.codearte.jfairy.Bootstrap.createFairy(Bootstrap.java:55)
	at io.codearte.jfairy.Bootstrap$Builder.build(Bootstrap.java:237)
	at io.codearte.jfairy.Bootstrap.create(Bootstrap.java:85)
	at io.codearte.jfairy.Fairy.create(Fairy.java:48)

Cannot get an instance of Fairy since 0.5.5

The issue

I am trying to load a static instance of Fairy via Fairy#create. My application is left hanging because that instance is never ready.

I get the following exception:

com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error injecting constructor, java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
  at io.codearte.jfairy.producer.text.TextProducerInternal.<init>(TextProducerInternal.java:49)
  while locating io.codearte.jfairy.producer.text.TextProducerInternal
    for parameter 0 at io.codearte.jfairy.producer.text.TextProducer.<init>(TextProducer.java:34)
  while locating io.codearte.jfairy.producer.text.TextProducer
    for parameter 0 at io.codearte.jfairy.Fairy.<init>(Fairy.java:37)
  while locating io.codearte.jfairy.Fairy annotated with @com.google.inject.internal.UniqueAnnotations$Internal(value=1)

It is worth noting that this exception is actually being swallowed somewhere down the line.

How to reproduce

Simply run the following piece of code:

public static final Fairy FAIRY = Fairy.create();

Versions affected

Sorry for lacking specifics and not coming up with a PR for this -- I am really busy right now. Just trying to put it out there and let you know. Maybe I'm just missing something huge or you guys just can't reproduce it.

Either way, I'll be sticking to 0.5.3 for now! I might come back to it this weekend.

java.lang.NoSuchMethodError: org.yaml.snakeyaml.Yaml.loadAs

I tried to use JFairy in my project (TestNG 6.8.5) and got

java.lang.NoSuchMethodError: org.yaml.snakeyaml.Yaml.loadAs(Ljava/io/InputStream;Ljava/lang/Class;)Ljava/lang/Object;
at eu.codearte.fairyland.data.DataMaster.readResources(DataMaster.java:92)
at eu.codearte.fairyland.Fairy.(Fairy.java:35)
at eu.codearte.fairyland.Fairy.create(Fairy.java:72)
at eu.codearte.fairyland.Fairy.create(Fairy.java:61)
at eu.codearte.fairyland.Fairy.create(Fairy.java:50)
at org.stormnetdev.inputdata.testdata.DataProvider.(DataProvider.java:6)
at org.stormnetdev.pageobjects.sampletest.GoogleHomePage.performRandomPersonSearchQuery(GoogleHomePage.java:24)
at org.stormnetdev.tests.sampletest.SampleTest.sampleTest(SampleTest.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

Missing release

The current release (0.5.0) does not support the already developed French locale. Missing release new version with the current updates.

Support for UK profiles

Recently a client of mine from the UK was looking for a tool for test data generation, but it generates only American profiles.

Please remove groovy-all dependency from compile scope

you should remove the following dependency:

<dependency>
	<groupId>org.codehaus.groovy</groupId>
	<artifactId>groovy-all</artifactId>
	<version>2.4.14</version>
</dependency>

Why?

  • It is only relevant for test, but not scoped to test. So it will transitively be included into your clients' projects.
  • There's no need to declare it explicitly, as it comes automatically with spock.
  • If there's a reason I did not see for manually upgrading the version, then you should at least set the scope to test

Thanks :-)

Illegal Characters in E-Mail addresses

Generated names should not be used verbatim in the construction of email addresses, because they can contain characters that are not allowed in email addresses.

Example: "Hugo Groß" leads to the German ß umlaut appearing in his email address.

Add possibility to get city from a given country

I am trying to create on my application a company with a city from my country. It would be glad to be able to generate a city given a country. I have several idea :

  • Add Nationality or country of birth in person and PersonProperties. I could get city from the person
  • Add Country in company and in CountryProperties
  • Add country in the Address

Regards

Junit 5 ParameterResolver extension for jfairy

just like MockitoExtension to supply mock extension

   @Test
    void testMock1(@Mock Person person) {
        when(person.getName()).thenReturn("Dilbert");
    }

In jfairy, just like following:

   @Test
    void testMock1(@Faked Person person) {
          person.getFullName();
    }

Add a generic randomElement method

Current randomElement() methods do not support getting a random element of my own type like an enum. Would be nice to have such a feature.

I also think it would be better for such a method to get a vararg argument instead of a list. But maybe both options make sense.

Support customized language

I'm using jfairy 0.5.6.
I want to add a chinese config jfairy_zh.yml and create Fairy by Fairy.create(Locale.CHINA).
In most situations it is ok to use default EnFairyModule as English is most popular language in the world.

However I met with an Exception

java.lang.IllegalArgumentException: No enum constant io.codearte.jfairy.producer.util.LanguageCode.ZH
at java.lang.Enum.valueOf(Enum.java:236)
at io.codearte.jfairy.producer.util.LanguageCode.valueOf(LanguageCode.java:7)
at io.codearte.jfairy.Bootstrap.getFairyModuleForLocale(Bootstrap.java:118)

I believe that return a default value (LanguageCode.EN) of LanguageCode.valueOf() (or a wrapper method) for unknown locale may be more reasonable, as there is a coming switch-default structure to handle the unknown locale.

    LanguageCode code = null;
    try {
        code = LanguageCode.valueOf(locale.getLanguage().toUpperCase());
    } catch (IllegalArgumentException e) {
        LOG.warn("Uknown locale " + locale);
        code = LanguageCode.EN;
    }

==========

Another question is that ./gradlew build always fails with exceptions signing.keyId and signing.secretKeyRingFile has to be configured while building the project cloning from github. I'm not familiar with gradle :( (I use maven).

If you guys intend to support Chinese language , I would like to help. Thanks.

textproducer.word(int count) with 117 elements results in an empty response.

If you call the TextProducer class method word with exactly 117 items, you will receive an empty result back.

So the following example:

Faityr.create().textProducer().word(117);

will result in an empty string. This has to do with it being 117 words available in the internal representation of the words in TextProducerInternal is of size 117, wish results in the method in BaseProducer:

public <T> List<T> randomElements(List<T> elements, int count) {
    Collections.shuffle(elements, this.random);
    return elements.subList(0, count % elements.size());
}

the sublist will become 0, 117%117 = 0, so no result will be returned. This depends on the number of words available of course, but I assume that it's not the expected result wished for.

End of support for Java 7?

Oracle plans to end releasing public updates for Java 7 in April 2015. We are considering to end support for Java 7 in jFairy along with it (jFairy versions released after that time would require Java 8+).

If you (as a jFairy user) have a good argument to keep support for Java 7 a little bit longer please say it in that issue.

Getting Started with JFairy

Hey,

New to this API, can anybody point me to documentation that covers setting a dev environment with dependencies? Looks like there are many! Anyway - help much appreciated!

.Chris

Too much dependencies

I think those dependencies are to much, and a lot of them are no need for end-user.
dependences
I suggest that you consider to remove or change it to optional, like:

<dependency>
    <groupId>org.yaml</groupId>
    <artifactId>snakeyaml</artifactId>
    <version>[1.9,2.0)</version>
    <optional>true</optional>
</dependency>

is there a parameter to specify the phone number format?

Hi

is there a parameter to specify the phone number format. I had a look through the methods and can't seem to see anything.

currently, numbers returned are between 9 & 10 digits with - separator.
I am stripping out the - but need to make the numbers a consistent amount of digits.

I may be missing the detail, if so can you point me in the right direction.
Thanks

Document thread safety

Please document if the library is thread-safe. I'm generating millions of test samples and want to know if I can safely reuse the same instance across threads. Also during prototyping, I use Fairy object as a Spring singleton bean - is it safe as well?

Another question - if I create hundreds of Fairy instances in quick succession, will they produce different samples? Or maybe (due to the same random seed maybe?) I'll get duplicates?

randomBetween(int, int) and randomBetween(long, long) are broken

The following invocations will always return 0:

randomInt(Integer.MAX_VALUE)
randomBetween(0, Integer.MAX_VALUE)

The following invocation will always return a negative number:

randomBetween(0L, Long.MAX_VALUE)

The reason for this behavior for integers is this weird logic:

int range = max - min + 1;
int randomInt = range > 0 ? this.random.nextInt(range) : 0;
return min + randomInt;

Subtracting 0 from the max integer value and then adding 1 to it overflows it and hence range is never above 0.

Something similar is being done for longs as well.

A quickfix is to subtract 1 from the max values but that's a huge WTF moment. These methods fail to deliver their promises.

File jfairy_ita.yml was not found on classpath

I included JFairy in my gradle build via

compile('io.codearte.jfairy:jfairy:0.5.9')

and generated a Person. The following stack trace appears at runtime:

Caused by: java.lang.IllegalArgumentException: File jfairy_ita.yml was not found on classpath at io.codearte.jfairy.data.MapBasedDataMaster.readResources(MapBasedDataMaster.java:100) ~[jfairy-0.5.9.jar:0.5.9] at io.codearte.jfairy.Bootstrap.fillDefaultDataMaster(Bootstrap.java:59) ~[jfairy-0.5.9.jar:0.5.9] at io.codearte.jfairy.Bootstrap.access$100(Bootstrap.java:38) ~[jfairy-0.5.9.jar:0.5.9] at io.codearte.jfairy.Bootstrap$Builder.build(Bootstrap.java:225) ~[jfairy-0.5.9.jar:0.5.9] at io.codearte.jfairy.Bootstrap.create(Bootstrap.java:93) ~[jfairy-0.5.9.jar:0.5.9] at io.codearte.jfairy.Fairy.create(Fairy.java:52) ~[jfairy-0.5.9.jar:0.5.9]

Build fails when on release tag and no keys are configured

As reported in #78. ./gradlew build fails with:

* Where:
Build file '/home/foo/code/jfairy/build.gradle' line: 114

* What went wrong:
signing.keyId and signing.secretKeyRingFile has to be configured (e.g. in ~/.gradle/gradle.properties)

if the latest commit is tagged with a release tag. It can be confusing for external contributors.

As a workaround -x sign can be used.

Does not work with JDK8 - key not found in "CaseInsensitiveMap"

    private static class CaseInsensitiveMap extends HashMap<String, Object> {

        @Override
        @SuppressWarnings("unchecked")
        public Object put(String key, Object value) {
            String loweredKey = key.toLowerCase();
            Object valueToInsert = value;

            if (value instanceof Map) {
                valueToInsert = new CaseInsensitiveMap();
                ((CaseInsensitiveMap) valueToInsert).putAll((Map<? extends String, ?>) value);
            }

            return super.put(loweredKey, valueToInsert);
        }

        @Override
        @SuppressWarnings("unchecked")
        public Object get(Object key) {
            return super.get(((String) key).toLowerCase());
        }

    }

This is only overriding the put method, not the putAll method. In JDK7 and below, that was fine. In JDK8 both put and putAll delegate to a different method: putVal.

I'd say that subclassing a JDK class is probably a bad idea anyway. This should probably be done with delegation.

Enhance language code systems to include full locale

Write now, fairy versions are differentiated by lang codes, for example 'EN'; however in many instances, this is not enough. For example, an EN fairy will return data in English, but also in formats correct for a specific country - US. This kind of info should be included so tath fairies for various locale with the same language can be added.

jfairy doesn't work with GlassFish 4.1

I have no beans.xml file in my Java EE 7 application (implicit bean archive). Deploy fails with error:

org.glassfish.deployment.common.DeploymentException: CDI deployment failure:Exception List with 2 exceptions:
Exception 0 :
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type BaseProducer with qualifiers @Default
  at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject public org.jfairy.producer.DateProducer(BaseProducer, TimeProvider)
  at org.jfairy.producer.DateProducer.<init>(DateProducer.java:0)
...
Exception 0 :
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type BaseProducer with qualifiers @Default
  at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject org.jfairy.data.DataMaster(BaseProducer)
  at org.jfairy.data.DataMaster.<init>(DataMaster.java:0)
...

jfairy uses Guice but container (GlassFish 4.1) thinks it uses CDI.
Guava team had a similar problem https://code.google.com/p/guava-libraries/issues/detail?id=1433.

I created beans.xml but it didn't help:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       bean-discovery-mode="annotated">    

    <scan>
        <exclude name="org.jfairy.**"/>
    </scan>
</beans>

i use testng

i use jfairy in testng but i met error.
how can i?

Fairy fairy = Fairy.create();
Person person = fairy.person();
FAILED: UserAddFailed
java.lang.NoClassDefFoundError: com/google/inject/internal/util/$Maps
    at com.google.inject.assistedinject.BindingCollector.<init>(BindingCollector.java:34)
    at com.google.inject.assistedinject.FactoryModuleBuilder.<init>(FactoryModuleBuilder.java:206)
    at io.codearte.jfairy.FairyModule.configure(FairyModule.java:28)
    at io.codearte.jfairy.EnFairyModule.configure(EnFairyModule.java:24)
    at com.google.inject.AbstractModule.configure(AbstractModule.java:62)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:259)
    at com.google.inject.spi.Elements.getElements(Elements.java:109)
    at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:136)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
    at com.google.inject.Guice.createInjector(Guice.java:96)
    at com.google.inject.Guice.createInjector(Guice.java:73)
    at com.google.inject.Guice.createInjector(Guice.java:62)
    at io.codearte.jfairy.Bootstrap.createFairy(Bootstrap.java:39)
    at io.codearte.jfairy.Bootstrap$Builder.build(Bootstrap.java:155)
    at io.codearte.jfairy.Bootstrap.create(Bootstrap.java:70)
    at io.codearte.jfairy.Fairy.create(Fairy.java:45)
    at me.dailylook.tests.user.UserAdd.UserAddFailed(UserAdd.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
    at org.testng.SuiteRunner.run(SuiteRunner.java:254)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.lang.ClassNotFoundException: com.google.inject.internal.util.$Maps
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 41 more

Guice provision errors: No such key: companyNames

Fairy.create().person().getAddress().city()

Exception in thread "main" com.google.inject.ProvisionException: Guice provision errors:

  1. Error injecting constructor, java.lang.IllegalArgumentException: No such key: companyNames
    at org.jfairy.producer.company.Company.(Company.java:27)
    while locating org.jfairy.producer.company.Company
    for parameter 6 at org.jfairy.producer.person.Person.(Person.java:68)
    while locating org.jfairy.producer.person.Person

1 error
at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:987)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1013)
at org.jfairy.Fairy.person(Fairy.java:89)
....
Caused by: java.lang.IllegalArgumentException: No such key: companyNames
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:120)
at org.jfairy.data.DataMaster.getData(DataMaster.java:78)
at org.jfairy.data.DataMaster.getStringList(DataMaster.java:41)
at org.jfairy.data.DataMaster.getRandomValue(DataMaster.java:69)
at org.jfairy.producer.company.Company.(Company.java:30)
at org.jfairy.producer.company.Company$$FastClassByGuice$$b478b369.newInstance()
at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:84)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)
... 9 more

asm pkg dep conflict with common android build

When running jfairy on android with roboelectric 3.0+, there is a package dependency mismatch against the asm library. jfairy runs on asm:asm:3.1 which is nearly a decade old while roboelectric run against asm 5.+. The pkg dep output for jfairy is below.

Injection is good and all but by including it in this library it increases the surface area for conflicts like above. When making the trade-off in terms of library maintainability vs. compatibility I would side on the compatibility especially as in the case of a library like this that really doesn't require injection or joda time etc.

+--- io.codearte.jfairy:jfairy:0.4.1
| +--- com.google.guava:guava:[15.0,) -> 19.0-rc1
| +--- com.google.inject:guice:3.0
| | +--- javax.inject:javax.inject:1
| | +--- aopalliance:aopalliance:1.0
| | --- org.sonatype.sisu.inject:cglib:2.2.1-v20090111
| | --- asm:asm:3.1 <----------------------------------------- conflict
| +--- org.yaml:snakeyaml:[1.9,2.0) -> 1.15
| +--- org.iban4j:iban4j:2.1.1
| +--- com.google.inject.extensions:guice-assistedinject:3.0
| | --- com.google.inject:guice:3.0 (*)
| +--- joda-time:joda-time:2.3
| +--- org.reflections:reflections:0.9.9
| | +--- com.google.guava:guava:15.0 -> 19.0-rc1
| | +--- org.javassist:javassist:3.18.2-GA -> 3.19.0-GA
| | --- com.google.code.findbugs:annotations:2.0.1
| +--- org.apache.commons:commons-lang3:3.3.2
| --- org.slf4j:slf4j-api:1.7.7

Google Guava Dependency causes Version Mismatch Error with Java 7

The build.gradle file specifies that any version greater than 15 of Google Guava should be used.

Google has just released Guava 21.0.rc1, which requires Java 8. Due to this, projects using JFairy that are being compiled with Java 1.7 fail with a Java Version Mismatch, for instance:

java.lang.UnsupportedClassVersionError: com/google/common/collect/Sets : Unsupported major.minor version 52.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.