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

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

public class MockDirectoryManager
extends Object
implements DirectoryManager


Constructor Summary
MockDirectoryManager(PermissionManager permissionManager, com.atlassian.event.api.EventPublisher eventPublisher, DirectoryInstanceLoader directoryInstanceLoader, DirectorySynchroniser directorySynchroniser, DirectoryPollerManager directoryPollerManager, DirectoryLockManager directoryLockManager)
           
 
Method Summary
 BulkAddResult<Group> addAllGroups(long directoryId, Collection<GroupTemplate> groups, boolean overwrite)
           
 BulkAddResult<User> addAllUsers(long directoryId, Collection<UserTemplateWithCredentialAndAttributes> users, boolean overwrite)
           
 BulkAddResult<String> addAllUsersToGroup(long directoryID, Collection<String> userNames, String groupName)
           
 com.atlassian.crowd.embedded.api.Directory addDirectory(com.atlassian.crowd.embedded.api.Directory directory)
           
 Group addGroup(long directoryId, GroupTemplate group)
           
 void addGroupToGroup(long directoryId, String childGroup, String parentGroup)
           
 User addUser(long directoryId, UserTemplate user, com.atlassian.crowd.embedded.api.PasswordCredential credential)
           
 void addUserToGroup(long directoryId, String username, String groupName)
           
 User authenticateUser(long directoryId, String username, com.atlassian.crowd.embedded.api.PasswordCredential passwordCredential)
           
 List<com.atlassian.crowd.embedded.api.Directory> findAllDirectories()
           
 com.atlassian.crowd.embedded.api.Directory findDirectoryById(long directoryID)
           
 com.atlassian.crowd.embedded.api.Directory findDirectoryByName(String name)
           
 Group findGroupByName(long directoryId, String groupName)
           
 GroupWithAttributes findGroupWithAttributesByName(long directoryId, String groupName)
           
 User findUserByName(long directoryId, String username)
           
 UserWithAttributes findUserWithAttributesByName(long directoryId, String username)
           
 com.atlassian.crowd.embedded.api.DirectorySynchronisationInformation getDirectorySynchronisationInformation(long directoryId)
           
 boolean isGroupDirectGroupMember(long directoryId, String childGroup, String parentGroup)
           
 boolean isGroupNestedGroupMember(long directoryId, String childGroup, String parentGroup)
           
 boolean isSynchronisable(long directoryId)
           
 boolean isSynchronising(long directoryId)
           
 boolean isUserDirectGroupMember(long directoryId, String username, String groupName)
           
 boolean isUserNestedGroupMember(long directoryId, String username, String groupName)
           
 void removeDirectory(com.atlassian.crowd.embedded.api.Directory directory)
           
 void removeGroup(long directoryId, String groupName)
           
 void removeGroupAttributes(long directoryId, String groupName, String attributeName)
           
 void removeGroupFromGroup(long directoryId, String childGroup, String parentGroup)
           
 void removeUser(long directoryId, String username)
           
 void removeUserAttributes(long directoryId, String username, String attributeName)
           
 void removeUserFromGroup(long directoryId, String username, String groupName)
           
 Group renameGroup(long directoryId, String oldGroupname, String newGroupname)
           
 User renameUser(long directoryId, String oldUsername, String newUsername)
           
 void resetPassword(long directoryId, String username)
           
<T> List<T>
searchDirectGroupRelationships(long directoryId, MembershipQuery<T> query)
           
 List<com.atlassian.crowd.embedded.api.Directory> searchDirectories(EntityQuery<com.atlassian.crowd.embedded.api.Directory> query)
           
<T> List<T>
searchGroups(long directoryId, EntityQuery<T> query)
           
<T> List<T>
searchNestedGroupRelationships(long directoryId, MembershipQuery<T> query)
           
