@Test public void testUpdateUserAvatar() throws RemoteApiException { Map<String, String> headerParams = new HashMap<>(); headerParams.put("sessionToken", MOCK_SESSION); String path = "/v1/admin/user/" + MOCK_USER_ID + "/avatar/update"; AvatarUpdate avatarUpdate = new AvatarUpdate(); avatarUpdate.setImage("dGVzdGV0ZXN0ZXN0ZXN0ZXN0ZQ=="); apiClient.updateUserAvatar(MOCK_SESSION, MOCK_USER_ID, avatarUpdate); verify(httpClient, times(1)).doPost(path, headerParams, Collections.<String, String>emptyMap(), avatarUpdate, Map.class); }
public void updateUserAvatar(String sessionToken, Long uid, AvatarUpdate avatarUpdate) throws RemoteApiException { checkAuthToken(sessionToken); if (uid == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, UID, UPDATE_USER_AVATAR); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, UID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (avatarUpdate == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, UPDATE_USER_AVATAR); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, UPDATE_USER_AVATAR); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/" + uid + "/avatar/update"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), avatarUpdate, Map.class); }
UserApiClient extends BasePodApiClient { public void updateUserAvatar(String sessionToken, Long uid, AvatarUpdate avatarUpdate) throws RemoteApiException { checkAuthToken(sessionToken); if (uid == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, UID, UPDATE_USER_AVATAR); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, UID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (avatarUpdate == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, UPDATE_USER_AVATAR); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, UPDATE_USER_AVATAR); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/" + uid + "/avatar/update"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), avatarUpdate, Map.class); } }
UserApiClient extends BasePodApiClient { public void updateUserAvatar(String sessionToken, Long uid, AvatarUpdate avatarUpdate) throws RemoteApiException { checkAuthToken(sessionToken); if (uid == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, UID, UPDATE_USER_AVATAR); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, UID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (avatarUpdate == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, UPDATE_USER_AVATAR); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, UPDATE_USER_AVATAR); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/" + uid + "/avatar/update"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), avatarUpdate, Map.class); } UserApiClient(HttpApiClient apiClient, LogMessageSource logMessage); }
UserApiClient extends BasePodApiClient { public void updateUserAvatar(String sessionToken, Long uid, AvatarUpdate avatarUpdate) throws RemoteApiException { checkAuthToken(sessionToken); if (uid == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, UID, UPDATE_USER_AVATAR); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, UID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (avatarUpdate == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, UPDATE_USER_AVATAR); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, UPDATE_USER_AVATAR); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/" + uid + "/avatar/update"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), avatarUpdate, Map.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 void updateUserAvatar(String sessionToken, Long uid, AvatarUpdate avatarUpdate) throws RemoteApiException { checkAuthToken(sessionToken); if (uid == null) { String reason = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING, UID, UPDATE_USER_AVATAR); String solution = logMessage.getMessage(MISSING_PARAMETER_WHEN_CALLING_SOLUTION, UID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (avatarUpdate == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, UPDATE_USER_AVATAR); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, UPDATE_USER_AVATAR); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/" + uid + "/avatar/update"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), avatarUpdate, Map.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);  }