Search in sources :

Example 11 with Task

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

the class TaskDueDateExtensionsTest method testRelativeDueDateStringExtension.

@Deployment
public void testRelativeDueDateStringExtension() throws Exception {
    Clock clock = processEngineConfiguration.getClock();
    clock.setCurrentCalendar(new GregorianCalendar(2015, 0, 1));
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("dateVariable", "P2DT5H40M");
    // Start process-instance, passing ISO8601 duration formatted String that should be used to calculate dueDate
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dueDateExtension", variables);
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(task.getDueDate());
    Period period = new Period(task.getCreateTime().getTime(), task.getDueDate().getTime());
    assertEquals(2, period.getDays());
    assertEquals(5, period.getHours());
    assertEquals(40, period.getMinutes());
    clock.reset();
}
Also used : Task(org.activiti.engine.task.Task) HashMap(java.util.HashMap) GregorianCalendar(java.util.GregorianCalendar) Period(org.joda.time.Period) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Clock(org.activiti.engine.runtime.Clock) Deployment(org.activiti.engine.test.Deployment)

Example 12 with Task

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

the class TaskDueDateExtensionsTest method testRelativeDueDateStringWithCalendarNameExtension.

@Deployment
public void testRelativeDueDateStringWithCalendarNameExtension() throws Exception {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("dateVariable", "P2DT5H40M");
    // Start process-instance, passing ISO8601 duration formatted String that should be used to calculate dueDate
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dueDateExtension", variables);
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(task.getDueDate());
    assertThat(task.getDueDate(), is(new Date(0)));
}
Also used : Task(org.activiti.engine.task.Task) HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Date(java.util.Date) Deployment(org.activiti.engine.test.Deployment)

Example 13 with Task

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

the class TaskPriorityExtensionsTest method testPriorityExtensionString.

@Deployment
public void testPriorityExtensionString() throws Exception {
    final ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("taskPriorityExtensionString");
    final Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals(42, task.getPriority());
}
Also used : Task(org.activiti.engine.task.Task) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 14 with Task

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

the class UserTaskTest method testTaskPropertiesNotNull.

@Deployment
public void testTaskPropertiesNotNull() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task.getId());
    assertEquals("my task", task.getName());
    assertEquals("Very important", task.getDescription());
    assertTrue(task.getPriority() > 0);
    assertEquals("kermit", task.getAssignee());
    assertEquals(processInstance.getId(), task.getProcessInstanceId());
    assertEquals(processInstance.getId(), task.getExecutionId());
    assertNotNull(task.getProcessDefinitionId());
    assertNotNull(task.getTaskDefinitionKey());
    assertNotNull(task.getCreateTime());
    // the next test verifies that if an execution creates a task, that no events are created during creation of the task.
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        assertEquals(0, taskService.getTaskEvents(task.getId()).size());
    }
}
Also used : Task(org.activiti.engine.task.Task) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 15 with Task

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

the class UserTaskTest method testCompleteAfterParallelGateway.

@Deployment
public void testCompleteAfterParallelGateway() throws InterruptedException {
    // related to https://activiti.atlassian.net/browse/ACT-1054
    // start the process
    runtimeService.startProcessInstanceByKey("ForkProcess");
    List<Task> taskList = taskService.createTaskQuery().list();
    assertNotNull(taskList);
    assertEquals(2, taskList.size());
    // make sure user task exists
    Task task = taskService.createTaskQuery().taskDefinitionKey("SimpleUser").singleResult();
    assertNotNull(task);
    // attempt to complete the task and get PersistenceException pointing to "referential integrity constraint violation"
    taskService.complete(task.getId());
}
Also used : Task(org.activiti.engine.task.Task) 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