### Question:
BookController { @GetMapping public ResponseEntity<List<Book>> getAllBooks() { return ResponseEntity.ok(bookService.getAllBooks()); }  @PostMapping ResponseEntity<Void> createNewBook(@Valid @RequestBody BookRequest bookRequest, UriComponentsBuilder uriComponentsBuilder); @GetMapping ResponseEntity<List<Book>> getAllBooks(); @GetMapping("/{id}") ResponseEntity<Book> getBookById(@PathVariable("id") Long id); @PutMapping("/{id}") ResponseEntity<Book> updateBook(@PathVariable("id") Long id, @Valid @RequestBody BookRequest bookRequest); @DeleteMapping("/{id}") ResponseEntity<Void> deleteBook(@PathVariable("id") Long id);  }### Answer:
@Test public void allBooksEndpointShouldReturnTwoBooks() throws Exception { when(bookService.getAllBooks()).thenReturn(List.of( createBook(1L, "Java 11", "Duke", "1337"), createBook(2L, "Java EE 8", "Duke", "1338"))); this.mockMvc .perform(get("/api/books")) .andExpect(status().isOk()) .andExpect(content().contentType("application/json")) .andExpect(jsonPath("$", hasSize(2))) .andExpect(jsonPath("$[0].title", is("Java 11"))) .andExpect(jsonPath("$[0].author", is("Duke"))) .andExpect(jsonPath("$[0].isbn", is("1337"))) .andExpect(jsonPath("$[0].id", is(1))); }