I have tests which I am writing that use AutoBeanCodex
to encode and decode AutoBeans.
When I try to test methods which use AutoBeanCodex.decode(...)
, I get errors like the following:
java.lang.ClassCastException: com.google.web.bindery.autobean.shared.AutoBean$$EnhancerByMockitoWithCGLIB$$78caf05b cannot be cast to com.google.web.bindery.autobean.shared.impl.AbstractAutoBean
at com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl.doDecode(AutoBeanCodexImpl.java:549)
at com.google.web.bindery.autobean.shared.AutoBeanCodex.decode(AutoBeanCodex.java:39)
at ...
First question is how do I deal with AutoBeanCodex
in my gwtmockito tests?
Do I have to use a fake provider like so, GwtMockito.useProviderForType(Class, FakeProvider)
?
If there are multiple ways to deal with AutoBeanCodex
, what is the best approach?
A priori (I haven't used GwtMockito, yet), you should configure a
FakeProvider
forAutoBeanFactory.class
to delegate toAutoBeanFactorySource.create()
so that you get real AutoBean instances, thatAutoBeanCodex
should be able to serialize and deserialize.You should probably raise an issue to GwtMockito so that this behavior is built-in, like for UiBinder et al.