mtedone / podam

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

Fill custom collection types #252

Closed matthisk closed 6 years ago

matthisk commented 6 years ago

How would you support custom collection types (e.g. javaslang collections)? I can create a type manufacturer for these types of collections but that would not fill the actual collections. Going through the codebase I am stuck at the fact that the PodamFactory has hard coded methods to fill arrays/collections/maps.

daivanov commented 6 years ago

Hi,

Podam should be definitely able to instantiate javaslang.collection.List I assume using javaslang.collection.List.empty(). It won't fill it in as Podam doesn't know that javaslang.collection.List is a collection and how to fill it. But as you instantiate class in TypeManufacturer you definitely can fill in it there.

matthisk commented 6 years ago

Ok thanks for the reply, I was doubting whether it was correct to populate (custom) collections from within type manufacturers. Closing this issue now.

daivanov commented 6 years ago

From Podam point of view javaslang.collection.List is just an object. Podam will try to fill it with setters, but the interface has none. To make Podam handle custom lists as java.lang.Collection, there is a need to add to Podam registration of new collection interfaces. At least the following: class name, size method and adding method.