UserPassService { public ResponseEntity<String> readUser(String token, String username){ log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Read User"). put(LogMessage.MESSAGE, "Trying to read user"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/auth/userpass/read","{\"username\":\""+username+"\"}",token); log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Read User"). put(LogMessage.MESSAGE, "Reading username 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_readUser_successfully() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; String responseJson = "\"{ \\\"data\\\": { \\\"bound_cidrs\\\": [], \\\"max_ttl\\\": 0,\\\"policies\\\": [ \\\"default\\\" ], \\\"ttl\\\": 0 }}\""; Response response = getMockResponse(HttpStatus.OK, true, responseJson); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseJson); when(reqProcessor.process("/auth/userpass/read","{\"username\":\"testuser\"}",token)).thenReturn(response); ResponseEntity<String> responseEntity = userPassService.readUser(token,"testuser"); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }