### Question:
VendingMachineController { @RequestMapping( value = "/vending-machine/push", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody Response selectProduct(@RequestBody Integer shelfNumber) { try{ vendingMachine.select(shelfNumber); return Response.success(); } catch (Exception e) { return Response.failure(e.getMessage()); } } @Autowired  VendingMachineController(VendingMachine vendingMachine, ProductStorage productStorage); @RequestMapping("/") String index(); @RequestMapping("/vending-machine") String page(); @RequestMapping( value = "/vending-machine/push", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") @ResponseBody Response selectProduct(@RequestBody Integer shelfNumber); @RequestMapping( value = "/vending-machine/insert", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") @ResponseBody Response insertCoin(@RequestBody String coin); @RequestMapping( value = "/vending-machine/state", method = RequestMethod.GET, produces = "application/json") @ResponseBody VendingMachineDTO state();  }### Answer:
@Test public void shouldSelectProduct() throws Exception { controller.selectProduct(3); verify(vendingMachine).select(3); }
@Test public void shouldReturnSuccessForSelect() throws Exception { Response response = controller.selectProduct(3); assertThat(response).isEqualTo(Response.success()); }
@Test public void shouldReturnFailureForSelect() throws Exception { selectFailsWithMessage("Invalid shelf number"); Response response = controller.selectProduct(-1); assertThat(response).isEqualTo(Response.failure("Invalid shelf number")); }