Search in sources :

Example 36 with Deployment

use of org.activiti.engine.test.Deployment in project Activiti by Activiti.

the class TaskAssignmentExtensionsTest method testCandidateGroupsExtension.

@Deployment
public void testCandidateGroupsExtension() {
    runtimeService.startProcessInstanceByKey("candidateGroupsExtension");
    // Bugfix check: potentially the query could return 2 tasks since
    // kermit is a member of the two candidate groups
    List<Task> tasks = taskService.createTaskQuery().taskCandidateUser("kermit").list();
    assertEquals(1, tasks.size());
    assertEquals("make profit", tasks.get(0).getName());
    tasks = taskService.createTaskQuery().taskCandidateUser("fozzie").list();
    assertEquals(1, tasks.size());
    assertEquals("make profit", tasks.get(0).getName());
    // Test the task query find-by-candidate-group operation
    TaskQuery query = taskService.createTaskQuery();
    assertEquals(1, query.taskCandidateGroup("management").count());
    assertEquals(1, query.taskCandidateGroup("accountancy").count());
}
Also used : Task(org.activiti.engine.task.Task) TaskQuery(org.activiti.engine.task.TaskQuery) Deployment(org.activiti.engine.test.Deployment)

Example 37 with Deployment

use of org.activiti.engine.test.Deployment 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 38 with Deployment

use of org.activiti.engine.test.Deployment 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 39 with Deployment

use of org.activiti.engine.test.Deployment 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 40 with Deployment

use of org.activiti.engine.test.Deployment 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)

Aggregations

Deployment (org.activiti.engine.test.Deployment)1020 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)709 Task (org.activiti.engine.task.Task)469 HashMap (java.util.HashMap)267 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)180 Execution (org.activiti.engine.runtime.Execution)106 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)87 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)84 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)83 Date (java.util.Date)82 Job (org.activiti.engine.runtime.Job)76 JsonNode (com.fasterxml.jackson.databind.JsonNode)66 Calendar (java.util.Calendar)54 StringEntity (org.apache.http.entity.StringEntity)50 HttpGet (org.apache.http.client.methods.HttpGet)49 ActivitiException (org.activiti.engine.ActivitiException)46 DelegateTask (org.activiti.engine.delegate.DelegateTask)40 ArrayList (java.util.ArrayList)39 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)30 TaskQuery (org.activiti.engine.task.TaskQuery)29