<T> List<T>
searchUsers(long directoryId, EntityQuery<T> query)
           
 void setDirectory(com.atlassian.crowd.embedded.api.Directory directory)
           
 void storeGroupAttributes(long directoryId, String groupName, Map<String,Set<String>> attributes)
           
 void storeUserAttributes(long directoryId, String username, Map<String,Set<String>> attributes)
           
 boolean supportsNestedGroups(long directoryId)
           
 void synchroniseCache(long directoryId, SynchronisationMode mode)
           
 void synchroniseCache(long directoryId, SynchronisationMode mode, boolean runInBackground)
           
 com.atlassian.crowd.embedded.api.Directory updateDirectory(com.atlassian.crowd.embedded.api.Directory directory)
           
 Group updateGroup(long directoryId, GroupTemplate group)
           
 User updateUser(long directoryId, UserTemplate user)
           
 void updateUserCredential(long directoryId, String username, com.atlassian.crowd.embedded.api.PasswordCredential credential)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockDirectoryManager

public MockDirectoryManager(PermissionManager permissionManager,
                            com.atlassian.event.api.EventPublisher eventPublisher,
                            DirectoryInstanceLoader directoryInstanceLoader,
                            DirectorySynchroniser directorySynchroniser,
                            DirectoryPollerManager directoryPollerManager,
                            DirectoryLockManager directoryLockManager)
Method Detail

setDirectory

public void setDirectory(com.atlassian.crowd.embedded.api.Directory directory)

addDirectory

public com.atlassian.crowd.embedded.api.Directory addDirectory(com.atlassian.crowd.embedded.api.Directory directory)
                                                        throws DirectoryInstantiationException
Specified by:
addDirectory in interface DirectoryManager
Throws:
DirectoryInstantiationException

findDirectoryById

public com.atlassian.crowd.embedded.api.Directory findDirectoryById(long directoryID)
                                                             throws DirectoryNotFoundException
Specified by:
findDirectoryById in interface DirectoryManager
Throws:
DirectoryNotFoundException

findAllDirectories

public List<com.atlassian.crowd.embedded.api.Directory> findAllDirectories()
Specified by:
findAllDirectories in interface DirectoryManager

searchDirectories

public List<com.atlassian.crowd.embedded.api.Directory> searchDirectories(EntityQuery<com.atlassian.crowd.embedded.api.Directory> query)
Specified by:
searchDirectories in interface DirectoryManager

findDirectoryByName

public com.atlassian.crowd.embedded.api.Directory findDirectoryByName(String name)
                                                               throws DirectoryNotFoundException
Specified by:
findDirectoryByName in interface DirectoryManager
Throws:
DirectoryNotFoundException

updateDirectory

public com.atlassian.crowd.embedded.api.Directory updateDirectory(com.atlassian.crowd.embedded.api.Directory directory)
                                                           throws DirectoryNotFoundException
Specified by:
updateDirectory in interface DirectoryManager
Throws:
DirectoryNotFoundException

removeDirectory

public void removeDirectory(com.atlassian.crowd.embedded.api.Directory directory)
                     throws DirectoryNotFoundException,
                            DirectoryCurrentlySynchronisingException
Specified by:
removeDirectory in interface DirectoryManager
Throws:
DirectoryNotFoundException
DirectoryCurrentlySynchronisingException

authenticateUser

public User authenticateUser(long directoryId,
                             String username,
                             com.atlassian.crowd.embedded.api.PasswordCredential passwordCredential)
                      throws OperationFailedException,
                             InactiveAccountException,
                             InvalidAuthenticationException,
                             ExpiredCredentialException,
                             DirectoryNotFoundException,
                             UserNotFoundException
Specified by:
authenticateUser in interface DirectoryManager
Throws:
OperationFailedException
InactiveAccountException
InvalidAuthenticationException
ExpiredCredentialException
DirectoryNotFoundException
UserNotFoundException

findUserByName

public User findUserByName(long directoryId,
                           String username)
                    throws DirectoryNotFoundException,
                           UserNotFoundException,
                           OperationFailedException
Specified by:
findUserByName in interface DirectoryManager
Throws:
DirectoryNotFoundException
UserNotFoundException
OperationFailedException

findUserWithAttributesByName

