use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class UserQueryTest method testQueryByMemberOf.
public void testQueryByMemberOf() {
UserQuery query = identityService.createUserQuery().memberOfGroup("muppets");
verifyQueryResults(query, 3);
query = identityService.createUserQuery().memberOfGroup("frogs");
verifyQueryResults(query, 1);
User result = query.singleResult();
assertEquals("kermit", result.getId());
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class UserQueryTest method createUser.
private User createUser(String id, String firstName, String lastName, String email) {
User user = identityService.newUser(id);
user.setFirstName(firstName);
user.setLastName(lastName);
user.setEmail(email);
identityService.saveUser(user);
return user;
}
use of org.activiti.engine.identity.User 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.User in project Activiti by Activiti.
the class CallServiceInServiceTaskTest method testMultipleServiceInvocationsFromDelegate.
@Deployment
public void testMultipleServiceInvocationsFromDelegate() {
runtimeService.startProcessInstanceByKey("multipleServiceInvocations");
// The service task should have created a user which is part of the admin group
User user = identityService.createUserQuery().singleResult();
assertEquals("Kermit", user.getId());
Group group = identityService.createGroupQuery().groupMember(user.getId()).singleResult();
assertNotNull(group);
assertEquals("admin", group.getId());
// Cleanup
identityService.deleteUser("Kermit");
identityService.deleteGroup("admin");
identityService.deleteMembership("Kermit", "admin");
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class CreateUserAndMembershipTestDelegate method execute.
@Override
public void execute(DelegateExecution execution) throws Exception {
IdentityService identityService = execution.getEngineServices().getIdentityService();
String username = "Kermit";
User user = identityService.newUser(username);
user.setPassword("123");
user.setFirstName("Manually");
user.setLastName("created");
identityService.saveUser(user);
// Add admin group
Group group = identityService.newGroup("admin");
identityService.saveGroup(group);
identityService.createMembership(username, "admin");
}
Aggregations