Search in sources :

Example 31 with ProcessInstance

use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.

the class DynamicUserTaskTest method testChangeOwner.

@Deployment(resources = { "org/activiti/engine/test/bpmn/usertask/DynamicUserTaskTest.assignment.bpmn20.xml" })
public void testChangeOwner() {
    // first test without changing the form key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    String processDefinitionId = processInstance.getProcessDefinitionId();
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("ownerTest", task.getOwner());
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskOwner("task1", "ownerTest2");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("ownerTest2", task.getOwner());
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.activiti.engine.task.Task) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 32 with ProcessInstance

use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.

the class DynamicUserTaskTest method testChangeAssignee.

@Deployment(resources = { "org/activiti/engine/test/bpmn/usertask/DynamicUserTaskTest.assignment.bpmn20.xml" })
public void testChangeAssignee() {
    // first test without changing the form key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    String processDefinitionId = processInstance.getProcessDefinitionId();
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("test", task.getAssignee());
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskAssignee("task1", "test2");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("test2", task.getAssignee());
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.activiti.engine.task.Task) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 33 with ProcessInstance

use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.

the class DynamicUserTaskTest method testChangeNameAndDescription.

@Deployment(resources = { "org/activiti/engine/test/bpmn/usertask/DynamicUserTaskTest.basictask.bpmn20.xml" })
public void testChangeNameAndDescription() {
    // first test without changing the form key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    String processDefinitionId = processInstance.getProcessDefinitionId();
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNull(task.getName());
    assertNull(task.getDescription());
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskName("task1", "Task name test");
    dynamicBpmnService.changeUserTaskDescription("task1", "Task description test", infoNode);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("Task name test", task.getName());
    assertEquals("Task description test", task.getDescription());
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.activiti.engine.task.Task) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 34 with ProcessInstance

use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.

the class DynamicUserTaskTest method testChangeCandidateUsersAndGroups.

@Deployment(resources = { "org/activiti/engine/test/bpmn/usertask/DynamicUserTaskTest.basictask.bpmn20.xml" })
public void testChangeCandidateUsersAndGroups() {
    // first test without changing the form key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    String processDefinitionId = processInstance.getProcessDefinitionId();
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    List<IdentityLink> taskIdentityLinks = taskService.getIdentityLinksForTask(task.getId());
    boolean candidateUserTestFound = false;
    boolean candidateGroupTestFound = false;
    for (IdentityLink identityLink : taskIdentityLinks) {
        if (IdentityLinkType.CANDIDATE.equals(identityLink.getType()) && identityLink.getUserId() != null && identityLink.getGroupId() == null) {
            if ("test".equals(identityLink.getUserId())) {
                candidateUserTestFound = true;
            }
        } else if (IdentityLinkType.CANDIDATE.equals(identityLink.getType()) && identityLink.getGroupId() != null && identityLink.getUserId() == null) {
            if ("test".equals(identityLink.getGroupId())) {
                candidateGroupTestFound = true;
            }
        }
    }
    assertFalse(candidateUserTestFound);
    assertFalse(candidateGroupTestFound);
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskCandidateGroup("task1", "test", true);
    dynamicBpmnService.changeUserTaskCandidateUser("task1", "test", true, infoNode);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskIdentityLinks = taskService.getIdentityLinksForTask(task.getId());
    candidateUserTestFound = false;
    candidateGroupTestFound = false;
    for (IdentityLink identityLink : taskIdentityLinks) {
        if (IdentityLinkType.CANDIDATE.equals(identityLink.getType()) && identityLink.getUserId() != null && identityLink.getGroupId() == null) {
            if ("test".equals(identityLink.getUserId())) {
                candidateUserTestFound = true;
            }
        } else if (IdentityLinkType.CANDIDATE.equals(identityLink.getType()) && identityLink.getGroupId() != null && identityLink.getUserId() == null) {
            if ("test".equals(identityLink.getGroupId())) {
                candidateGroupTestFound = true;
            }
        }
    }
    assertTrue(candidateUserTestFound);
    assertTrue(candidateGroupTestFound);
    taskService.complete(task.getId());
    infoNode = dynamicBpmnService.getProcessDefinitionInfo(processDefinitionId);
    dynamicBpmnService.changeUserTaskCandidateGroup("task1", "test2", false, infoNode);
    dynamicBpmnService.changeUserTaskCandidateUser("task1", "test2", false, infoNode);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskIdentityLinks = taskService.getIdentityLinksForTask(task.getId());
    candidateUserTestFound = false;
    boolean candidateUserTestFound2 = false;
    candidateGroupTestFound = false;
    boolean candidateGroupTest2Found = false;
    for (IdentityLink identityLink : taskIdentityLinks) {
        if (IdentityLinkType.CANDIDATE.equals(identityLink.getType()) && identityLink.getUserId() != null && identityLink.getGroupId() == null) {
            if ("test".equals(identityLink.getUserId())) {
                candidateUserTestFound = true;
            } else if ("test2".equals(identityLink.getUserId())) {
                candidateUserTestFound2 = true;
            }
        } else if (IdentityLinkType.CANDIDATE.equals(identityLink.getType()) && identityLink.getGroupId() != null && identityLink.getUserId() == null) {
            if ("test".equals(identityLink.getGroupId())) {
                candidateGroupTestFound = true;
            } else if ("test2".equals(identityLink.getGroupId())) {
                candidateGroupTest2Found = true;
            }
        }
    }
    assertTrue(candidateUserTestFound);
    assertTrue(candidateUserTestFound2);
    assertTrue(candidateGroupTestFound);
    assertTrue(candidateGroupTest2Found);
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.activiti.engine.task.Task) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) IdentityLink(org.activiti.engine.task.IdentityLink) Deployment(org.activiti.engine.test.Deployment)

Example 35 with ProcessInstance

use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.

the class DynamicUserTaskTest method testChangeFormKey.

@Deployment
public void testChangeFormKey() {
    // first test without changing the form key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    String processDefinitionId = processInstance.getProcessDefinitionId();
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("test", task.getFormKey());
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskFormKey("task1", "test2");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("test2", task.getFormKey());
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.activiti.engine.task.Task) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Aggregations

ProcessInstance (org.activiti.engine.runtime.ProcessInstance)822 Deployment (org.activiti.engine.test.Deployment)708 Task (org.activiti.engine.task.Task)374 HashMap (java.util.HashMap)242 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)182 Execution (org.activiti.engine.runtime.Execution)76 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)64 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)57 Job (org.activiti.engine.runtime.Job)55 Date (java.util.Date)53 JsonNode (com.fasterxml.jackson.databind.JsonNode)49 Calendar (java.util.Calendar)48 ActivitiException (org.activiti.engine.ActivitiException)41 ArrayList (java.util.ArrayList)38 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)38 HttpGet (org.apache.http.client.methods.HttpGet)38 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)27 StringEntity (org.apache.http.entity.StringEntity)27 HttpPost (org.apache.http.client.methods.HttpPost)25 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)24