SecretControllerV2 { @ApiOperation(value = "${SecretControllerV2.deleteFromVault.value}", notes = "${SecretControllerV2.deleteFromVault.notes}") @DeleteMapping(value="/v2/safes/folders/secrets",produces="application/json") public ResponseEntity<String> deleteFromVault(@RequestHeader(value="vault-token") String token, @RequestParam("path") String path){ return secretService.deleteFromVault(token, path); }  @ApiOperation(value = "${SecretControllerV2.readFromVault.value}", notes = "${SecretControllerV2.readFromVault.notes}") @GetMapping(value="/v2/safes/folders/secrets",produces= "application/json") ResponseEntity<String> readFromVault(@RequestHeader(value="vault-token") String token, @RequestParam("path") String path,@RequestParam( name="fetchOption",required=false) FetchOption fetchOption); @ApiOperation(value = "${SecretControllerV2.write.value}", notes = "${SecretControllerV2.write.notes}") @PostMapping(value={"/v2/safes/folders/secrets","/v2/write"},consumes="application/json",produces="application/json") ResponseEntity<String> write(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody Secret secret); @ApiOperation(value = "${SecretControllerV2.deleteFromVault.value}", notes = "${SecretControllerV2.deleteFromVault.notes}") @DeleteMapping(value="/v2/safes/folders/secrets",produces="application/json") ResponseEntity<String> deleteFromVault(@RequestHeader(value="vault-token") String token, @RequestParam("path") String path);  }
@Test public void test_deleteFromVault() throws Exception { String responseMessage = "{\"messages\":[\"Secrets deleted\"]}"; ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseMessage); when(secretService.deleteFromVault(eq("5PDrOhsy4ig8L3EpsJZSLAMg"), eq("users/safe1"))).thenReturn(responseEntityExpected); mockMvc.perform(MockMvcRequestBuilders.delete("/v2/safes/folders/secrets?path=users/safe1") .header("vault-token", "5PDrOhsy4ig8L3EpsJZSLAMg") .header("Content-Type", "application/json;charset=UTF-8")) .andExpect(status().isOk()) .andExpect(content().string(containsString(responseMessage))); }