public UserWithAttributes findUserWithAttributesByName(long directoryId,
                                                       String username)
                                                throws DirectoryNotFoundException,
                                                       UserNotFoundException,
                                                       OperationFailedException
Specified by:
findUserWithAttributesByName in interface DirectoryManager
Throws:
DirectoryNotFoundException
UserNotFoundException
OperationFailedException

searchUsers

public <T> List<T> searchUsers(long directoryId,
                               EntityQuery<T> query)
                    throws DirectoryNotFoundException,
                           OperationFailedException
Specified by:
searchUsers in interface DirectoryManager
Throws:
DirectoryNotFoundException
OperationFailedException

addUser

public User addUser(long directoryId,
                    UserTemplate user,
                    com.atlassian.crowd.embedded.api.PasswordCredential credential)
             throws InvalidCredentialException,
                    InvalidUserException,
                    DirectoryPermissionException,
                    DirectoryNotFoundException,
                    OperationFailedException,
                    UserAlreadyExistsException
Specified by:
addUser in interface DirectoryManager
Throws:
InvalidCredentialException
InvalidUserException
DirectoryPermissionException
DirectoryNotFoundException
OperationFailedException
UserAlreadyExistsException

updateUser

public User updateUser(long directoryId,
                       UserTemplate user)
                throws DirectoryNotFoundException,
                       UserNotFoundException,
                       DirectoryPermissionException,
                       InvalidUserException,
                       OperationFailedException
Specified by:
updateUser in interface DirectoryManager
Throws:
DirectoryNotFoundException
UserNotFoundException
DirectoryPermissionException
InvalidUserException
OperationFailedException

renameUser

public User renameUser(long directoryId,
                       String oldUsername,
                       String newUsername)
                throws DirectoryNotFoundException,
                       UserNotFoundException,
                       OperationFailedException,
                       DirectoryPermissionException,
                       InvalidUserException,
                       UserAlreadyExistsException
Specified by:
renameUser in interface DirectoryManager
Throws:
DirectoryNotFoundException
UserNotFoundException
OperationFailedException
DirectoryPermissionException
InvalidUserException
UserAlreadyExistsException

storeUserAttributes

public void storeUserAttributes(long directoryId,
                                String username,
                                Map<String,Set<String>> attributes)
                         throws DirectoryPermissionException,
                                DirectoryNotFoundException,
                                UserNotFoundException,
                                OperationFailedException
Specified by:
storeUserAttributes in interface DirectoryManager
Throws:
DirectoryPermissionException
DirectoryNotFoundException
UserNotFoundException
OperationFailedException

removeUserAttributes

public void removeUserAttributes(long directoryId,
                                 String username,
                                 String attributeName)
                          throws DirectoryPermissionException,
                                 DirectoryNotFoundException,
                                 UserNotFoundException,
                                 OperationFailedException
Specified by:
removeUserAttributes in interface DirectoryManager
Throws:
DirectoryPermissionException
DirectoryNotFoundException
UserNotFoundException
OperationFailedException

updateUserCredential

public void updateUserCredential(long directoryId,
                                 String username,
                                 com.atlassian.crowd.embedded.api.PasswordCredential credential)
                          throws DirectoryPermissionException,
                                 InvalidCredentialException,
                                 DirectoryNotFoundException,
                                 UserNotFoundException,
                                 OperationFailedException
Specified by:
updateUserCredential in interface DirectoryManager
Throws:
DirectoryPermissionException
InvalidCredentialException
DirectoryNotFoundException
UserNotFoundException
OperationFailedException

resetPassword

public void resetPassword(long directoryId,
                          String username)
                   throws DirectoryNotFoundException,
                          UserNotFoundException,
                          InvalidEmailAddressException,
                          DirectoryPermissionException,
                          InvalidCredentialException,
                          OperationFailedException
Specified by:
resetPassword in interface DirectoryManager
Throws:
DirectoryNotFoundException
UserNotFoundException
InvalidEmailAddressException
DirectoryPermissionException
InvalidCredentialException
OperationFailedException

removeUser

