I have a method what I want to test. This method can throw an exception.
mapper.mapToDTO(fragment.getDTO(), new ElementHandler()); I want to test, that what happens after the Exception. So I made a Mocked test:
when(mapper.mapToDTO(dto, Mockito.any(ElementHandler.class))).thenThrow( new MappingFailureException()); Unfortunatelly this Mocking is not good. I also know that the Mockito.any part is not good. my goal would be to invoke the MappingFailureException
How can I map an Object of a type of a class, that my Exception will be thrown if any type of ElementHandler class is given as a parameter?