I have problem testing , can someone help me please?
Here is the code I want to test:
Here is the test method :
When I'm testing RuntimeException, test is ok, but when testing JsonProcessingException it's printing error :
My goal is to send invalid request param so when objectmapper start mapping json string in CustomClass to throw JsonProcessingException or IoException.
When i change starting in this " its going to throw this warnign:
Exceptions from controller mappings can not be handled in the way you are expecting when testing with MockMvc. Any exception thrown from a controller mapping method will be received in your test as a 500 HTTP response. So instead of a try catch arrangement you'll need to do something like this