Spring Boot, Mockito, Unit Testing, Junit 5, Rest Api.
findById_ReturnsInternalServerError() throws Exception { when(this.bookService.findById(anyString())).thenThrow(RuntimeException.class); this.mockMvc.perform(get("/api/v1/books/123")).andExpect(status().isInternalServerError()); } } Conclusion In conclusion, mastering the art of unit testing in the