UserPassService { public ResponseEntity<String> listUsers(String token){ log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Users Listing"). put(LogMessage.MESSAGE, "Trying to list users"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/auth/userpass/list","{}",token); log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Users Listing"). put(LogMessage.MESSAGE, "Users Listing Completed"). 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> createUser(String token, UserpassUser user); ResponseEntity<String> readUser(String token, String username); ResponseEntity<String> deleteUser(String token, String username); ResponseEntity<String> updatePassword( String token, UserpassUser user); ResponseEntity<String> listUsers(String token); ResponseEntity<String> login(UserLogin user);  }
@Test public void test_listUsers_successfully() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; Response response = getMockResponse(HttpStatus.OK, true, "{ \"data\": { \"keys\": [ \"safeadmin\",\"testuser1\", \"testuser2\", \"vaultadmin\"] }}"); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body("{ \"data\": { \"keys\": [ \"safeadmin\",\"testuser1\", \"testuser2\", \"vaultadmin\"] }}"); when(reqProcessor.process("/auth/userpass/list","{}",token)).thenReturn(response); ResponseEntity<String> responseEntity = userPassService.listUsers(token); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }