UserPassControllerV2 { @ApiOperation(value = "${UserPassControllerV2.deleteUser.value}", notes = "${UserPassControllerV2.deleteUser.notes}") @DeleteMapping(value="/v2/auth/userpass/users/{username}",produces="application/json") public ResponseEntity<String> deleteUser(@RequestHeader(value="vault-token") String token, @RequestBody String username){ return userpassService.deleteUser(token, username); }  @ApiOperation(value = "${UserPassControllerV2.createUser.value}", notes = "${UserPassControllerV2.createUser.notes}") @PostMapping(value="/v2/auth/userpass/users", consumes="application/json", produces="application/json") ResponseEntity<String> createUser(@RequestHeader(value="vault-token") String token, @RequestBody UserpassUser user); @ApiOperation(value = "${UserPassControllerV2.readUser.value}", notes = "${UserPassControllerV2.readUser.notes}") @GetMapping(value="/v2/auth/userpass/users/{username}",produces="application/json") ResponseEntity<String> readUser(@RequestHeader(value="vault-token") String token, @PathVariable("username" ) String username); @ApiOperation(value = "${UserPassControllerV2.deleteUser.value}", notes = "${UserPassControllerV2.deleteUser.notes}") @DeleteMapping(value="/v2/auth/userpass/users/{username}",produces="application/json") ResponseEntity<String> deleteUser(@RequestHeader(value="vault-token") String token, @RequestBody String username); @ApiOperation(value = "${UserPassControllerV2.updatePassword.value}", notes = "${UserPassControllerV2.updatePassword.notes}") @PutMapping(value="/v2/auth/userpass/users",produces="application/json") ResponseEntity<String> updatePassword(@RequestHeader(value="vault-token") String token,  @RequestBody UserpassUser user); @ApiOperation(value = "${UserPassControllerV2.listUsers.value}", notes = "${UserPassControllerV2.listUsers.notes}") @GetMapping(value="/v2/auth/userpass/users",produces="application/json") ResponseEntity<String> listUsers(@RequestHeader(value="vault-token") String token); @ApiOperation(value = "${UserPassControllerV2.login.value}", notes = "${UserPassControllerV2.login.notes}") @PostMapping(value="/v2/auth/userpass/login") ResponseEntity<String> login(@RequestBody UserLogin user);  }
@Test public void test_deleteUser() throws Exception { UserLogin user = new UserLogin(); user.setUsername("testuser"); String inputJson =new ObjectMapper().writeValueAsString(user); String responseMessage = "{\"messages\":[\"Username User deleted\"]}"; ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseMessage); when(userpassService.deleteUser(eq("5PDrOhsy4ig8L3EpsJZSLAMg"),Mockito.any())).thenReturn(responseEntityExpected); mockMvc.perform(MockMvcRequestBuilders.delete("/v2/auth/userpass/users/user1") .header("vault-token", "5PDrOhsy4ig8L3EpsJZSLAMg") .header("Content-Type", "application/json;charset=UTF-8") .content(inputJson)) .andExpect(status().isOk()) .andExpect(content().string(containsString(responseMessage))); }