Issue
can someone please help me?
I want't to test objectMapper.readValue() - when i send invalid string throw JsonProcessingException exception.
Method test :
@GetMapping("/find-example")
public Sort<Example> findByExample(@RequestParam String example) throws IOException {
Example exampleObject = objectMapper.readValue(example, Example.class);
return exampleService.findByExample(exampleObject);
}
I'm stuck for a week now with this test.
Solution
The only way to do that is having a real ObjectMapper being injected in the Controller while testing it.
Nevertheless, in my opinion, that is something you should avoid. You are basically testing code that is not yours.
Answered By - João Dias
Answer Checked By - Clifford M. (JavaFixing Volunteer)