Class MockGroupManager
java.lang.Object
com.atlassian.jira.security.groups.MockGroupManager
- All Implemented Interfaces:
GroupManager
- Since:
- v4.3
-
Constructor Summary
ConstructorDescriptionMockGroupManager
(com.atlassian.crowd.embedded.api.CrowdService crowdService) -
Method Summary
Modifier and TypeMethodDescriptionaddGroup
(com.atlassian.crowd.embedded.api.Group group) com.atlassian.crowd.embedded.api.Group
void
void
addUserToGroup
(ApplicationUser 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.filterUsersInAllGroupsDirect
(Collection<String> userNames, Collection<String> groupNames) Returns a collection of user names for the users that are direct members of every one of the supplied groups.Returns the names of all groups or an empty collection if there are no groups.Collection<com.atlassian.crowd.embedded.api.Group>
Get all groups.Deprecated.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
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.Returns the names of all the groups that the given user belongs to.getGroupNamesForUser
(String userName) 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>
Returns all the groups that the given user belongs to.Collection<com.atlassian.crowd.embedded.api.Group>
getGroupsForUser
(String userName) Returns all the groups that the given user belongs to.getNamesOfDirectMembersOfGroups
(Collection<String> groupNames, int limit) Returns a list of all active user names that are direct members in at least one of the supplied groups.getUserNamesInGroup
(com.atlassian.crowd.embedded.api.Group group) Returns the names of all the users in a group.getUserNamesInGroup
(String groupName) Returns the names of all the users in a group.getUserNamesInGroups
(Collection<com.atlassian.crowd.embedded.api.Group> groups) Returns the names of all the users in a collection of groups.getUsersInGroup
(com.atlassian.crowd.embedded.api.Group group) Returns all the users in a group.getUsersInGroup
(String groupName) Returns all the users in a group.getUsersInGroup
(String groupName, Boolean includeInactive) Returns all the users in a group.getUsersInGroup
(String groupName, Boolean active, PageRequest pageRequest) Returns a page with users in a group.int
getUsersInGroupCount
(com.atlassian.crowd.embedded.api.Group group) Returns a count of all active users in a group.int
getUsersInGroupCount
(String groupName) Returns a count of all active users in a group.boolean
groupExists
(com.atlassian.crowd.embedded.api.Group group) Returnstrue
if the given group exists.boolean
groupExists
(String groupName) Returnstrue
if the given group name exists.boolean
isUserInGroup
(ApplicationUser user, com.atlassian.crowd.embedded.api.Group group) Returnstrue
if the user is a member of the group.boolean
isUserInGroup
(ApplicationUser user, String groupName) Returnstrue
if the user is a member of the named group.boolean
isUserInGroup
(String username, String groupName) Returnstrue
if the user is a member of the group.boolean
isUserInGroups
(ApplicationUser user, Set<String> groupNames) Returnstrue
if the user is a member of at least one of the named groups.setUserMembership
(ApplicationUser user, com.atlassian.crowd.embedded.api.Group... groups) <T extends Exception>
voidthrowExceptionOnCreateGroup
(String groupName, Exception cause)
-
Constructor Details
-
MockGroupManager
public MockGroupManager() -
MockGroupManager
public MockGroupManager(com.atlassian.crowd.embedded.api.CrowdService crowdService)
-
-
Method Details
-
getAllGroups
Description copied from interface:GroupManager
Get all groups.- Specified by:
getAllGroups
in interfaceGroupManager
- Returns:
- Collection of all Groups.
-
groupExists
Description copied from interface:GroupManager
Returnstrue
if the given group name exists.- Specified by:
groupExists
in interfaceGroupManager
- Parameters:
groupName
- The group name.- Returns:
true
if the given group name exists.
-
groupExists
public boolean groupExists(@Nonnull com.atlassian.crowd.embedded.api.Group group) Description copied from interface:GroupManager
Returnstrue
if the given group exists.- Specified by:
groupExists
in interfaceGroupManager
- Parameters:
group
- The group.- Returns:
true
if the given group exists.
-
createGroup
Description copied from interface:GroupManager
Create a group with the given name.- Specified by:
createGroup
in interfaceGroupManager
- Parameters:
groupName
- The group name.- Returns:
- the newly created Group.
-
throwExceptionOnCreateGroup
-
getGroup
Description copied from interface:GroupManager
Returns the Group for this groupName, else null if no such Group exists.- Specified by:
getGroup
in interfaceGroupManager
- Parameters:
groupName
- The group name.- Returns:
- The Group for this groupName, else null if no such Group exists.
-
getGroupEvenWhenUnknown
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 interfaceGroupManager
- Parameters:
groupName
- The group name.- Returns:
- The Group for this groupName.
-
getGroupObject
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 interfaceGroupManager
- Parameters:
groupName
- The group name.- Returns:
- The Group for this groupName, else null if no such Group exists.
- See Also:
-
isUserInGroup
Description copied from interface:GroupManager
Returnstrue
if the user is a member of the group.Note that if the username or groupname is null, then it will return false.
Performance note: If you have a full user object, then calling one of the other
isUserInGroup()
methods directly is more efficient.- Specified by:
isUserInGroup
in interfaceGroupManager
- 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:
-
isUserInGroup
public boolean isUserInGroup(@Nullable ApplicationUser user, @Nullable com.atlassian.crowd.embedded.api.Group group) Description copied from interface:GroupManager
Returnstrue
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 interfaceGroupManager
- 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.
-
isUserInGroup
Description copied from interface:GroupManager
Returnstrue
if the user is a member of the named group.If you already have the user object, then this method is faster than the alternative of passing in the username because it saves on an unnecessary user lookup to find the correct User Directory.
- Specified by:
isUserInGroup
in interfaceGroupManager
- Parameters:
user
- 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.
-
isUserInGroups
Description copied from interface:GroupManager
Returnstrue
if the user is a member of at least one of the named groups.- Specified by:
isUserInGroups
in interfaceGroupManager
- Parameters:
user
- user to inspect.groupNames
- groups to inspect.- Returns:
true
if and only if the user is a direct or indirect (nested) member of the groups.
-
getUsersInGroup
Description copied from interface:GroupManager
Returns all the users in a group.- Specified by:
getUsersInGroup
in interfaceGroupManager
- Parameters:
groupName
- The group- Returns:
- all the users that belongs to the group.
-
getUsersInGroup
Description copied from interface:GroupManager
Returns all the users in a group. Allows for additional filtering by the active flag of a user.- Specified by:
getUsersInGroup
in interfaceGroupManager
- Parameters:
groupName
- The groupincludeInactive
- if set to true inactive users will be returned as well- Returns:
- all the users that belongs to the group.
-
getUsersInGroup
public Page<ApplicationUser> getUsersInGroup(String groupName, Boolean active, PageRequest pageRequest) Description copied from interface:GroupManager
Returns a page with users in a group. Users are sorted by name in ascending order.- Specified by:
getUsersInGroup
in interfaceGroupManager
- Parameters:
groupName
- name of the group for which users are returnedactive
- if set to true inactive users will be returned as wellpageRequest
- parameters of the page to return- Returns:
- page with the users
-
getUsersInGroup
Description copied from interface:GroupManager
Returns all the users in a group. This will include nested group members.- Specified by:
getUsersInGroup
in interfaceGroupManager
- Parameters:
group
- The group- Returns:
- all the users that belongs to the group.
-
getUsersInGroupCount
public int getUsersInGroupCount(com.atlassian.crowd.embedded.api.Group group) Description copied from interface:GroupManager
Returns a count of all active users in a group. This will include nested group members.- Specified by:
getUsersInGroupCount
in interfaceGroupManager
- Parameters:
group
- The group- Returns:
- a count of all the users that belongs to the group.
-
getUsersInGroupCount
Description copied from interface:GroupManager
Returns a count of all active users in a group. This will include nested group members.- Specified by:
getUsersInGroupCount
in interfaceGroupManager
- Parameters:
groupName
- The group name- Returns:
- a count of all the users that belongs to the group.
-
getNamesOfDirectMembersOfGroups
Description copied from interface:GroupManager
Returns a list of all active user names that are direct members in at least one of the supplied groups.- Specified by:
getNamesOfDirectMembersOfGroups
in interfaceGroupManager
- Parameters:
groupNames
- A collection of group names to find direct members oflimit
- A maximum number of names to return- Returns:
- a list of user names
-
filterUsersInAllGroupsDirect
public Collection<String> filterUsersInAllGroupsDirect(Collection<String> userNames, Collection<String> groupNames) Description copied from interface:GroupManager
Returns a collection of user names for the users that are direct members of every one of the supplied groups.- Specified by:
filterUsersInAllGroupsDirect
in interfaceGroupManager
- Parameters:
userNames
- A collection of user namesgroupNames
- A collection of groups- Returns:
- a collection of user names
-
getUserNamesInGroup
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 interfaceGroupManager
- Parameters:
group
- The group- Returns:
- all the users that belongs to the group.
-
getUserNamesInGroups
public Collection<String> getUserNamesInGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups) Description copied from interface:GroupManager
Returns the names of all the users in a collection of groups. This will include nested group members.- Specified by:
getUserNamesInGroups
in interfaceGroupManager
- Parameters:
groups
- The collection of groups- Returns:
- all the users that belongs to the group.
-
getUserNamesInGroup
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 interfaceGroupManager
- Parameters:
groupName
- The group- Returns:
- all the users that belongs to the group.
-
getDirectUsersInGroup
public Collection<ApplicationUser> 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 interfaceGroupManager
- Parameters:
group
- The group- Returns:
- all the users that belongs to the group.
-
getGroupsForUser
Description copied from interface:GroupManager
Returns all the groups that the given user belongs to.- Specified by:
getGroupsForUser
in interfaceGroupManager
- Parameters:
userName
- The user- Returns:
- all the groups that the given user belongs to.
- See Also:
-
getGroupsForUser
Description copied from interface:GroupManager
Returns all the groups that the given user belongs to.- Specified by:
getGroupsForUser
in interfaceGroupManager
- Parameters:
user
- The user- Returns:
- all the groups that the given user belongs to.
- See Also:
-
getGroupNamesForUser
Description copied from interface:GroupManager
Returns the names of all the groups that the given user belongs to.- Specified by:
getGroupNamesForUser
in interfaceGroupManager
- Parameters:
userName
- The user- Returns:
- all the groups that the given user belongs to.
- See Also:
-
getGroupNamesForUser
Description copied from interface:GroupManager
Returns the names of all the groups that the given user belongs to.- Specified by:
getGroupNamesForUser
in interfaceGroupManager
- Parameters:
user
- The user- Returns:
- all the groups that the given user belongs to.
- See Also:
-
addUserToGroup
Description copied from interface:GroupManager
Adds a user as a member of a group.- Specified by:
addUserToGroup
in interfaceGroupManager
- Parameters:
user
- The user that will become a member of the group.group
- The group that will gain a new member.
-
getConnectUsers
Deprecated.Description copied from interface:GroupManager
Returns all the connect app users. This will return an emptySet
in JIRA Server as connect plugins are only supported in JIRA Cloud. This result does not filter out inactive users.- Specified by:
getConnectUsers
in interfaceGroupManager
- Returns:
- all the connect app users.
-
addGroup
-
addGroup
-
addMember
-
setUserMembership
public MockGroupManager setUserMembership(ApplicationUser user, com.atlassian.crowd.embedded.api.Group... groups) -
getAllGroupNames
Description copied from interface:GroupManager
Returns the names of all groups or an empty collection if there are no groups.- Specified by:
getAllGroupNames
in interfaceGroupManager
- Returns:
- all the groups.
-