From 7ed728bf41824925099380b51425f9a14468148f Mon Sep 17 00:00:00 2001 From: Tassilo Weidner Date: Tue, 10 Dec 2019 09:57:24 +0100 Subject: [PATCH] fix(rest): make groups query unlimited in groups info resource related to CAM-11150 --- .../bpm/engine/rest/impl/IdentityRestServiceImpl.java | 10 ++++++++-- .../bpm/engine/rest/IdentityRestServiceQueryTest.java | 5 ++--- .../bpm/engine/rest/ProcessEngineRestServiceTest.java | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/impl/IdentityRestServiceImpl.java b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/impl/IdentityRestServiceImpl.java index 2377388ba89..26ad792c4c0 100644 --- a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/impl/IdentityRestServiceImpl.java +++ b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/impl/IdentityRestServiceImpl.java @@ -57,13 +57,19 @@ public GroupInfoDto getGroupInfo(String userId) { IdentityService identityService = getProcessEngine().getIdentityService(); GroupQuery query = identityService.createGroupQuery(); - List userGroups = query.groupMember(userId).orderByGroupName().asc().list(); + List userGroups = query.groupMember(userId) + .orderByGroupName() + .asc() + .unlimitedList(); Set allGroupUsers = new HashSet(); List allGroups = new ArrayList(); for (Group group : userGroups) { - List groupUsers = identityService.createUserQuery().memberOfGroup(group.getId()).list(); + List 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())); diff --git a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/IdentityRestServiceQueryTest.java b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/IdentityRestServiceQueryTest.java index ad89360bdf3..093c63d20a4 100644 --- a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/IdentityRestServiceQueryTest.java +++ b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/IdentityRestServiceQueryTest.java @@ -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; @@ -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 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); diff --git a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/ProcessEngineRestServiceTest.java b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/ProcessEngineRestServiceTest.java index 9c3e79bebe5..4bf3bb5205b 100644 --- a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/ProcessEngineRestServiceTest.java +++ b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/ProcessEngineRestServiceTest.java @@ -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);