SecretService { public ResponseEntity<String> readFromVault(String token, String path){ log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Read Secret"). put(LogMessage.MESSAGE, String.format("Trying to read secret [%s]", path)). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/read","{\"path\":\""+path+"\"}",token); log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Read Secret"). put(LogMessage.MESSAGE, String.format("Reading secret [%s] completed succssfully", path)). put(LogMessage.STATUS, response.getHttpstatus().toString()). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); }  ResponseEntity<String> readFromVault(String token, String path); ResponseEntity<String> write(String token, Secret secret, UserDetails userDetails); ResponseEntity<String> deleteFromVault(String token, String path); ResponseEntity<String> readFromVaultRecursive(String token, String path); ResponseEntity<String> readFoldersAndSecrets(String token, String path);  }
@Test public void test_readFromVault_successfully() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; String responsejson = "{ \"data\": { \"secret1\": \"value1\", \"secret2\": \"value2\" }}"; Response response = getMockResponse(HttpStatus.OK, true, responsejson); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responsejson); when(reqProcessor.process("/read","{\"path\":\"shared/mysafe01/myfolder\"}",token)).thenReturn(response); ResponseEntity<String> responseEntity = secretService.readFromVault(token, "shared/mysafe01/myfolder"); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }