RestUserController { @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/users/{$username}", method = RequestMethod.DELETE) public void delete(@PathVariable("$username") String username) throws UserException { User user = userService.findByUsername(username); if (user == null ) { throw new UserException("No user found for username " + username); } userService.deleteById(user.getId()); }  @RequestMapping(value = "/users", method = RequestMethod.GET) List<User> all(); @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/users", method = RequestMethod.POST) 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_UTF8_VALUE) User getByUsername(@PathVariable("$username") String username); @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/users/{$username}", method = RequestMethod.PUT, 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);  }
@Test public void deleteUser() { restTemplate.delete(GET_PUT_DEL_URL, "doctorwho"); User newUser = restTemplate.getForObject(GET_PUT_DEL_URL, User.class, "doctorwho"); assertNull(newUser); }