@Test public void testUpdateUser() throws RemoteApiException { Map<String, String> headerParams = new HashMap<>(); headerParams.put("sessionToken", MOCK_SESSION); UserAttributes userAttributes = mockUserAttributes(); UserDetail expected = new UserDetail(); expected.setUserAttributes(userAttributes); String path = "/v1/admin/user/" + MOCK_USER_ID + "/update"; doReturn(expected).when(httpClient) .doPost(path, headerParams, Collections.<String, String>emptyMap(), userAttributes, UserDetail.class); UserDetail result = apiClient.updateUser(MOCK_SESSION, MOCK_USER_ID, userAttributes); assertEquals(expected, result); }
public UserDetail updateUser(String sessionToken, Long uid, UserAttributes attributes) throws RemoteApiException { checkAuthToken(sessionToken); if (uid == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, UID, UPDATE_USER); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, UID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (attributes == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, UPDATE_USER); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, UPDATE_USER); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/" + uid + "/update"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), attributes, UserDetail.class); }
UserApiClient extends BasePodApiClient { public UserDetail updateUser(String sessionToken, Long uid, UserAttributes attributes) throws RemoteApiException { checkAuthToken(sessionToken); if (uid == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, UID, UPDATE_USER); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, UID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (attributes == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, UPDATE_USER); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, UPDATE_USER); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/" + uid + "/update"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), attributes, UserDetail.class); } }
UserApiClient extends BasePodApiClient { public UserDetail updateUser(String sessionToken, Long uid, UserAttributes attributes) throws RemoteApiException { checkAuthToken(sessionToken); if (uid == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, UID, UPDATE_USER); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, UID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (attributes == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, UPDATE_USER); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, UPDATE_USER); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/" + uid + "/update"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), attributes, UserDetail.class); } UserApiClient(HttpApiClient apiClient, LogMessageSource logMessage); }
UserApiClient extends BasePodApiClient { public UserDetail updateUser(String sessionToken, Long uid, UserAttributes attributes) throws RemoteApiException { checkAuthToken(sessionToken); if (uid == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, UID, UPDATE_USER); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, UID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (attributes == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, UPDATE_USER); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, UPDATE_USER); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/" + uid + "/update"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), attributes, UserDetail.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 UserDetail updateUser(String sessionToken, Long uid, UserAttributes attributes) throws RemoteApiException { checkAuthToken(sessionToken); if (uid == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, UID, UPDATE_USER); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, UID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (attributes == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, UPDATE_USER); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, UPDATE_USER); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/" + uid + "/update"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), attributes, UserDetail.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);  }