Search in sources :

Example 41 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class MultiInstanceTest method testSequentialSubProcessWithTimer.

@Deployment
public void testSequentialSubProcessWithTimer() {
    String procId = runtimeService.startProcessInstanceByKey("miSequentialSubprocessWithTimer").getId();
    // Complete one subprocess
    List<Task> tasks = taskService.createTaskQuery().list();
    assertEquals(2, tasks.size());
    taskService.complete(tasks.get(0).getId());
    taskService.complete(tasks.get(1).getId());
    tasks = taskService.createTaskQuery().list();
    assertEquals(2, tasks.size());
    // Fire timer
    Job timer = managementService.createJobQuery().singleResult();
    managementService.executeJob(timer.getId());
    Task taskAfterTimer = taskService.createTaskQuery().singleResult();
    assertEquals("taskAfterTimer", taskAfterTimer.getTaskDefinitionKey());
    taskService.complete(taskAfterTimer.getId());
    assertProcessEnded(procId);
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) Job(org.activiti.engine.runtime.Job) Deployment(org.activiti.engine.test.Deployment)

Example 42 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class MultiInstanceTest method testNestedParallelUserTasks.

@Deployment
public void testNestedParallelUserTasks() {
    String procId = runtimeService.startProcessInstanceByKey("miNestedParallelUserTasks").getId();
    List<Task> tasks = taskService.createTaskQuery().taskAssignee("kermit").list();
    for (Task task : tasks) {
        assertEquals("My Task", task.getName());
        taskService.complete(task.getId());
    }
    assertProcessEnded(procId);
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) Deployment(org.activiti.engine.test.Deployment)

Example 43 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class MultiInstanceTest method checkParallelUserTasksCustomExtensions.

private void checkParallelUserTasksCustomExtensions(String processDefinitionKey) {
    Map<String, Object> vars = new HashMap<String, Object>();
    List<String> assigneeList = Arrays.asList("kermit", "gonzo", "fozzie");
    vars.put("assigneeList", assigneeList);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinitionKey, vars);
    List<Task> tasks = taskService.createTaskQuery().orderByTaskName().asc().list();
    assertEquals(3, tasks.size());
    assertEquals("My Task 0", tasks.get(0).getName());
    assertEquals("My Task 1", tasks.get(1).getName());
    assertEquals("My Task 2", tasks.get(2).getName());
    tasks = taskService.createTaskQuery().orderByTaskAssignee().asc().list();
    assertEquals("fozzie", tasks.get(0).getAssignee());
    assertEquals("gonzo", tasks.get(1).getAssignee());
    assertEquals("kermit", tasks.get(2).getAssignee());
    // Completing 3 tasks will trigger completioncondition
    taskService.complete(tasks.get(0).getId());
    taskService.complete(tasks.get(1).getId());
    taskService.complete(tasks.get(2).getId());
    assertEquals(0, taskService.createTaskQuery().count());
    assertProcessEnded(processInstance.getProcessInstanceId());
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) HashMap(java.util.HashMap) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance)

Example 44 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class MultiInstanceTest method testSequentialMultiInstanceCallActivityWithErrorBoundaryEvent.

@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.callActivityWithBoundaryErrorEventSequential.bpmn20.xml", "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.throwingErrorEventSubProcess.bpmn20.xml" })
public void testSequentialMultiInstanceCallActivityWithErrorBoundaryEvent() {
    Map<String, Object> variableMap = new HashMap<String, Object>();
    variableMap.put("assignees", Arrays.asList("kermit", "gonzo"));
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process", variableMap);
    List<Task> tasks = taskService.createTaskQuery().list();
    assertEquals(1, tasks.size());
    // finish first call activity with error
    variableMap = new HashMap<String, Object>();
    variableMap.put("done", false);
    taskService.complete(tasks.get(0).getId(), variableMap);
    tasks = taskService.createTaskQuery().list();
    assertEquals(1, tasks.size());
    taskService.complete(tasks.get(0).getId());
    List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().processDefinitionKey("process").list();
    assertEquals(0, processInstances.size());
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) HashMap(java.util.HashMap) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 45 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class MultiInstanceTest method testMultiInstanceParalelReceiveTaskWithTimer.

@Deployment
public void testMultiInstanceParalelReceiveTaskWithTimer() {
    Date startTime = new Date();
    processEngineConfiguration.getClock().setCurrentTime(startTime);
    runtimeService.startProcessInstanceByKey("multiInstanceReceiveWithTimer");
    List<Execution> executions = runtimeService.createExecutionQuery().activityId("theReceiveTask").list();
    assertEquals(3, executions.size());
    // Signal only one execution. Then the timer will fire
    runtimeService.signal(executions.get(1).getId());
    processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + 60000L));
    waitForJobExecutorToProcessAllJobs(10000L, 1000L);
    // The process should now be in the task after the timer
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("Task after timer", task.getName());
    // Completing it should end the process
    taskService.complete(task.getId());
    assertEquals(0, runtimeService.createExecutionQuery().count());
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) Execution(org.activiti.engine.runtime.Execution) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) Date(java.util.Date) Deployment(org.activiti.engine.test.Deployment)

Aggregations

Task (org.activiti.engine.task.Task)718 Deployment (org.activiti.engine.test.Deployment)469 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)374 HashMap (java.util.HashMap)152 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)95 Date (java.util.Date)51 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)49 DelegateTask (org.activiti.engine.delegate.DelegateTask)42 JsonNode (com.fasterxml.jackson.databind.JsonNode)41 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)41 Test (org.junit.Test)40 Job (org.activiti.engine.runtime.Job)39 HttpGet (org.apache.http.client.methods.HttpGet)36 Calendar (java.util.Calendar)35 Execution (org.activiti.engine.runtime.Execution)33 ArrayList (java.util.ArrayList)32 TaskQuery (org.activiti.engine.task.TaskQuery)32 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)28 HttpPost (org.apache.http.client.methods.HttpPost)23 StringEntity (org.apache.http.entity.StringEntity)21