Search in sources :

Example 6 with GroupQuery

use of org.activiti.engine.identity.GroupQuery in project Activiti by Activiti.

the class GroupQueryEscapeClauseTest method testQueryByNameLike.

public void testQueryByNameLike() {
    GroupQuery query = identityService.createGroupQuery().groupNameLike("%\\%%");
    assertEquals(1, query.list().size());
    assertEquals(1, query.count());
    assertEquals("muppets", query.singleResult().getId());
    query = identityService.createGroupQuery().groupNameLike("%\\_%");
    assertEquals(1, query.list().size());
    assertEquals(1, query.count());
    assertEquals("frogs", query.singleResult().getId());
}
Also used : GroupQuery(org.activiti.engine.identity.GroupQuery)

Example 7 with GroupQuery

use of org.activiti.engine.identity.GroupQuery in project Activiti by Activiti.

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.activiti.engine.identity.Group) GroupQuery(org.activiti.engine.identity.GroupQuery)

Example 8 with GroupQuery

use of org.activiti.engine.identity.GroupQuery in project Activiti by Activiti.

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);
}
Also used : GroupQuery(org.activiti.engine.identity.GroupQuery)

Example 9 with GroupQuery

use of org.activiti.engine.identity.GroupQuery in project Activiti by Activiti.

the class GroupQueryTest method testQueryByInvalidNameLike.

public void testQueryByInvalidNameLike() {
    GroupQuery query = identityService.createGroupQuery().groupNameLike("%invalid%");
    verifyQueryResults(query, 0);
    try {
        identityService.createGroupQuery().groupNameLike(null).list();
        fail();
    } catch (ActivitiIllegalArgumentException e) {
    }
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) GroupQuery(org.activiti.engine.identity.GroupQuery)

Example 10 with GroupQuery

use of org.activiti.engine.identity.GroupQuery in project Activiti by Activiti.

the class GroupQueryTest method testQueryById.

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

Aggregations

GroupQuery (org.activiti.engine.identity.GroupQuery)12 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)5 Group (org.activiti.engine.identity.Group)2