com.atlassian.crowd.acceptance.tests.directory
Class MockDirectoryManager

java.lang.Object
  extended by com.atlassian.crowd.manager.directory.DirectoryManagerGeneric
      extended by com.atlassian.crowd.acceptance.tests.directory.MockDirectoryManager
All Implemented Interfaces:
DirectoryManager

public class MockDirectoryManager
extends DirectoryManagerGeneric
implements DirectoryManager


Constructor Summary
MockDirectoryManager()
           
 
Method Summary
 Directory addDirectory(Directory directory)
          Adds the given directory.
 java.util.List<Directory> findAllDirectories()
          Returns a List of all directories in the system.
 Directory findDirectoryById(long directoryID)
          This is the only implemented method.
 Directory findDirectoryByName(java.lang.String name)
          Finds a directory given the supplied name.
 User findUserByToken(java.lang.String key)
          Will find a user via the passed in token key.
 void invalidateToken(java.lang.String token)
          Attempts to invalidate a Token based on the passed in Token key (random hash).
 void removeDirectory(Directory directory)
          Removes a given directory and all its associated entities and mappings.
 void removeExpiredTokens()
          Removes all tokens that have exceeded their expiry time.
 java.util.List<Directory> searchDirectories(EntityQuery query)
          Returns a List of Directories matching the search query.
 java.util.List<Token> searchTokens(EntityQuery query)
          Returns a list of users matching the given query.
 void setDirectory(Directory directory)
           
 Directory updateDirectory(Directory directory)
          Updates the passed in directory.
 
Methods inherited from class com.atlassian.crowd.manager.directory.DirectoryManagerGeneric
addAllGroups, addAllUsers, addAllUsersToGroup, addGroup, addGroupToGroup, addUser, addUserToGroup, findGroupByName, findGroupWithAttributesByName, findUserByName, findUserWithAttributesByName, isGroupDirectGroupMember, isGroupNestedGroupMember, isUserDirectGroupMember, isUserNestedGroupMember, removeGroup, removeGroupAttributes, removeGroupFromGroup, removeUser, removeUserAttributes, removeUserFromGroup, renameGroup, renameUser, resetPassword, searchDirectGroupRelationships, searchGroups, searchNestedGroupRelationships, searchUsers, setApplicationDAO, setDirectoryDAO, setEventManager, setI18nHelper, setPasswordHelper, setPermissionManager, setPropertyManager, setTokenDAO, storeGroupAttributes, storeUserAttributes, updateGroup, updateUser, updateUserCredential
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.crowd.manager.directory.DirectoryManager
addAllGroups, addAllUsers, addAllUsersToGroup, addGroup, addGroupToGroup, addUser, addUserToGroup, findGroupByName, findGroupWithAttributesByName, findUserByName, findUserWithAttributesByName, isGroupDirectGroupMember, isGroupNestedGroupMember, isUserDirectGroupMember, isUserNestedGroupMember, removeGroup, removeGroupAttributes, removeGroupFromGroup, removeUser, removeUserAttributes, removeUserFromGroup, renameGroup, renameUser, resetPassword, searchDirectGroupRelationships, searchGroups, searchNestedGroupRelationships, searchUsers, storeGroupAttributes, storeUserAttributes, updateGroup, updateUser, updateUserCredential
 

Constructor Detail

MockDirectoryManager

public MockDirectoryManager()
Method Detail

setDirectory

public void setDirectory(Directory directory)

addDirectory

public Directory addDirectory(Directory directory)
                       throws DirectoryInstantiationException
Description copied from interface: DirectoryManager
Adds the given directory.

Specified by:
addDirectory in interface DirectoryManager
Overrides:
addDirectory in class DirectoryManagerGeneric
Parameters:
directory - the Directory to add
Returns:
the added Directory
Throws:
DirectoryInstantiationException - if there was an error instantiating the directory

findDirectoryById

public Directory findDirectoryById(long directoryID)
                            throws ObjectNotFoundException
This is the only implemented method. Will always return directory.