public void removeUser(long directoryId,
                       String username)
                throws DirectoryNotFoundException,
                       UserNotFoundException,
                       DirectoryPermissionException,
                       OperationFailedException
Specified by:
removeUser in interface DirectoryManager
Throws:
DirectoryNotFoundException
UserNotFoundException
DirectoryPermissionException
OperationFailedException

findGroupByName

public Group findGroupByName(long directoryId,
                             String groupName)
                      throws GroupNotFoundException,
                             DirectoryNotFoundException,
                             OperationFailedException
Specified by:
findGroupByName in interface DirectoryManager
Throws:
GroupNotFoundException
DirectoryNotFoundException
OperationFailedException

findGroupWithAttributesByName

public GroupWithAttributes findGroupWithAttributesByName(long directoryId,
                                                         String groupName)
                                                  throws GroupNotFoundException,
                                                         DirectoryNotFoundException,
                                                         OperationFailedException
Specified by:
findGroupWithAttributesByName in interface DirectoryManager
Throws:
GroupNotFoundException
DirectoryNotFoundException
OperationFailedException

searchGroups

public <T> List<T> searchGroups(long directoryId,
                                EntityQuery<T> query)
                     throws DirectoryNotFoundException,
                            OperationFailedException
Specified by:
searchGroups in interface DirectoryManager
Throws:
DirectoryNotFoundException
OperationFailedException

addGroup

public Group addGroup(long directoryId,
                      GroupTemplate group)
               throws InvalidGroupException,
                      DirectoryPermissionException,
                      DirectoryNotFoundException,
                      OperationFailedException
Specified by:
addGroup in interface DirectoryManager
Throws:
InvalidGroupException
DirectoryPermissionException
DirectoryNotFoundException
OperationFailedException

updateGroup

public Group updateGroup(long directoryId,
                         GroupTemplate group)
                  throws GroupNotFoundException,
                         DirectoryNotFoundException,
                         DirectoryPermissionException,
                         InvalidGroupException,
                         OperationFailedException,
                         ReadOnlyGroupException
Specified by:
updateGroup in interface DirectoryManager
Throws:
GroupNotFoundException
DirectoryNotFoundException
DirectoryPermissionException
InvalidGroupException
OperationFailedException
ReadOnlyGroupException

renameGroup

public Group renameGroup(long directoryId,
                         String oldGroupname,
                         String newGroupname)
                  throws GroupNotFoundException,
                         DirectoryNotFoundException,
                         DirectoryPermissionException,
                         InvalidGroupException,
                         OperationFailedException
Specified by:
renameGroup in interface DirectoryManager
Throws:
GroupNotFoundException
DirectoryNotFoundException
DirectoryPermissionException
InvalidGroupException
OperationFailedException

storeGroupAttributes

public void storeGroupAttributes(long directoryId,
                                 String groupName,
                                 Map<String,Set<String>> attributes)
                          throws DirectoryPermissionException,
                                 GroupNotFoundException,
                                 DirectoryNotFoundException,
                                 OperationFailedException
Specified by:
storeGroupAttributes in interface DirectoryManager
Throws:
DirectoryPermissionException
GroupNotFoundException
DirectoryNotFoundException
OperationFailedException

removeGroupAttributes

public void removeGroupAttributes(long directoryId,
                                  String groupName,
                                  String attributeName)
                           throws DirectoryPermissionException,
                                  GroupNotFoundException,
                                  DirectoryNotFoundException,
                                  OperationFailedException
Specified by:
removeGroupAttributes in interface DirectoryManager
Throws:
DirectoryPermissionException
GroupNotFoundException
DirectoryNotFoundException
OperationFailedException

removeGroup

public void removeGroup(long directoryId,
                        String groupName)
                 throws GroupNotFoundException,
                        DirectoryNotFoundException,
                        DirectoryPermissionException,
                        OperationFailedException,
                        ReadOnlyGroupException
Specified by:
removeGroup in interface DirectoryManager
Throws:
GroupNotFoundException
DirectoryNotFoundException
DirectoryPermissionException
OperationFailedException
ReadOnlyGroupException

