@Test public void deleteUser() { restTemplate.delete(GET_POST_URL, "gigipedala"); User newUser = restTemplate.getForObject(GET_PUT_DEL_URL, User.class, "gigipedala"); assertNull(newUser); }
@ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/users/{$username}", method = RequestMethod.DELETE) public void delete(@PathVariable("$username") String username) throws UserException { final User user = userService.findByUsername(username); if (user == null) { throw new UserException("No user found for username " + username); } userService.deleteById(user.getId()); }
RestUserController { @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/users/{$username}", method = RequestMethod.DELETE) public void delete(@PathVariable("$username") String username) throws UserException { final User user = userService.findByUsername(username); if (user == null) { throw new UserException("No user found for username " + username); } userService.deleteById(user.getId()); } }
RestUserController { @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/users/{$username}", method = RequestMethod.DELETE) public void delete(@PathVariable("$username") String username) throws UserException { final User user = userService.findByUsername(username); if (user == null) { throw new UserException("No user found for username " + username); } userService.deleteById(user.getId()); } @Autowired  RestUserController(UserService userService); }
RestUserController { @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/users/{$username}", method = RequestMethod.DELETE) public void delete(@PathVariable("$username") String username) throws UserException { final User user = userService.findByUsername(username); if (user == null) { throw new UserException("No user found for username " + username); } userService.deleteById(user.getId()); } @Autowired  RestUserController(UserService userService); @RequestMapping(value = "/users", method = RequestMethod.GET) List<User> all(); @PostMapping @RequestMapping(value = "/users") void create(@RequestBody @Valid User newUser, @Value("#{request.requestURL}")
			StringBuffer originalUrl, HttpServletResponse response); @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/users/{$username}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) User getByUsername(@PathVariable("$username") String username); @PutMapping @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/users/{$username}", produces = MediaType.APPLICATION_JSON_VALUE) User update(@PathVariable("$username") String username, @RequestBody User newUser); @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/users/{$username}", method = RequestMethod.DELETE) void delete(@PathVariable("$username") String username); @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/allusers/{$type}", produces = MediaType.APPLICATION_JSON_VALUE) Collection<User> getByType(@PathVariable("$type") UserType type); @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/emails/{$type}", produces = MediaType.APPLICATION_JSON_VALUE) Collection<String> getIdsByType(@PathVariable("$type") UserType type); @ResponseStatus(HttpStatus.NOT_FOUND) @ExceptionHandler({IllegalArgumentException.class}) void handleNotFound(); @ResponseStatus(HttpStatus.CONFLICT) @ExceptionHandler({DataIntegrityViolationException.class}) void handleAlreadyExists(); }
RestUserController { @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/users/{$username}", method = RequestMethod.DELETE) public void delete(@PathVariable("$username") String username) throws UserException { final User user = userService.findByUsername(username); if (user == null) { throw new UserException("No user found for username " + username); } userService.deleteById(user.getId()); } @Autowired  RestUserController(UserService userService); @RequestMapping(value = "/users", method = RequestMethod.GET) List<User> all(); @PostMapping @RequestMapping(value = "/users") void create(@RequestBody @Valid User newUser, @Value("#{request.requestURL}")
			StringBuffer originalUrl, HttpServletResponse response); @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/users/{$username}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) User getByUsername(@PathVariable("$username") String username); @PutMapping @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/users/{$username}", produces = MediaType.APPLICATION_JSON_VALUE) User update(@PathVariable("$username") String username, @RequestBody User newUser); @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/users/{$username}", method = RequestMethod.DELETE) void delete(@PathVariable("$username") String username); @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/allusers/{$type}", produces = MediaType.APPLICATION_JSON_VALUE) Collection<User> getByType(@PathVariable("$type") UserType type); @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/emails/{$type}", produces = MediaType.APPLICATION_JSON_VALUE) Collection<String> getIdsByType(@PathVariable("$type") UserType type); @ResponseStatus(HttpStatus.NOT_FOUND) @ExceptionHandler({IllegalArgumentException.class}) void handleNotFound(); @ResponseStatus(HttpStatus.CONFLICT) @ExceptionHandler({DataIntegrityViolationException.class}) void handleAlreadyExists();  }