use of org.camunda.bpm.engine.identity.GroupQuery in project camunda-bpm-platform by camunda.
the class GroupRestServiceInteractionTest method testGetNonExistingGroup.
@Test
public void testGetNonExistingGroup() {
GroupQuery sampleGroupQuery = mock(GroupQuery.class);
when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.groupId(anyString())).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.singleResult()).thenReturn(null);
given().pathParam("id", "aNonExistingGroup").then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Group with id aNonExistingGroup does not exist")).when().get(GROUP_URL);
}
use of org.camunda.bpm.engine.identity.GroupQuery in project camunda-bpm-platform by camunda.
the class GroupRestServiceInteractionTest method testUpdateNonExistingGroup.
@Test
public void testUpdateNonExistingGroup() {
Group groupUpdate = MockProvider.createMockGroupUpdate();
GroupQuery sampleGroupQuery = mock(GroupQuery.class);
when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.groupId("aNonExistingGroup")).thenReturn(sampleGroupQuery);
// this time the query returns null
when(sampleGroupQuery.singleResult()).thenReturn(null);
given().pathParam("id", "aNonExistingGroup").body(GroupDto.fromGroup(groupUpdate)).contentType(ContentType.JSON).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Group with id aNonExistingGroup does not exist")).when().put(GROUP_URL);
verify(identityServiceMock, never()).saveGroup(any(Group.class));
}
use of org.camunda.bpm.engine.identity.GroupQuery in project camunda-bpm-platform by camunda.
the class IdentityRestServiceQueryTest method createMockIdentityQueries.
private void createMockIdentityQueries() {
UserQuery sampleUserQuery = mock(UserQuery.class);
List<User> mockUsers = new ArrayList<User>();
mockUser = MockProvider.createMockUser();
mockUsers.add(mockUser);
when(sampleUserQuery.list()).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.groupMember(anyString())).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.orderByGroupName()).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.orderByGroupId()).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.orderByGroupType()).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.asc()).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.desc()).thenReturn(sampleGroupQuery);
when(processEngine.getIdentityService().createGroupQuery()).thenReturn(sampleGroupQuery);
when(processEngine.getIdentityService().createUserQuery()).thenReturn(sampleUserQuery);
}
use of org.camunda.bpm.engine.identity.GroupQuery in project camunda-bpm-platform by camunda.
the class GroupQueryTest method testQueryByType.
public void testQueryByType() {
GroupQuery query = identityService.createGroupQuery().groupType("user");
verifyQueryResults(query, 3);
query = identityService.createGroupQuery().groupType("admin");
verifyQueryResults(query, 0);
}
use of org.camunda.bpm.engine.identity.GroupQuery in project camunda-bpm-platform by camunda.
the class GroupQueryTest method testQueryByMember.
public void testQueryByMember() {
GroupQuery query = identityService.createGroupQuery().groupMember("fozzie");
verifyQueryResults(query, 2);
query = identityService.createGroupQuery().groupMember("kermit");
verifyQueryResults(query, 3);
query = query.orderByGroupId().asc();
List<Group> groups = query.list();
assertEquals(3, groups.size());
assertEquals("admin", groups.get(0).getId());
assertEquals("frogs", groups.get(1).getId());
assertEquals("muppets", groups.get(2).getId());
query = query.groupType("user");
groups = query.list();
assertEquals(2, groups.size());
assertEquals("frogs", groups.get(0).getId());
assertEquals("muppets", groups.get(1).getId());
}
Aggregations