public class MockGroupManager extends Object implements GroupManager
| Constructor and Description |
|---|
MockGroupManager() |
MockGroupManager(com.atlassian.crowd.embedded.api.CrowdService crowdService) |
| Modifier and Type | Method and Description |
|---|---|
MockGroupManager |
addGroup(com.atlassian.crowd.embedded.api.Group group) |
com.atlassian.crowd.embedded.api.Group |
addGroup(String groupName) |
void |
addMember(String groupName,
String userName) |
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.
|
Collection<String> |
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.
|
Collection<com.atlassian.crowd.embedded.api.Group> |
getAllGroups()
Get all groups.
|
Set<ApplicationUser> |
getConnectUsers()
Deprecated.
|
Collection<ApplicationUser> |
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(ApplicationUser user)
Returns the names of all the groups that the given user belongs to.
|
Collection<String> |
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> |
getGroupsForUser(ApplicationUser user)
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.
|
List<String> |
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.
|
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<String> |
getUserNamesInGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups)
Returns the names of all the users in a collection of groups.
|
Collection<ApplicationUser> |
getUsersInGroup(com.atlassian.crowd.embedded.api.Group group)
Returns all the users in a group.
|
Collection<ApplicationUser> |
getUsersInGroup(String groupName)
Returns all the users in a group.
|
Collection<ApplicationUser> |
getUsersInGroup(String groupName,
Boolean includeInactive)
Returns all the users in a group.
|
Page<ApplicationUser> |
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)
Returns
true if the given group exists. |
boolean |
groupExists(String groupName)
Returns
true if the given group name exists. |
boolean |
isUserInGroup(ApplicationUser user,
com.atlassian.crowd.embedded.api.Group group)
Returns
true if the user is a member of the group. |
boolean |
isUserInGroup(ApplicationUser user,
String groupName)
Returns
true if the user is a member of the named group. |
boolean |
isUserInGroup(String username,
String groupName)
Returns
true if the user is a member of the group. |
MockGroupManager |
setUserMembership(ApplicationUser user,
com.atlassian.crowd.embedded.api.Group... groups) |
<T extends Exception> |
throwExceptionOnCreateGroup(String groupName,
Exception cause) |
public MockGroupManager()
public MockGroupManager(com.atlassian.crowd.embedded.api.CrowdService crowdService)
public Collection<com.atlassian.crowd.embedded.api.Group> getAllGroups()
GroupManagergetAllGroups in interface GroupManagerpublic boolean groupExists(String groupName)
GroupManagertrue if the given group name exists.groupExists in interface GroupManagergroupName - The group name.true if the given group name exists.public boolean groupExists(@Nonnull com.atlassian.crowd.embedded.api.Group group)
GroupManagertrue if the given group exists.groupExists in interface GroupManagergroup - The group.true if the given group exists.public com.atlassian.crowd.embedded.api.Group createGroup(String groupName)
GroupManagercreateGroup in interface GroupManagergroupName - The group name.public <T extends Exception> void throwExceptionOnCreateGroup(String groupName, Exception cause)
public com.atlassian.crowd.embedded.api.Group getGroup(String groupName)
GroupManagergetGroup in interface GroupManagergroupName - The group name.public com.atlassian.crowd.embedded.api.Group getGroupEvenWhenUnknown(String groupName)
GroupManagergetGroupEvenWhenUnknown in interface GroupManagergroupName - The group name.public com.atlassian.crowd.embedded.api.Group getGroupObject(String groupName)
GroupManager
Legacy synonym for GroupManager.getGroup(String).
getGroupObject in interface GroupManagergroupName - The group name.GroupManager.getGroup(String)public boolean isUserInGroup(@Nullable String username, @Nullable String groupName)
GroupManagertrue 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.
isUserInGroup in interface GroupManagerusername - user to inspect.groupName - group to inspect.true if and only if the user is a direct or indirect (nested) member of the group.GroupManager.isUserInGroup(ApplicationUser, Group),
GroupManager.isUserInGroup(ApplicationUser, String)public boolean isUserInGroup(@Nullable ApplicationUser user, @Nullable com.atlassian.crowd.embedded.api.Group group)
GroupManagertrue 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()
isUserInGroup in interface GroupManageruser - user to inspect.group - group to inspect.true if and only if the user is a direct or indirect (nested) member of the group.public boolean isUserInGroup(@Nullable ApplicationUser user, @Nullable String groupName)
GroupManagertrue 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.
isUserInGroup in interface GroupManageruser - user to inspect.groupName - group to inspect.true if and only if the user is a direct or indirect (nested) member of the group.public Collection<ApplicationUser> getUsersInGroup(String groupName)
GroupManagergetUsersInGroup in interface GroupManagergroupName - The group#getUsersInGroup(Group)}public Collection<ApplicationUser> getUsersInGroup(String groupName, Boolean includeInactive)
GroupManagergetUsersInGroup in interface GroupManagergroupName - The groupincludeInactive - if set to true inactive users will be returned as wellpublic Page<ApplicationUser> getUsersInGroup(String groupName, Boolean active, PageRequest pageRequest)
GroupManagergetUsersInGroup in interface GroupManagergroupName - 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 returnpublic Collection<ApplicationUser> getUsersInGroup(com.atlassian.crowd.embedded.api.Group group)
GroupManagergetUsersInGroup in interface GroupManagergroup - The group#getUsersInGroup(String)}public int getUsersInGroupCount(com.atlassian.crowd.embedded.api.Group group)
GroupManagergetUsersInGroupCount in interface GroupManagergroup - The group#getUsersInGroupCount(String)}public int getUsersInGroupCount(String groupName)
GroupManagergetUsersInGroupCount in interface GroupManagergroupName - The group name#getUsersInGroupCount(Group)}public List<String> getNamesOfDirectMembersOfGroups(Collection<String> groupNames, int limit)
GroupManagergetNamesOfDirectMembersOfGroups in interface GroupManagergroupNames - A collection of group names to find direct members oflimit - A maximum number of names to returnpublic Collection<String> filterUsersInAllGroupsDirect(Collection<String> userNames, Collection<String> groupNames)
GroupManagerfilterUsersInAllGroupsDirect in interface GroupManageruserNames - A collection of user namesgroupNames - A collection of groupspublic Collection<String> getUserNamesInGroup(com.atlassian.crowd.embedded.api.Group group)
GroupManagergetUserNamesInGroup in interface GroupManagergroup - The group#getUsersInGroup(Group)}public Collection<String> getUserNamesInGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups)
GroupManagergetUserNamesInGroups in interface GroupManagergroups - The collection of groupspublic Collection<String> getUserNamesInGroup(String groupName)
GroupManagergetUserNamesInGroup in interface GroupManagergroupName - The group#getUsersInGroup(String)}public Collection<ApplicationUser> getDirectUsersInGroup(com.atlassian.crowd.embedded.api.Group group)
GroupManagergetDirectUsersInGroup in interface GroupManagergroup - The group#getUsersInGroup(String)}public Collection<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(String userName)
GroupManagergetGroupsForUser in interface GroupManageruserName - The userGroupManager.getGroupNamesForUser(String)public Collection<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(ApplicationUser user)
GroupManagergetGroupsForUser in interface GroupManageruser - The userGroupManager.getGroupNamesForUser(String)public Collection<String> getGroupNamesForUser(String userName)
GroupManagergetGroupNamesForUser in interface GroupManageruserName - The userGroupManager.getGroupsForUser(String),
GroupManager.getGroupNamesForUser(com.atlassian.jira.user.ApplicationUser)public Collection<String> getGroupNamesForUser(@Nonnull ApplicationUser user)
GroupManagergetGroupNamesForUser in interface GroupManageruser - The userGroupManager.getGroupsForUser(String)public void addUserToGroup(ApplicationUser user, com.atlassian.crowd.embedded.api.Group group)
GroupManageraddUserToGroup in interface GroupManageruser - The user that will become a member of the group.group - The group that will gain a new member.@Deprecated public Set<ApplicationUser> getConnectUsers()
GroupManagerSet in JIRA Server as connect plugins are only
supported in JIRA Cloud. This result does not filter out inactive users.getConnectUsers in interface GroupManagerpublic com.atlassian.crowd.embedded.api.Group addGroup(String groupName)
public MockGroupManager addGroup(com.atlassian.crowd.embedded.api.Group group)
public MockGroupManager setUserMembership(ApplicationUser user, com.atlassian.crowd.embedded.api.Group... groups)
Copyright © 2002-2019 Atlassian. All Rights Reserved.