@Test public void shouldListAllUsers() throws Exception { stubServiceToReturnExistingUsers(10); Collection<Book> books = bookController.listBooks(); assertNotNull(books); assertEquals(10, books.size()); verify(bookService, times(1)).getList(); }
@ApiOperation(value = "Retrieve a list of books.", responseContainer = "List") @RequestMapping(value = "/books", method = RequestMethod.GET, produces = {"application/json"}) public List<Book> listBooks() { LOGGER.debug("Received request to list all books"); return bookService.getList(); }
BookController { @ApiOperation(value = "Retrieve a list of books.", responseContainer = "List") @RequestMapping(value = "/books", method = RequestMethod.GET, produces = {"application/json"}) public List<Book> listBooks() { LOGGER.debug("Received request to list all books"); return bookService.getList(); } }
BookController { @ApiOperation(value = "Retrieve a list of books.", responseContainer = "List") @RequestMapping(value = "/books", method = RequestMethod.GET, produces = {"application/json"}) public List<Book> listBooks() { LOGGER.debug("Received request to list all books"); return bookService.getList(); } @Autowired  BookController(final BookService bookService); }
BookController { @ApiOperation(value = "Retrieve a list of books.", responseContainer = "List") @RequestMapping(value = "/books", method = RequestMethod.GET, produces = {"application/json"}) public List<Book> listBooks() { LOGGER.debug("Received request to list all books"); return bookService.getList(); } @Autowired  BookController(final BookService bookService); @RequestMapping(value = "/books", method = RequestMethod.POST, consumes = {"application/json"}) Book saveBook(@RequestBody @Valid final Book book); @ApiOperation(value = "Retrieve a list of books.", responseContainer = "List") @RequestMapping(value = "/books", method = RequestMethod.GET, produces = {"application/json"}) List<Book> listBooks(); @RequestMapping(value = "/books/{id}", method = RequestMethod.GET, produces = {"application/json"}) @ResponseBody Book singleBook(@PathVariable Long id); @RequestMapping(value = "/books/{id}", method = RequestMethod.DELETE) void deleteBook(@PathVariable Long id); @ExceptionHandler @ResponseStatus(HttpStatus.CONFLICT) String handleUserAlreadyExistsException(BookAlreadyExistsException e); }
BookController { @ApiOperation(value = "Retrieve a list of books.", responseContainer = "List") @RequestMapping(value = "/books", method = RequestMethod.GET, produces = {"application/json"}) public List<Book> listBooks() { LOGGER.debug("Received request to list all books"); return bookService.getList(); } @Autowired  BookController(final BookService bookService); @RequestMapping(value = "/books", method = RequestMethod.POST, consumes = {"application/json"}) Book saveBook(@RequestBody @Valid final Book book); @ApiOperation(value = "Retrieve a list of books.", responseContainer = "List") @RequestMapping(value = "/books", method = RequestMethod.GET, produces = {"application/json"}) List<Book> listBooks(); @RequestMapping(value = "/books/{id}", method = RequestMethod.GET, produces = {"application/json"}) @ResponseBody Book singleBook(@PathVariable Long id); @RequestMapping(value = "/books/{id}", method = RequestMethod.DELETE) void deleteBook(@PathVariable Long id); @ExceptionHandler @ResponseStatus(HttpStatus.CONFLICT) String handleUserAlreadyExistsException(BookAlreadyExistsException e);  }