AccountController { @PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "/app/{username}", method = RequestMethod.DELETE) @ResponseBody public void deleteApp(@PathVariable("username") String username, HttpServletResponse response) { OadrApp findByUsername = oadrAppService.findByUsername(username); if (findByUsername == null) { LOGGER.warn("Unknown User: " + username); response.setStatus(HttpStatus.NOT_FOUND_404); return; } oadrAppService.delete(findByUsername); LOGGER.info("Delete Ven: " + findByUsername.getUsername()); }  @RequestMapping(value = "/", method = RequestMethod.GET) @ResponseBody @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_DEVICE_MANAGER') or hasRole('ROLE_DRPROGRAM')") AbstractUserWithRoleDto registeredUser(Principal principal); @PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "/user", method = RequestMethod.GET) @ResponseBody List<OadrUserDto> listUser(); @PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "/user", method = RequestMethod.POST) @ResponseBody ResponseEntity<InputStreamResource> createUser(@RequestBody OadrUserCreateDto dto,
			HttpServletResponse response); @PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "/user/{username}", method = RequestMethod.DELETE) @ResponseBody void deleteUser(@PathVariable("username") String username, HttpServletResponse response); @PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "/app", method = RequestMethod.GET) @ResponseBody List<OadrAppDto> listApp(); @PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "/app", method = RequestMethod.POST) @ResponseBody ResponseEntity<InputStreamResource> createApp(@RequestBody OadrAppCreateDto dto,
			HttpServletResponse response); @PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "/app/{username}", method = RequestMethod.DELETE) @ResponseBody void deleteApp(@PathVariable("username") String username, HttpServletResponse response);  }
@Test public void deleteAppTest() throws Exception { this.mockMvc .perform(MockMvcRequestBuilders.delete(ACCOUNT_APP_URL + "/mouaiccool") .header("Content-Type", "application/json").with(user)) .andExpect(MockMvcResultMatchers.status().is(HttpStatus.FORBIDDEN_403)); this.mockMvc .perform(MockMvcRequestBuilders.delete(ACCOUNT_APP_URL + "/mouaiccool") .header("Content-Type", "application/json").with(admin)) .andExpect(MockMvcResultMatchers.status().is(HttpStatus.NOT_FOUND_404)); OadrAppCreateDto dto = new OadrAppCreateDto(); dto.setCommonName("myapp"); dto.setUsername("myapp"); dto.setAuthenticationType("login"); dto.setPassword("pass"); byte[] content = mapper.writeValueAsBytes(dto); MvcResult andReturn = this.mockMvc .perform(MockMvcRequestBuilders.post(ACCOUNT_APP_URL).content(content) .header("Content-Type", "application/json").with(admin)) .andExpect(MockMvcResultMatchers.status().is(HttpStatus.CREATED_201)).andReturn(); assertEquals(0, andReturn.getResponse().getContentLength()); OadrApp findByUsername = oadrAppService.findByUsername("myapp"); assertNotNull(findByUsername); this.mockMvc .perform(MockMvcRequestBuilders.delete(ACCOUNT_APP_URL + "/myapp") .header("Content-Type", "application/json").with(admin)) .andExpect(MockMvcResultMatchers.status().is(HttpStatus.OK_200)); findByUsername = oadrAppService.findByUsername("myapp"); assertNull(findByUsername); }