Search in sources :

Example 86 with User

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

the class LdapIntegrationTest method testUserQueryById.

public void testUserQueryById() {
    List<User> users = identityService.createUserQuery().userId("kermit").list();
    assertEquals(1, users.size());
    User user = users.get(0);
    assertEquals("kermit", user.getId());
    assertEquals("Kermit", user.getFirstName());
    assertEquals("The Frog", user.getLastName());
    user = identityService.createUserQuery().userId("fozzie").singleResult();
    assertEquals("fozzie", user.getId());
    assertEquals("Fozzie", user.getFirstName());
    assertEquals("Bear", user.getLastName());
}
Also used : User(org.activiti.engine.identity.User)

Example 87 with User

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

the class LdapIntegrationTest method testUserQueryByFullNameLike.

public void testUserQueryByFullNameLike() {
    List<User> users = identityService.createUserQuery().userFullNameLike("ermi").list();
    assertEquals(1, users.size());
    assertEquals(1, identityService.createUserQuery().userFullNameLike("ermi").count());
    User user = users.get(0);
    assertEquals("kermit", user.getId());
    assertEquals("Kermit", user.getFirstName());
    assertEquals("The Frog", user.getLastName());
    users = identityService.createUserQuery().userFullNameLike("rog").list();
    assertEquals(1, users.size());
    assertEquals(1, identityService.createUserQuery().userFullNameLike("rog").count());
    user = users.get(0);
    assertEquals("kermit", user.getId());
    assertEquals("Kermit", user.getFirstName());
    assertEquals("The Frog", user.getLastName());
    users = identityService.createUserQuery().userFullNameLike("e").list();
    assertEquals(5, users.size());
    assertEquals(5, identityService.createUserQuery().userFullNameLike("e").count());
    users = identityService.createUserQuery().userFullNameLike("The").list();
    assertEquals(3, users.size());
    assertEquals(3, identityService.createUserQuery().userFullNameLike("The").count());
}
Also used : User(org.activiti.engine.identity.User)

Example 88 with User

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

the class SerializableVariablesDiabledTest method setupServer.

@Before
public void setupServer() {
    if (serverUrlPrefix == null) {
        TestServer testServer = TestServerUtil.createAndStartServer(ObjectVariableSerializationDisabledApplicationConfiguration.class);
        serverUrlPrefix = testServer.getServerUrlPrefix();
        this.repositoryService = testServer.getApplicationContext().getBean(RepositoryService.class);
        this.runtimeService = testServer.getApplicationContext().getBean(RuntimeService.class);
        this.identityService = testServer.getApplicationContext().getBean(IdentityService.class);
        this.taskService = testServer.getApplicationContext().getBean(TaskService.class);
        User user = identityService.newUser("kermit");
        user.setFirstName("Kermit");
        user.setLastName("the Frog");
        user.setPassword("kermit");
        identityService.saveUser(user);
        Group group = identityService.newGroup("admin");
        group.setName("Administrators");
        identityService.saveGroup(group);
        identityService.createMembership(user.getId(), group.getId());
        this.testUserId = user.getId();
        this.testGroupId = group.getId();
    }
}
Also used : IdentityService(org.activiti.engine.IdentityService) Group(org.activiti.engine.identity.Group) User(org.activiti.engine.identity.User) RuntimeService(org.activiti.engine.RuntimeService) TaskService(org.activiti.engine.TaskService) TestServer(org.activiti.rest.util.TestServerUtil.TestServer) RepositoryService(org.activiti.engine.RepositoryService) Before(org.junit.Before)

Example 89 with User

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

the class UserEventsTest method testUserEntityEvents.

/**
	 * Test create, update and delete events of users.
	 */
public void testUserEntityEvents() throws Exception {
    User user = null;
    try {
        user = identityService.newUser("fred");
        user.setFirstName("Frederik");
        user.setLastName("Heremans");
        identityService.saveUser(user);
        assertEquals(2, listener.getEventsReceived().size());
        ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
        assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
        assertTrue(event.getEntity() instanceof User);
        User userFromEvent = (User) event.getEntity();
        assertEquals("fred", userFromEvent.getId());
        assertNull(event.getProcessDefinitionId());
        assertNull(event.getExecutionId());
        assertNull(event.getProcessInstanceId());
        event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
        assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
        listener.clearEventsReceived();
        // Update user
        user.setFirstName("Anna");
        identityService.saveUser(user);
        assertEquals(1, listener.getEventsReceived().size());
        event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
        assertEquals(ActivitiEventType.ENTITY_UPDATED, event.getType());
        assertTrue(event.getEntity() instanceof User);
        userFromEvent = (User) event.getEntity();
        assertEquals("fred", userFromEvent.getId());
        assertEquals("Anna", userFromEvent.getFirstName());
        assertNull(event.getProcessDefinitionId());
        assertNull(event.getExecutionId());
        assertNull(event.getProcessInstanceId());
        listener.clearEventsReceived();
        // Delete user
        identityService.deleteUser(user.getId());
        assertEquals(1, listener.getEventsReceived().size());
        event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
        assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
        assertTrue(event.getEntity() instanceof User);
        userFromEvent = (User) event.getEntity();
        assertEquals("fred", userFromEvent.getId());
        assertNull(event.getProcessDefinitionId());
        assertNull(event.getExecutionId());
        assertNull(event.getProcessInstanceId());
        listener.clearEventsReceived();
    } finally {
        if (user != null && user.getId() != null) {
            identityService.deleteUser(user.getId());
        }
    }
}
Also used : User(org.activiti.engine.identity.User) ActivitiEntityEvent(org.activiti.engine.delegate.event.ActivitiEntityEvent)

Example 90 with User

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

the class TaskServiceTest method testClaimUnexistingTaskId.

public void testClaimUnexistingTaskId() {
    User user = identityService.newUser("user");
    identityService.saveUser(user);
    try {
        taskService.claim("unexistingtaskid", user.getId());
        fail("ActivitiException expected");
    } catch (ActivitiObjectNotFoundException ae) {
        assertTextPresent("Cannot find task with id unexistingtaskid", ae.getMessage());
        assertEquals(Task.class, ae.getObjectClass());
    }
    identityService.deleteUser(user.getId());
}
Also used : Task(org.activiti.engine.task.Task) User(org.activiti.engine.identity.User) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

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