com.atlassian.jira.security.groups
Class MockGroupManager

java.lang.Object
  extended by com.atlassian.jira.security.groups.MockGroupManager
All Implemented Interfaces:
GroupManager

public class MockGroupManager
extends Object
implements GroupManager

Since:
v4.3

Constructor Summary
MockGroupManager()
           
 
Method Summary
 void addGroup(String groupName)
           
 void addMember(String groupName, String userName)
           
 void addUserToGroup(com.atlassian.crowd.embedded.api.User user, com.atlassian.crowd.embedded.api.Group group)
          Adds a user as a member of a group.
 com.atlassian.crowd.embedded.api.Group createGroup(String groupName)
          Create a group with the given name.
 Collection<com.atlassian.crowd.embedded.api.Group> getAllGroups()
          Get all groups.
 Collection<com.atlassian.crowd.embedded.api.User> getDirectUsersInGroup(com.atlassian.crowd.embedded.api.Group group)
          Returns all the users that are direct members of the group.
 com.atlassian.crowd.embedded.api.Group getGroup(String groupname)
          Returns the Group for this groupName, else null if no such Group exists.
 com.atlassian.crowd.embedded.api.Group getGroupEvenWhenUnknown(String groupName)
          Returns the Group for this groupName, if no such Group exists then a proxy unknown immutable Group object is returned.
 Collection<String> getGroupNamesForUser(String userName)
          Returns the names of all the groups that the given user belongs to.
 Collection<String> getGroupNamesForUser(com.atlassian.crowd.embedded.api.User user)
          Returns the names of all the groups that the given user belongs to.
 com.atlassian.crowd.embedded.api.Group getGroupObject(String groupName)
          Returns the Group for this groupName, else null if no such Group exists.
 Collection<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(String userName)
          Returns all the groups that the given user belongs to.
 Collection<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(com.atlassian.crowd.embedded.api.User user)
          Returns all the groups that the given user belongs to.
 Collection<String> getUserNamesInGroup(com.atlassian.crowd.embedded.api.Group group)
          Returns the names of all the users in a group.
 Collection<String> getUserNamesInGroup(String groupName)
          Returns the names of all the users in a group.
 Collection<com.atlassian.crowd.embedded.api.User> getUsersInGroup(com.atlassian.crowd.embedded.api.Group group)
          Returns all the users in a group.
 Collection<com.atlassian.crowd.embedded.api.User> getUsersInGroup(String groupName)
          Returns all the users in a group.
 boolean groupExists(String groupname)
          Returns true if the given group name exists.
 boolean isUserInGroup(String username, String groupname)
          Returns true if the user is a member of the group.
 boolean isUserInGroup(com.atlassian.crowd.embedded.api.User user, com.atlassian.crowd.embedded.api.Group group)
          Returns true if the user is a member of the group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockGroupManager

public MockGroupManager()
Method Detail

getAllGroups

public Collection<com.atlassian.crowd.embedded.api.Group> getAllGroups()
Description copied from interface: GroupManager
Get all groups.

Specified by:
getAllGroups in interface GroupManager
Returns:
Collection of all Groups.

groupExists

public boolean groupExists(String groupname)
Description copied from interface: GroupManager
Returns true if the given group name exists.

Specified by:
groupExists in interface GroupManager
Parameters:
groupname - The group name.
Returns:
true if the given group name exists.

createGroup

public com.atlassian.crowd.embedded.api.Group createGroup(String groupName)
Description copied from interface: GroupManager
Create a group with the given name.

Specified by:
createGroup in interface GroupManager
Parameters:
groupName - The group name.
Returns:
the newly created Group.

getGroup

public com.atlassian.crowd.embedded.api.Group getGroup(String groupname)
Description copied from interface: GroupManager
Returns the Group for this groupName, else null if no such Group exists.

Warning: previous incarnations of this method returned com.opensymphony.user.Group. This class has now been removed from the JIRA API, meaning that the 5.0 version is not binary or source compatible with earlier versions.

Specified by:
getGroup in interface GroupManager
Parameters:
groupname - The group name.
Returns:
The Group for this groupName, else null if no such Group exists.

getGroupEvenWhenUnknown

public com.atlassian.crowd.embedded.api.Group getGroupEvenWhenUnknown(String groupName)
Description copied from interface: GroupManager
Returns the Group for this groupName, if no such Group exists then a proxy unknown immutable Group object is returned.

Specified by:
getGroupEvenWhenUnknown in interface GroupManager
Parameters:
groupName - The group name.
Returns:
The Group for this groupName.

getGroupObject

public com.atlassian.crowd.embedded.api.Group getGroupObject(String groupName)
Description copied from interface: GroupManager
Returns the Group for this groupName, else null if no such Group exists.

Legacy synonym for GroupManager.getGroup(String).

Specified by:
getGroupObject in interface GroupManager
Parameters:
groupName - The group name.
Returns:
The Group for this groupName, else null if no such Group exists.
See Also:
GroupManager.getGroup(String)

isUserInGroup

public boolean isUserInGroup(String username,
                             String groupname)
