Solution : (Mockito.anyObject(), Mockito.any(TypeReference.class))
Recently I went through a scenario and got the below error while using object Mapper
java.lang.illegalargumentexception :no serializer found for class org.mockito.internal.invocation.mock ref.mock weakreference and no properties discovered to create beanserializer (to avoid exception disable serializationfeature.fail_on_empty_beans [ Solved ]
Here is the scenario
public class A{
@Autowired
private ObjectMapper obj;
private boolean isWar(Test abc){
obj.convertValue(object, new TypeReference<Map<String,Object>>(){});
}
}
and my junit class is here
@Test
public void testSomething(){
public void testSomething(){
when (objectMapper.convertValue(obj,map.class)).thenReturn(something);
}
Changing the convertValue parameter as (Mockito.anyObject(), Mockito.any(TypeReference.class)) solved the problem
No comments:
Post a Comment
Your feedback may help others !!!