### Question:
BookController { @GetMapping("/books") List<Book> findAll() { return repository.findAll(); }    }### Answer:
@Test public void find_allBook_OK() throws Exception { List<Book> books = Arrays.asList( new Book(1L, "Book A", "Ah Pig", new BigDecimal("1.99")), new Book(2L, "Book B", "Ah Dog", new BigDecimal("2.99"))); when(mockRepository.findAll()).thenReturn(books); mockMvc.perform(get("/books")) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()) .andExpect(jsonPath("$", hasSize(2))) .andExpect(jsonPath("$[0].id", is(1))) .andExpect(jsonPath("$[0].name", is("Book A"))) .andExpect(jsonPath("$[0].author", is("Ah Pig"))) .andExpect(jsonPath("$[0].price", is(1.99))) .andExpect(jsonPath("$[1].id", is(2))) .andExpect(jsonPath("$[1].name", is("Book B"))) .andExpect(jsonPath("$[1].author", is("Ah Dog"))) .andExpect(jsonPath("$[1].price", is(2.99))); verify(mockRepository, times(1)).findAll(); }