Specified by:
findDirectoryById in interface DirectoryManager
Overrides:
findDirectoryById in class DirectoryManagerGeneric
Parameters:
directoryID -
Returns:
Throws:
ObjectNotFoundException

findAllDirectories

public java.util.List<Directory> findAllDirectories()
Description copied from interface: DirectoryManager
Returns a List of all directories in the system.

Specified by:
findAllDirectories in interface DirectoryManager
Overrides:
findAllDirectories in class DirectoryManagerGeneric
Returns:
List of all Directories.

searchDirectories

public java.util.List<Directory> searchDirectories(EntityQuery query)
Description copied from interface: DirectoryManager
Returns a List of Directories matching the search query.

Specified by:
searchDirectories in interface DirectoryManager
Overrides:
searchDirectories in class DirectoryManagerGeneric
Parameters:
query - the context to search on
Returns:
a List of directories, or an Empty List of none are found

findDirectoryByName

public Directory findDirectoryByName(java.lang.String name)
                              throws ObjectNotFoundException
Description copied from interface: DirectoryManager
Finds a directory given the supplied name.

Specified by:
findDirectoryByName in interface DirectoryManager
Overrides:
findDirectoryByName in class DirectoryManagerGeneric
Parameters:
name - the name of the directory
Returns:
the directory with the given name
Throws:
ObjectNotFoundException - if no Directory is found

updateDirectory

public Directory updateDirectory(Directory directory)
                          throws ObjectNotFoundException
Description copied from interface: DirectoryManager
Updates the passed in directory.

Specified by:
updateDirectory in interface DirectoryManager
Overrides:
updateDirectory in class DirectoryManagerGeneric
Parameters:
directory - the directory with updated attrbutes
Returns:
the updated directory
Throws:
ObjectNotFoundException - if no Directory is found

removeDirectory

public void removeDirectory(Directory directory)
                     throws ObjectNotFoundException
Description copied from interface: DirectoryManager
Removes a given directory and all its associated entities and mappings.

Specified by:
removeDirectory in interface DirectoryManager
Overrides:
removeDirectory in class DirectoryManagerGeneric
Parameters:
directory - the directory to remove
Throws:
ObjectNotFoundException - if the directory cannot be found

invalidateToken

public void invalidateToken(java.lang.String token)
Description copied from interface: DirectoryManager
Attempts to invalidate a Token based on the passed in Token key (random hash).

If the token does not exist (ie. already invalidated) this method silently returns. If an existing token is successfully invalidated, a TokenInvalidatedEvent is fired.

Specified by:
invalidateToken in interface DirectoryManager
Overrides:
invalidateToken in class DirectoryManagerGeneric
Parameters:
token - the token key (random hash) to invalidate.

searchTokens

public java.util.List<Token> searchTokens(EntityQuery query)
Description copied from interface: DirectoryManager
Returns a list of users matching the given query.

Specified by:
searchTokens in interface DirectoryManager
Overrides:
searchTokens in class DirectoryManagerGeneric
Parameters:
query - entity query for Entity.TOKEN.
Returns:
list of Token matching the search criteria.

removeExpiredTokens

public void removeExpiredTokens()
Description copied from interface: DirectoryManager
Removes all tokens that have exceeded their expiry time.

NOTE: Do not call this method from the web layer, as this is wrapped in a Spring managed transaction.

Specified by:
removeExpiredTokens in interface DirectoryManager
Overrides:
removeExpiredTokens in class DirectoryManagerGeneric

findUserByToken

public User findUserByToken(java.lang.String key)
                     throws InvalidTokenException,
                            DirectoryAccessException
Description copied from interface: DirectoryManager
Will find a user via the passed in token key.

Specified by:
findUserByToken in interface DirectoryManager
Overrides:
findUserByToken in class DirectoryManagerGeneric
Parameters:
key - the token key
Returns:
the User associated to the given token key
Throws:
InvalidTokenException - if the User or Directory cannot be found that relates to the given token, or the token is associated to an Application and not a User
DirectoryAccessException - if there was an issue accessing the user from the underlying directory


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.