Search in sources :

Example 6 with User

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

Example 7 with User

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

Example 8 with 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());
}
Also used : User(org.activiti.engine.identity.User) UserQuery(org.activiti.engine.identity.UserQuery)

Example 9 with User

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");
}
Also used : Group(org.activiti.engine.identity.Group) User(org.activiti.engine.identity.User) Deployment(org.activiti.engine.test.Deployment)

Example 10 with User

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

Aggregations

User (org.activiti.engine.identity.User)94 Group (org.activiti.engine.identity.Group)22 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)10 Task (org.activiti.engine.task.Task)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)9 Picture (org.activiti.engine.identity.Picture)9 StringEntity (org.apache.http.entity.StringEntity)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ArrayList (java.util.ArrayList)7 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)7 HttpPut (org.apache.http.client.methods.HttpPut)7 HttpGet (org.apache.http.client.methods.HttpGet)6 UserQuery (org.activiti.engine.identity.UserQuery)5 HttpDelete (org.apache.http.client.methods.HttpDelete)5 HttpPost (org.apache.http.client.methods.HttpPost)4 Item (com.vaadin.data.Item)3 ActivitiException (org.activiti.engine.ActivitiException)3 IdentityService (org.activiti.engine.IdentityService)3