Showing posts with label map. Show all posts
Showing posts with label map. Show all posts

June 07, 2021

IllegalArgumentException no serializer found for class org.mockito and no properties discovered to create beanserializer [Solved]

Solution : (Mockito.anyObject(), Mockito.any(TypeReference.class))


Hi 

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(){
when (objectMapper.convertValue(obj,map.class)).thenReturn(something);
}


Changing the convertValue parameter as (Mockito.anyObject(), Mockito.any(TypeReference.class)) solved the problem

Facebook comments