use of org.activiti.engine.identity.UserQuery in project Activiti by Activiti.
the class UserQueryTest method testQueryByInvalidLastName.
public void testQueryByInvalidLastName() {
UserQuery query = identityService.createUserQuery().userLastName("invalid");
verifyQueryResults(query, 0);
try {
identityService.createUserQuery().userLastName(null).singleResult();
fail();
} catch (ActivitiIllegalArgumentException e) {
}
}
use of org.activiti.engine.identity.UserQuery in project Activiti by Activiti.
the class UserQueryTest method testQuerySorting.
public void testQuerySorting() {
// asc
assertEquals(3, identityService.createUserQuery().orderByUserId().asc().count());
assertEquals(3, identityService.createUserQuery().orderByUserEmail().asc().count());
assertEquals(3, identityService.createUserQuery().orderByUserFirstName().asc().count());
assertEquals(3, identityService.createUserQuery().orderByUserLastName().asc().count());
// desc
assertEquals(3, identityService.createUserQuery().orderByUserId().desc().count());
assertEquals(3, identityService.createUserQuery().orderByUserEmail().desc().count());
assertEquals(3, identityService.createUserQuery().orderByUserFirstName().desc().count());
assertEquals(3, identityService.createUserQuery().orderByUserLastName().desc().count());
// Combined with criteria
UserQuery query = identityService.createUserQuery().userLastNameLike("%ea%").orderByUserFirstName().asc();
List<User> users = query.list();
assertEquals(2, users.size());
assertEquals("Fozzie", users.get(0).getFirstName());
assertEquals("Gonzo", users.get(1).getFirstName());
}
use of org.activiti.engine.identity.UserQuery in project Activiti by Activiti.
the class UserQueryTest method testQueryByFullNameLike.
public void testQueryByFullNameLike() {
UserQuery query = identityService.createUserQuery().userFullNameLike("%erm%");
verifyQueryResults(query, 1);
query = identityService.createUserQuery().userFullNameLike("%ea%");
verifyQueryResults(query, 2);
query = identityService.createUserQuery().userFullNameLike("%e%");
verifyQueryResults(query, 3);
}
use of org.activiti.engine.identity.UserQuery in project Activiti by Activiti.
the class GroupMembersQuery method loadItems.
public List<Item> loadItems(int start, int count) {
UserQuery query = identityService.createUserQuery().memberOfGroup(groupId);
if (sortby == null || "id".equals(sortby)) {
// default
query.orderByUserId();
} else if ("firstName".equals(sortby)) {
query.orderByUserFirstName();
} else if ("lastName".equals(sortby)) {
query.orderByUserLastName();
} else if ("email".equals(sortby)) {
query.orderByUserEmail();
}
if (sortby == null || ascending) {
query.asc();
} else {
query.desc();
}
List<User> users = query.listPage(start, count);
List<Item> items = new ArrayList<Item>();
for (User user : users) {
items.add(new GroupMemberItem(user));
}
return items;
}
use of org.activiti.engine.identity.UserQuery in project Activiti by Activiti.
the class UserQueryEscapeClauseTest method testQueryByLastNameLike.
public void testQueryByLastNameLike() {
UserQuery query = identityService.createUserQuery().userLastNameLike("%\\%%");
assertEquals(1, query.list().size());
assertEquals(1, query.count());
assertEquals("kermit", query.singleResult().getId());
query = identityService.createUserQuery().userLastNameLike("%\\_%");
assertEquals(1, query.list().size());
assertEquals(1, query.count());
assertEquals("fozzie", query.singleResult().getId());
}
Aggregations