Description copied from interface: GroupManager
Returns true if the user is a member of the group.

Note that if the username or groupname is null, then it will return false.

Specified by:
isUserInGroup in interface GroupManager
Parameters:
username - user to inspect.
groupname - group to inspect.
Returns:
true if and only if the user is a direct or indirect (nested) member of the group.
See Also:
GroupManager.isUserInGroup(com.atlassian.crowd.embedded.api.User, com.atlassian.crowd.embedded.api.Group)

isUserInGroup

public boolean isUserInGroup(com.atlassian.crowd.embedded.api.User user,
                             com.atlassian.crowd.embedded.api.Group group)
Description copied from interface: GroupManager
Returns true if the user is a member of the group.

Note that if the User or Group object is null, then it will return false. This was done to retain consistency with the old OSUser behaviour of User.inGroup() and Group.containsUser()

Specified by:
isUserInGroup in interface GroupManager
Parameters:
user - user to inspect.
group - group to inspect.
Returns:
true if and only if the user is a direct or indirect (nested) member of the group.
See Also:
GroupManager.isUserInGroup(String, String)

getUsersInGroup

public Collection<com.atlassian.crowd.embedded.api.User> getUsersInGroup(String groupName)
Description copied from interface: GroupManager
Returns all the users in a group.

Specified by:
getUsersInGroup in interface GroupManager
Parameters:
groupName - The group
Returns:
all the users that belongs to the group.
See Also:
#getUsersInGroup(Group)}

getUsersInGroup

public Collection<com.atlassian.crowd.embedded.api.User> getUsersInGroup(com.atlassian.crowd.embedded.api.Group group)
Description copied from interface: GroupManager
Returns all the users in a group. This will include nested group members.

Specified by:
getUsersInGroup in interface GroupManager
Parameters:
group - The group
Returns:
all the users that belongs to the group.
See Also:
#getUsersInGroup(String)}

getUserNamesInGroup

public Collection<String> getUserNamesInGroup(com.atlassian.crowd.embedded.api.Group group)
Description copied from interface: GroupManager
Returns the names of all the users in a group. This will include nested group members.

Specified by:
getUserNamesInGroup in interface GroupManager
Parameters:
group - The group
Returns:
all the users that belongs to the group.
See Also:
#getUsersInGroup(Group)}

getUserNamesInGroup

public Collection<String> getUserNamesInGroup(String groupName)
Description copied from interface: GroupManager
Returns the names of all the users in a group. This will include nested group members.

Specified by:
getUserNamesInGroup in interface GroupManager
Parameters:
groupName - The group
Returns:
all the users that belongs to the group.
See Also:
#getUsersInGroup(String)}

getDirectUsersInGroup

public Collection<com.atlassian.crowd.embedded.api.User> getDirectUsersInGroup(com.atlassian.crowd.embedded.api.Group group)
Description copied from interface: GroupManager
Returns all the users that are direct members of the group. This will NOT include nested group members.

Specified by:
getDirectUsersInGroup in interface GroupManager
Parameters:
group - The group
Returns:
all the users that belongs to the group.
See Also:
#getUsersInGroup(String)}

getGroupsForUser

public Collection<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(String userName)
Description copied from interface: GroupManager
Returns all the groups that the given user belongs to.

Specified by:
getGroupsForUser in interface GroupManager
Parameters:
userName - The user
Returns:
all the groups that the given user belongs to.
See Also:
GroupManager.getGroupNamesForUser(String)

getGroupsForUser

public Collection<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(com.atlassian.crowd.embedded.api.User user)
Description copied from interface: GroupManager
Returns all the groups that the given user belongs to.

Specified by:
getGroupsForUser in interface GroupManager
Parameters:
user - The user
Returns:
all the groups that the given user belongs to.
See Also:
GroupManager.getGroupNamesForUser(String)

getGroupNamesForUser

public Collection<String> getGroupNamesForUser(String userName)
Description copied from interface: GroupManager
Returns the names of all the groups that the given user belongs to.

Specified by:
getGroupNamesForUser in interface GroupManager
Parameters:
userName - The user
Returns:
all the groups that the given user belongs to.
See Also:
GroupManager.getGroupsForUser(String)

getGroupNamesForUser

public Collection<String> getGroupNamesForUser(com.atlassian.crowd.embedded.api.User user)
Description copied from interface: GroupManager
Returns the names of all the groups that the given user belongs to.

Specified by:
getGroupNamesForUser in interface GroupManager
Parameters:
user - The user
Returns:
all the groups that the given user belongs to.
See Also:
GroupManager.getGroupsForUser(String)

addUserToGroup

public void addUserToGroup(com.atlassian.crowd.embedded.api.User user,
                           com.atlassian.crowd.embedded.api.Group group)
Description copied from interface: GroupManager
Adds a user as a member of a group.

Specified by:
addUserToGroup in interface GroupManager
Parameters:
user - The user that will become a member of the group.
group - The group that will gain a new member.

addGroup

public void addGroup(String groupName)

addMember

public void addMember(String groupName,
                      String userName)


Copyright © 2002-2013 Atlassian. All Rights Reserved.