com.atlassian.sal.testresources.usersettings
Class MockUserSettingsService

java.lang.Object
  extended by com.atlassian.sal.testresources.usersettings.MockUserSettingsService
All Implemented Interfaces:
UserSettingsService

public class MockUserSettingsService
extends Object
implements UserSettingsService


Field Summary
 
Fields inherited from interface com.atlassian.sal.api.usersettings.UserSettingsService
MAX_KEY_LENGTH, MAX_STRING_VALUE_LENGTH, USER_SETTINGS_PREFIX
 
Constructor Summary
MockUserSettingsService()
           
 
Method Summary
 UserSettings getUserSettings(String userName)
          Gets the UserSettings for the user with name userName.
 UserSettings getUserSettings(UserKey user)
          Gets the UserSettings for the given user.
 void updateUserSettings(String userName, com.google.common.base.Function<UserSettingsBuilder,UserSettings> updateFunction)
          Updates the UserSettings stored for this user with name UserName.
 void updateUserSettings(UserKey user, com.google.common.base.Function<UserSettingsBuilder,UserSettings> updateFunction)
          Updates the UserSettings stored for this user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockUserSettingsService

public MockUserSettingsService()
Method Detail

getUserSettings

public UserSettings getUserSettings(String userName)
Description copied from interface: UserSettingsService
Gets the UserSettings for the user with name userName.

Specified by:
getUserSettings in interface UserSettingsService
Parameters:
userName - name of the user whose user settings are to be retrieved
Returns:
a UserSettings for the user with name userName,

getUserSettings

public UserSettings getUserSettings(UserKey user)
Description copied from interface: UserSettingsService
Gets the UserSettings for the given user.

Specified by:
getUserSettings in interface UserSettingsService
Parameters:
user - key of a user whose user settings are to be retrieved
Returns:
a UserSettings for the user with name userName,

updateUserSettings

public void updateUserSettings(String userName,
                               com.google.common.base.Function<UserSettingsBuilder,UserSettings> updateFunction)
Description copied from interface: UserSettingsService
Updates the UserSettings stored for this user with name UserName. Implementations of this interface will ensure that updateFunctions provided to this method are called in a threadsafe manner. Consumers can throw RuntimeExceptions within updateFunction to control flow when the input to updateFunction is unexpected. As such, implementers must either rethrow caught RuntimeExceptions, or not catch them in the first place. The intended behaviour of this function is that the return value of updateFunction be stored against the specified user. However, product implementations do not do this, and update the user settings in the underlying database in response to calls to the UserSettingsBuilder provided to updateFunction, and ignore the return value from updateFunction.

Specified by:
updateUserSettings in interface UserSettingsService
Parameters:
userName - name of the user whose UserSettings are to be updated. If userName does not match a known user, updateFunction will not be called.
updateFunction - function to update a user's UserSettings. The parameter to updateFunction is a UserSettingsBuilder whose contents match the UserSettings for the provided user.

updateUserSettings

public void updateUserSettings(UserKey user,
                               com.google.common.base.Function<UserSettingsBuilder,UserSettings> updateFunction)
Description copied from interface: UserSettingsService
Updates the UserSettings stored for this user. Implementations of this interface will ensure that updateFunctions provided to this method are called in a threadsafe manner. Consumers can throw RuntimeExceptions within updateFunction to control flow when the input to updateFunction is unexpected. As such, implementers must either rethrow caught RuntimeExceptions, or not catch them in the first place. The intended behaviour of this function is that the return value of updateFunction be stored against the specified user. However, product implementations do not do this, and update the user settings in the underlying database in response to calls to the UserSettingsBuilder provided to updateFunction, and ignore the return value from updateFunction. This function will be deprecated in a future version of SAL with replacements with a more appropriate signature, or the intended behaviour, or both.

Specified by:
updateUserSettings in interface UserSettingsService
Parameters:
user - key of a user whose UserSettings are to be updated. If user is null or does not exist updateFunction will not be called.
updateFunction - function to update a user's UserSettings. The parameter to updateFunction is a UserSettingsBuilder whose contents match the UserSettings for the provided user.


Copyright © 2015 Atlassian. All rights reserved.