isUserDirectGroupMember

public boolean isUserDirectGroupMember(long directoryId,
                                       String username,
                                       String groupName)
                                throws DirectoryNotFoundException,
                                       OperationFailedException
Specified by:
isUserDirectGroupMember in interface DirectoryManager
Throws:
DirectoryNotFoundException
OperationFailedException

isGroupDirectGroupMember

public boolean isGroupDirectGroupMember(long directoryId,
                                        String childGroup,
                                        String parentGroup)
                                 throws DirectoryNotFoundException,
                                        OperationFailedException
Specified by:
isGroupDirectGroupMember in interface DirectoryManager
Throws:
DirectoryNotFoundException
OperationFailedException

addUserToGroup

public void addUserToGroup(long directoryId,
                           String username,
                           String groupName)
                    throws DirectoryPermissionException,
                           DirectoryNotFoundException,
                           UserNotFoundException,
                           GroupNotFoundException,
                           OperationFailedException,
                           ReadOnlyGroupException,
                           MembershipAlreadyExistsException
Specified by:
addUserToGroup in interface DirectoryManager
Throws:
DirectoryPermissionException
DirectoryNotFoundException
UserNotFoundException
GroupNotFoundException
OperationFailedException
ReadOnlyGroupException
MembershipAlreadyExistsException

addGroupToGroup

public void addGroupToGroup(long directoryId,
                            String childGroup,
                            String parentGroup)
                     throws DirectoryPermissionException,
                            DirectoryNotFoundException,
                            GroupNotFoundException,
                            InvalidMembershipException,
                            NestedGroupsNotSupportedException,
                            OperationFailedException,
                            ReadOnlyGroupException,
                            MembershipAlreadyExistsException
Specified by:
addGroupToGroup in interface DirectoryManager
Throws:
DirectoryPermissionException
DirectoryNotFoundException
GroupNotFoundException
InvalidMembershipException
NestedGroupsNotSupportedException
OperationFailedException
ReadOnlyGroupException
MembershipAlreadyExistsException

removeUserFromGroup

public void removeUserFromGroup(long directoryId,
                                String username,
                                String groupName)
                         throws DirectoryPermissionException,
                                DirectoryNotFoundException,
                                UserNotFoundException,
                                GroupNotFoundException,
                                MembershipNotFoundException,
                                OperationFailedException,
                                ReadOnlyGroupException
Specified by:
removeUserFromGroup in interface DirectoryManager
Throws:
DirectoryPermissionException
DirectoryNotFoundException
UserNotFoundException
GroupNotFoundException
MembershipNotFoundException
OperationFailedException
ReadOnlyGroupException

removeGroupFromGroup

public void removeGroupFromGroup(long directoryId,
                                 String childGroup,
                                 String parentGroup)
                          throws DirectoryPermissionException,
                                 GroupNotFoundException,
                                 DirectoryNotFoundException,
                                 InvalidMembershipException,
                                 MembershipNotFoundException,
                                 OperationFailedException,
                                 ReadOnlyGroupException
Specified by:
removeGroupFromGroup in interface DirectoryManager
Throws:
DirectoryPermissionException
GroupNotFoundException
DirectoryNotFoundException
InvalidMembershipException
MembershipNotFoundException
OperationFailedException
ReadOnlyGroupException

searchDirectGroupRelationships

public <T> List<T> searchDirectGroupRelationships(long directoryId,
                                                  MembershipQuery<T> query)
                                       throws DirectoryNotFoundException,
                                              OperationFailedException
Specified by:
searchDirectGroupRelationships in interface DirectoryManager
Throws:
DirectoryNotFoundException
OperationFailedException

isUserNestedGroupMember

public boolean isUserNestedGroupMember(long directoryId,
                                       String username,
                                       String groupName)
                                throws DirectoryNotFoundException,
                                       OperationFailedException
Specified by:
isUserNestedGroupMember in interface DirectoryManager
Throws:
DirectoryNotFoundException
OperationFailedException

isGroupNestedGroupMember

