I am getting this exception - java.lang.IllegalArgumentException: No serializer found for class org.mockito.internal.creation.bytebuddy.ByteBuddyCrossClassLoaderSerializationSupport and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.mockito.codegen.Object$MockitoMock$["mockitoInterceptor"]->org.mockito.internal.creation.bytebuddy.MockMethodInterceptor["serializationSupport"])
The Testcase I'm writing looks like this
@Mock
Object object;
@Mock
ResponseType response;
@Test
public void handleRequest() {
ObjectMapper mapper = new ObjectMapper();
when(mapper.convertValue(object, ResponseType.class)).thenReturn(response)
new Handler().handleRequest(object);
}
The method I'm trying to test:
public class Handler{
public ResponseType handleRequest(Object object) {
ObjectMapper mapper = new ObjectMapper();
ResponseType response = mapper.convertValue(object, ResponseType.class);
return response;
}
}
I see that I can disable SerializationFeature.FAIL_ON_EMPTY_BEANS, but I have no control over the base class, I can only write a test case. Can someone tell me what I am doing wrong and what I can add to the test case? I cannot instantiate an ObjectMapper within the testcase as it has to be a mock, and I tried using a spy on the ObjectMapper and disable the SerializationFeature.FAIL_ON_EMPTY_BEANS, but neither works. I am also pretty new to Mockito so I'm not sure how I can proceed further. Any help would be appreciated, thanks