Skip to content

Commit

Permalink
fix(rest): make groups query unlimited in groups info resource
Browse files Browse the repository at this point in the history
related to CAM-11150
  • Loading branch information
tasso94 authored and tmetzke committed Dec 10, 2019
1 parent f922464 commit 7ed728b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ public GroupInfoDto getGroupInfo(String userId) {
IdentityService identityService = getProcessEngine().getIdentityService();

GroupQuery query = identityService.createGroupQuery();
List<Group> userGroups = query.groupMember(userId).orderByGroupName().asc().list();
List<Group> userGroups = query.groupMember(userId)
.orderByGroupName()
.asc()
.unlimitedList();

Set<UserDto> allGroupUsers = new HashSet<UserDto>();
List<GroupDto> allGroups = new ArrayList<GroupDto>();

for (Group group : userGroups) {
List<User> groupUsers = identityService.createUserQuery().memberOfGroup(group.getId()).list();
List<User> groupUsers = identityService.createUserQuery()
.memberOfGroup(group.getId())
.unlimitedList();

for (User user : groupUsers) {
if (!user.getId().equals(userId)) {
allGroupUsers.add(new UserDto(user.getId(), user.getFirstName(), user.getLastName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.camunda.bpm.engine.identity.User;
import org.camunda.bpm.engine.identity.UserQuery;
import org.camunda.bpm.engine.rest.dto.identity.BasicUserCredentialsDto;
import org.camunda.bpm.engine.rest.dto.identity.GroupDto;
import org.camunda.bpm.engine.rest.exception.InvalidRequestException;
import org.camunda.bpm.engine.rest.helper.MockProvider;
import org.camunda.bpm.engine.rest.util.container.TestContainerRule;
Expand Down Expand Up @@ -70,14 +69,14 @@ private void createMockIdentityQueries() {
mockUser = MockProvider.createMockUser();
mockUsers.add(mockUser);

when(sampleUserQuery.list()).thenReturn(mockUsers);
when(sampleUserQuery.unlimitedList()).thenReturn(mockUsers);
when(sampleUserQuery.memberOfGroup(anyString())).thenReturn(sampleUserQuery);
when(sampleUserQuery.count()).thenReturn((long) mockUsers.size());

GroupQuery sampleGroupQuery = mock(GroupQuery.class);

List<Group> mockGroups = MockProvider.createMockGroups();
when(sampleGroupQuery.list()).thenReturn(mockGroups);
when(sampleGroupQuery.unlimitedList()).thenReturn(mockGroups);
when(sampleGroupQuery.groupMember(anyString())).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.orderByGroupName()).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.orderByGroupId()).thenReturn(sampleGroupQuery);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ private void createIdentityMocks() {
when(sampleGroupQuery.groupMember(anyString())).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.orderByGroupName()).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.asc()).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.list()).thenReturn(mockGroups);
when(sampleGroupQuery.unlimitedList()).thenReturn(mockGroups);

when(mockIdentityService.createGroupQuery()).thenReturn(sampleGroupQuery);
when(mockIdentityService.createUserQuery()).thenReturn(sampleUserQuery);
Expand Down

0 comments on commit 7ed728b

Please sign in to comment.