I have a method and method includes one exception if some param does not write in url. Let's show below
if (url != null) {
File = getService().getByUrl(url);
} else {
throw new IllegalStateException("you must send id);
}
this is my method pair and I want to write test for exception. How to I cath error message with mockmvc?
return getMockMvc().perform(get(url))
.contentType(MediaType.APPLICATION_JSON_UTF8)
.andExpect(status().is5xxServerError());
This code not getting with error message. Can you help me