@Test public void testGetUserByUsername() throws RemoteApiException { String username = "symphony"; Map<String, String> headerParams = new HashMap<>(); headerParams.put("sessionToken", MOCK_SESSION); Map<String, String> queryParams = new HashMap<>(); queryParams.put("username", username); queryParams.put("local", Boolean.TRUE.toString()); User user = mockUser(); doReturn(user).when(httpClient).doGet("/v2/user", headerParams, queryParams, User.class); User result = apiClient.getUserByUsername(MOCK_SESSION, username); assertEquals(user, result); }
public User getUserByUsername(String sessionToken, String username) throws RemoteApiException { checkAuthToken(sessionToken); if (username == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, USERNAME, GET_USER_BY_USERNAME); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, USERNAME); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v2/user"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); Map<String, String> queryParams = new HashMap<>(); queryParams.put("username", username); queryParams.put("local", Boolean.TRUE.toString()); return apiClient.doGet(path, headerParams, queryParams, User.class); }
UserApiClient extends BasePodApiClient { public User getUserByUsername(String sessionToken, String username) throws RemoteApiException { checkAuthToken(sessionToken); if (username == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, USERNAME, GET_USER_BY_USERNAME); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, USERNAME); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v2/user"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); Map<String, String> queryParams = new HashMap<>(); queryParams.put("username", username); queryParams.put("local", Boolean.TRUE.toString()); return apiClient.doGet(path, headerParams, queryParams, User.class); } }
UserApiClient extends BasePodApiClient { public User getUserByUsername(String sessionToken, String username) throws RemoteApiException { checkAuthToken(sessionToken); if (username == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, USERNAME, GET_USER_BY_USERNAME); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, USERNAME); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v2/user"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); Map<String, String> queryParams = new HashMap<>(); queryParams.put("username", username); queryParams.put("local", Boolean.TRUE.toString()); return apiClient.doGet(path, headerParams, queryParams, User.class); } UserApiClient(HttpApiClient apiClient, LogMessageSource logMessage); }
UserApiClient extends BasePodApiClient { public User getUserByUsername(String sessionToken, String username) throws RemoteApiException { checkAuthToken(sessionToken); if (username == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, USERNAME, GET_USER_BY_USERNAME); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, USERNAME); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v2/user"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); Map<String, String> queryParams = new HashMap<>(); queryParams.put("username", username); queryParams.put("local", Boolean.TRUE.toString()); return apiClient.doGet(path, headerParams, queryParams, User.class); } UserApiClient(HttpApiClient apiClient, LogMessageSource logMessage); User getUserByEmail(String sessionToken, String email); User getUserByUsername(String sessionToken, String username); User getUserById(String sessionToken, Long userId); UserDetail createUser(String sessionToken, UserCreate userInfo); UserDetail updateUser(String sessionToken, Long uid, UserAttributes attributes); void updateUserAvatar(String sessionToken, Long uid, AvatarUpdate avatarUpdate); }
UserApiClient extends BasePodApiClient { public User getUserByUsername(String sessionToken, String username) throws RemoteApiException { checkAuthToken(sessionToken); if (username == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, USERNAME, GET_USER_BY_USERNAME); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, USERNAME); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v2/user"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); Map<String, String> queryParams = new HashMap<>(); queryParams.put("username", username); queryParams.put("local", Boolean.TRUE.toString()); return apiClient.doGet(path, headerParams, queryParams, User.class); } UserApiClient(HttpApiClient apiClient, LogMessageSource logMessage); User getUserByEmail(String sessionToken, String email); User getUserByUsername(String sessionToken, String username); User getUserById(String sessionToken, Long userId); UserDetail createUser(String sessionToken, UserCreate userInfo); UserDetail updateUser(String sessionToken, Long uid, UserAttributes attributes); void updateUserAvatar(String sessionToken, Long uid, AvatarUpdate avatarUpdate);  }