mtedone / podam

PODAM - POjo DAta Mocker
https://mtedone.github.io/podam
MIT License
323 stars 750 forks source link

All values of a class setted to null #211

Closed pacellig closed 8 years ago

pacellig commented 8 years ago

Trying to use the library in order to create random instances of unknown object ( which type is known at runtime ), all the values inside such a class are setted to null. Might it be that these fields are private, and so they are not seen/changed by the library?

i.e. Trying to create a random instance of originalObject

PodamFactory factory = new PodamFactoryImpl();
Object x = factory.manufacturePojo(originalObject.getClass());

all fields for x are null.

mtedone commented 8 years ago

You need to use the manufacturePojoWithFullData method.

Regards, M.

On 12 Jul 2016, at 08:07, Giuseppe notifications@github.com wrote:

Trying to use the library in order to create random instances of unknown object ( which type is known at runtime ), all the values inside such a class are setted to null. Might it be that these fields are private, and so they are not seen/changed by the library?

i.e. Trying to create a random instance of originalObject

PodamFactory factory = new PodamFactoryImpl(); Object x = factory.manufacturePojo(originalObject.getClass()); all fields for x are null.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/devopsfolks/podam/issues/211, or mute the thread https://github.com/notifications/unsubscribe/AAWXINYSFE5Oa5Gcp5jVdb3FfXGflRMFks5qUz1GgaJpZM4JKGPr.

daivanov commented 8 years ago

Might it be that these fields are private, and so they are not seen/changed by the library?

There could be million reasons for that. Could you please show the code of your POJO class?

pacellig commented 8 years ago

I haven't the code for the class, since I am trying to generate random instances of objects which type is only known at runtime, through reflection. I tried with ManufacturePojoWithFullData but doesn't seem to work as well.

daivanov commented 8 years ago

I haven't the code for the class, since I am trying to generate random instances of objects which type is only known at runtime, through reflection.

Without knowing, which class isn't populated it's impossible to say anything about this issue. Name the problematic class or present a Podam log, which should contain enough information for fixing this issue.

pacellig commented 8 years ago

I cannot share my POJO class since I am trying to randomize objects which type is only known at runtime. Thank you for your help.

daivanov commented 8 years ago

Even you use random objects at runtime, they are still specific objects at each specific execution, so you can print class name into the log and Podam logs data regarding its instantiation as well.