public boolean isGroupNestedGroupMember(long directoryId,
                                        String childGroup,
                                        String parentGroup)
                                 throws DirectoryNotFoundException,
                                        OperationFailedException
Specified by:
isGroupNestedGroupMember in interface DirectoryManager
Throws:
DirectoryNotFoundException
OperationFailedException

searchNestedGroupRelationships

public <T> List<T> searchNestedGroupRelationships(long directoryId,
                                                  MembershipQuery<T> query)
                                       throws DirectoryNotFoundException,
                                              OperationFailedException
Specified by:
searchNestedGroupRelationships in interface DirectoryManager
Throws:
DirectoryNotFoundException
OperationFailedException

addAllUsers

public BulkAddResult<User> addAllUsers(long directoryId,
                                       Collection<UserTemplateWithCredentialAndAttributes> users,
                                       boolean overwrite)
                                throws DirectoryPermissionException,
                                       DirectoryNotFoundException,
                                       OperationFailedException
Specified by:
addAllUsers in interface DirectoryManager
Throws:
DirectoryPermissionException
DirectoryNotFoundException
OperationFailedException

addAllGroups

public BulkAddResult<Group> addAllGroups(long directoryId,
                                         Collection<GroupTemplate> groups,
                                         boolean overwrite)
                                  throws DirectoryPermissionException,
                                         DirectoryNotFoundException,
                                         OperationFailedException,
                                         InvalidGroupException
Specified by:
addAllGroups in interface DirectoryManager
Throws:
DirectoryPermissionException
DirectoryNotFoundException
OperationFailedException
InvalidGroupException

addAllUsersToGroup

public BulkAddResult<String> addAllUsersToGroup(long directoryID,
                                                Collection<String> userNames,
                                                String groupName)
                                         throws DirectoryPermissionException,
                                                DirectoryNotFoundException,
                                                GroupNotFoundException,
                                                OperationFailedException
Specified by:
addAllUsersToGroup in interface DirectoryManager
Throws:
DirectoryPermissionException
DirectoryNotFoundException
GroupNotFoundException
OperationFailedException

supportsNestedGroups

public boolean supportsNestedGroups(long directoryId)
                             throws DirectoryInstantiationException,
                                    DirectoryNotFoundException
Specified by:
supportsNestedGroups in interface DirectoryManager
Throws:
DirectoryInstantiationException
DirectoryNotFoundException

isSynchronisable

public boolean isSynchronisable(long directoryId)
                         throws DirectoryInstantiationException,
                                DirectoryNotFoundException
Specified by:
isSynchronisable in interface DirectoryManager
Throws:
DirectoryInstantiationException
DirectoryNotFoundException

synchroniseCache

public void synchroniseCache(long directoryId,
                             SynchronisationMode mode)
                      throws OperationFailedException,
                             DirectoryNotFoundException
Specified by:
synchroniseCache in interface DirectoryManager
Throws:
OperationFailedException
DirectoryNotFoundException

synchroniseCache

public void synchroniseCache(long directoryId,
                             SynchronisationMode mode,
                             boolean runInBackground)
                      throws OperationFailedException,
                             DirectoryNotFoundException
Specified by:
synchroniseCache in interface DirectoryManager
Throws:
OperationFailedException
DirectoryNotFoundException

isSynchronising

public boolean isSynchronising(long directoryId)
                        throws DirectoryInstantiationException,
                               DirectoryNotFoundException
Specified by:
isSynchronising in interface DirectoryManager
Throws:
DirectoryInstantiationException
DirectoryNotFoundException

getDirectorySynchronisationInformation

public com.atlassian.crowd.embedded.api.DirectorySynchronisationInformation getDirectorySynchronisationInformation(long directoryId)
                                                                                                            throws DirectoryInstantiationException,
                                                                                                                   DirectoryNotFoundException
Specified by:
getDirectorySynchronisationInformation in interface DirectoryManager
Throws:
DirectoryInstantiationException
DirectoryNotFoundException


Copyright © 2014 Atlassian. All Rights Reserved.