how about you create an anonymous exception of type JsonProcessingException
when(mapper.writeValueAsString(any(Object.class))).thenThrow(new JsonProcessingException("Error"){});
The {} braces does the trick. This is much better since it is not confusing to the reader of the test code.