random instantiation of enum values

165 views
Skip to first unread message

Andreas Beckers

unread,
Mar 26, 2015, 6:17:07 AM3/26/15
to po...@googlegroups.com
Hello,

I am using PODAM for creating Testdata. Unfortunately PODAM does not instatiate enum values or I am missing something.

What I do is:

FACTORY.manufacturePojo(MyType.class);

I will get the wollowing warnings on each Enumaration:

2015-03-26 11:11:47 LoggingExternalFactory [WARN] Cannot instantiate class mypackage.myenum with arguments []. Returning null.

What I did is to Override the PodamFactoryImpl and did it myself:


    private static final class MyFactory extends PodamFactoryImpl {

       
@Override
       
public <T> T manufacturePojo(final Class<T> pojoClass) {
           
if (pojoClass.isEnum()) {
               
return pojoClass.getEnumConstants().length == 0 ? null : pojoClass.getEnumConstants()[new Random().nextInt(pojoClass.getEnumConstants().length)];
           
}
           
return super.manufacturePojo(pojoClass);
       
}

   
}


It would be also possible to randomly choose one of the existing enums.

I think that could be inserted into the PODAM Project, right?


Best regards,
Andreas


Marco Tedone

unread,
Mar 26, 2015, 8:24:19 AM3/26/15
to po...@googlegroups.com
Hi Andreas, the best way of contributing to the project is to fork it and implement a pull request. 

Regards, 
--
You received this message because you are subscribed to the Google Groups "PODAM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to podam+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniil Ivanov

unread,
Mar 28, 2015, 7:36:25 AM3/28/15
to po...@googlegroups.com
This was incorporated in podam-5.2.0.
Reply all
Reply to author
Forward
0 new messages