Search in sources :

Example 26 with GroupQuery

use of org.camunda.bpm.engine.identity.GroupQuery in project camunda-bpm-platform by camunda.

the class GroupQueryTest method testQueryByMemberOfTenant.

public void testQueryByMemberOfTenant() {
    GroupQuery query = identityService.createGroupQuery().memberOfTenant("nonExisting");
    verifyQueryResults(query, 0);
    query = identityService.createGroupQuery().memberOfTenant("tenant");
    verifyQueryResults(query, 1);
    Group group = query.singleResult();
    assertEquals("frogs", group.getId());
}
Also used : Group(org.camunda.bpm.engine.identity.Group) GroupQuery(org.camunda.bpm.engine.identity.GroupQuery)

Example 27 with GroupQuery

use of org.camunda.bpm.engine.identity.GroupQuery in project camunda-bpm-platform by camunda.

the class GroupQueryTest method testQueryByName.

public void testQueryByName() {
    GroupQuery query = identityService.createGroupQuery().groupName("Muppet show characters_");
    verifyQueryResults(query, 1);
    query = identityService.createGroupQuery().groupName("Famous frogs");
    verifyQueryResults(query, 1);
}
Also used : GroupQuery(org.camunda.bpm.engine.identity.GroupQuery)

Example 28 with GroupQuery

use of org.camunda.bpm.engine.identity.GroupQuery in project camunda-bpm-platform by camunda.

the class GroupQueryTest method testQueryById.

public void testQueryById() {
    GroupQuery query = identityService.createGroupQuery().groupId("muppets");
    verifyQueryResults(query, 1);
}
Also used : GroupQuery(org.camunda.bpm.engine.identity.GroupQuery)

Example 29 with GroupQuery

use of org.camunda.bpm.engine.identity.GroupQuery in project camunda-bpm-platform by camunda.

the class GroupQueryTest method testQuerySorting.

public void testQuerySorting() {
    // asc
    assertEquals(4, identityService.createGroupQuery().orderByGroupId().asc().count());
    assertEquals(4, identityService.createGroupQuery().orderByGroupName().asc().count());
    assertEquals(4, identityService.createGroupQuery().orderByGroupType().asc().count());
    // desc
    assertEquals(4, identityService.createGroupQuery().orderByGroupId().desc().count());
    assertEquals(4, identityService.createGroupQuery().orderByGroupName().desc().count());
    assertEquals(4, identityService.createGroupQuery().orderByGroupType().desc().count());
    // Multiple sortings
    GroupQuery query = identityService.createGroupQuery().orderByGroupType().asc().orderByGroupName().desc();
    List<Group> groups = query.list();
    assertEquals(4, query.count());
    assertEquals("security", groups.get(0).getType());
    assertEquals("user", groups.get(1).getType());
    assertEquals("user", groups.get(2).getType());
    assertEquals("user", groups.get(3).getType());
    assertEquals("admin", groups.get(0).getId());
    assertEquals("muppets", groups.get(1).getId());
    assertEquals("mammals", groups.get(2).getId());
    assertEquals("frogs", groups.get(3).getId());
}
Also used : Group(org.camunda.bpm.engine.identity.Group) GroupQuery(org.camunda.bpm.engine.identity.GroupQuery)

Example 30 with GroupQuery

use of org.camunda.bpm.engine.identity.GroupQuery in project camunda-bpm-platform by camunda.

the class IdentityServiceTenantTest method deleteTenantMembershipsOfTenant.

@Test
public void deleteTenantMembershipsOfTenant() {
    Tenant tenant = identityService.newTenant(TENANT_ONE);
    identityService.saveTenant(tenant);
    User user = identityService.newUser(USER_ONE);
    identityService.saveUser(user);
    Group group = identityService.newGroup(GROUP_ONE);
    identityService.saveGroup(group);
    identityService.createTenantUserMembership(TENANT_ONE, USER_ONE);
    identityService.createTenantGroupMembership(TENANT_ONE, GROUP_ONE);
    UserQuery userQuery = identityService.createUserQuery().memberOfTenant(TENANT_ONE);
    GroupQuery groupQuery = identityService.createGroupQuery().memberOfTenant(TENANT_ONE);
    assertThat(userQuery.count(), is(1L));
    assertThat(groupQuery.count(), is(1L));
    identityService.deleteTenant(TENANT_ONE);
    assertThat(userQuery.count(), is(0L));
    assertThat(groupQuery.count(), is(0L));
}
Also used : Group(org.camunda.bpm.engine.identity.Group) Tenant(org.camunda.bpm.engine.identity.Tenant) User(org.camunda.bpm.engine.identity.User) UserQuery(org.camunda.bpm.engine.identity.UserQuery) GroupQuery(org.camunda.bpm.engine.identity.GroupQuery) Test(org.junit.Test)

Aggregations

GroupQuery (org.camunda.bpm.engine.identity.GroupQuery)34 Group (org.camunda.bpm.engine.identity.Group)22 Test (org.junit.Test)12 Matchers.anyString (org.mockito.Matchers.anyString)10 ArrayList (java.util.ArrayList)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 User (org.camunda.bpm.engine.identity.User)5 UserQuery (org.camunda.bpm.engine.identity.UserQuery)4 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)4 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)3 Tenant (org.camunda.bpm.engine.identity.Tenant)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Response (com.jayway.restassured.response.Response)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)1 IdentityService (org.camunda.bpm.engine.IdentityService)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1