PODAM fails to initialize MyType<T> containing final Map<T,T>

176 vistas
Ir al primer mensaje no leído

Jordan Angold

no leída,
15 ago 2017, 1:43:04 p.m.15/8/17
para PODAM
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

Daniil Ivanov

no leída,
16 ago 2017, 11:35:27 a.m.16/8/17
para PODAM
Hi,

  I'm affraid there is no workaround, unless you tell Podam to skip filling of this field and then fill it yourself.
  Could you please report this issue on  https://github.com/devopsfolks/podam

Thanks, Daniil

Jordan Angold

no leída,
16 ago 2017, 1:47:18 p.m.16/8/17
para PODAM
Thanks for your reply.

I have copy-pasted my original post to https://github.com/devopsfolks/podam/issues/247

Thanks,
/Jordan
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos