I have a test case that requires PODAM to create and fill a POJO containing a final Map<T,T> as suggested in the title, and found that it doesn't work. I'm using PODAM 7.0.5 .
I have distilled the problem down to this example:
public class MyTest {
@Test
public void test() {
PodamFactory factory = new PodamFactoryImpl();
MyType<String> wrapper = factory.manufacturePojoWithFullData(MyType.class, String.class);
assertNotNull(wrapper);
}
public static class MyType<T> {
/* // works:
Map<T,T> map;
public void setMap(Map<T,T> map) { this.map = map; }
//*/
// doesn't work:
final Map<T,T> map = new HashMap<>();
public Map<T,T> getMap() {
return map;
}
}
}
If you use the 'doesn't work' part, you get:
java.lang.IllegalArgumentException: java.util.Map is missing generic type arguments, expected [K, V], provided [T, T]
at uk.co.jemos.podam.typeManufacturers.TypeManufacturerUtil.fillTypeArgMap(TypeManufacturerUtil.java:169)
at uk.co.jemos.podam.api.PodamFactoryImpl.populateReadOnlyField(PodamFactoryImpl.java:709)
at uk.co.jemos.podam.api.PodamFactoryImpl.populatePojoInternal(PodamFactoryImpl.java:622)
at uk.co.jemos.podam.api.PodamFactoryImpl.manufacturePojoInternal(PodamFactoryImpl.java:533)
at uk.co.jemos.podam.api.PodamFactoryImpl.doManufacturePojo(PodamFactoryImpl.java:436)
at uk.co.jemos.podam.api.PodamFactoryImpl.manufacturePojoWithFullData(PodamFactoryImpl.java:141)
at MyTest.test:15
If you instead use the 'works' part instead, then you get a correctly-constructed object.
I don't know much about the internal workings of PODAM, but this seems like a bug to me. I would prefer to not have to modify my own business logic types (represented here as MyType). Is there a workaround?
Thanks,
/Jordan