Search in sources :

Example 21 with HistoricTaskInstance

use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.

the class HistoricTaskInstanceQueryTest method testTaskWasAssigned.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskWasAssigned() {
    // given
    Task taskOne = taskService.newTask("taskOne");
    Task taskTwo = taskService.newTask("taskTwo");
    Task taskThree = taskService.newTask("taskThree");
    // when
    taskOne.setAssignee("aUserId");
    taskService.saveTask(taskOne);
    taskTwo.setAssignee("anotherUserId");
    taskService.saveTask(taskTwo);
    taskService.saveTask(taskThree);
    List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskAssigned().list();
    // then
    assertEquals(list.size(), 2);
    // cleanup
    taskService.deleteTask("taskOne", true);
    taskService.deleteTask("taskTwo", true);
    taskService.deleteTask("taskThree", true);
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) Deployment(org.camunda.bpm.engine.test.Deployment) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 22 with HistoricTaskInstance

use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.

the class HistoricTaskInstanceQueryTest method testTaskReturnedBeforeEndTime.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskReturnedBeforeEndTime() {
    // given
    Task taskOne = taskService.newTask("taskOne");
    // when
    taskOne.setAssignee("aUserId");
    taskService.saveTask(taskOne);
    Calendar hourAgo = Calendar.getInstance();
    hourAgo.add(Calendar.HOUR_OF_DAY, -1);
    ClockUtil.setCurrentTime(hourAgo.getTime());
    taskService.complete(taskOne.getId());
    List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().finishedBefore(hourAgo.getTime()).list();
    // then
    assertEquals(1, list.size());
    // cleanup
    taskService.deleteTask("taskOne", true);
    ClockUtil.reset();
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) Calendar(java.util.Calendar) Deployment(org.camunda.bpm.engine.test.Deployment) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 23 with HistoricTaskInstance

use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.

the class SubTaskTest method testSubTask.

public void testSubTask() {
    Task gonzoTask = taskService.newTask();
    gonzoTask.setName("gonzoTask");
    taskService.saveTask(gonzoTask);
    Task subTaskOne = taskService.newTask();
    subTaskOne.setName("subtask one");
    String gonzoTaskId = gonzoTask.getId();
    subTaskOne.setParentTaskId(gonzoTaskId);
    taskService.saveTask(subTaskOne);
    Task subTaskTwo = taskService.newTask();
    subTaskTwo.setName("subtask two");
    subTaskTwo.setParentTaskId(gonzoTaskId);
    taskService.saveTask(subTaskTwo);
    String subTaskId = subTaskOne.getId();
    assertTrue(taskService.getSubTasks(subTaskId).isEmpty());
    assertTrue(historyService.createHistoricTaskInstanceQuery().taskParentTaskId(subTaskId).list().isEmpty());
    List<Task> subTasks = taskService.getSubTasks(gonzoTaskId);
    Set<String> subTaskNames = new HashSet<String>();
    for (Task subTask : subTasks) {
        subTaskNames.add(subTask.getName());
    }
    if (processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_AUDIT.getId()) {
        Set<String> expectedSubTaskNames = new HashSet<String>();
        expectedSubTaskNames.add("subtask one");
        expectedSubTaskNames.add("subtask two");
        assertEquals(expectedSubTaskNames, subTaskNames);
        List<HistoricTaskInstance> historicSubTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(gonzoTaskId).list();
        subTaskNames = new HashSet<String>();
        for (HistoricTaskInstance historicSubTask : historicSubTasks) {
            subTaskNames.add(historicSubTask.getName());
        }
        assertEquals(expectedSubTaskNames, subTaskNames);
    }
    taskService.deleteTask(gonzoTaskId, true);
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) HashSet(java.util.HashSet)

Example 24 with HistoricTaskInstance

use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.

the class TaskServiceTest method testDeleteTaskWithDeleteReason.

@Test
public void testDeleteTaskWithDeleteReason() {
    // ACT-900: deleteReason can be manually specified - can only be validated when historyLevel > ACTIVITY
    if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
        Task task = taskService.newTask();
        task.setName("test task");
        taskService.saveTask(task);
        assertNotNull(task.getId());
        taskService.deleteTask(task.getId(), "deleted for testing purposes");
        HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
        assertNotNull(historicTaskInstance);
        assertEquals("deleted for testing purposes", historicTaskInstance.getDeleteReason());
        // Delete historic task that is left behind, will not be cleaned up because this is not part of a process
        taskService.deleteTask(task.getId(), true);
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) Test(org.junit.Test)

Example 25 with HistoricTaskInstance

use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.

the class TaskServiceTest method testSaveTaskUpdate.

@Test
public void testSaveTaskUpdate() throws Exception {
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
    Task task = taskService.newTask();
    task.setDescription("description");
    task.setName("taskname");
    task.setPriority(0);
    task.setAssignee("taskassignee");
    task.setOwner("taskowner");
    Date dueDate = sdf.parse("01/02/2003 04:05:06");
    task.setDueDate(dueDate);
    task.setCaseInstanceId("taskcaseinstanceid");
    taskService.saveTask(task);
    // Fetch the task again and update
    task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
    assertEquals("description", task.getDescription());
    assertEquals("taskname", task.getName());
    assertEquals("taskassignee", task.getAssignee());
    assertEquals("taskowner", task.getOwner());
    assertEquals(dueDate, task.getDueDate());
    assertEquals(0, task.getPriority());
    assertEquals("taskcaseinstanceid", task.getCaseInstanceId());
    if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
        HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
        assertEquals("taskname", historicTaskInstance.getName());
        assertEquals("description", historicTaskInstance.getDescription());
        assertEquals("taskassignee", historicTaskInstance.getAssignee());
        assertEquals("taskowner", historicTaskInstance.getOwner());
        assertEquals(dueDate, historicTaskInstance.getDueDate());
        assertEquals(0, historicTaskInstance.getPriority());
        assertEquals("taskcaseinstanceid", historicTaskInstance.getCaseInstanceId());
    }
    task.setName("updatedtaskname");
    task.setDescription("updateddescription");
    task.setPriority(1);
    task.setAssignee("updatedassignee");
    task.setOwner("updatedowner");
    dueDate = sdf.parse("01/02/2003 04:05:06");
    task.setDueDate(dueDate);
    task.setCaseInstanceId("updatetaskcaseinstanceid");
    taskService.saveTask(task);
    task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
    assertEquals("updatedtaskname", task.getName());
    assertEquals("updateddescription", task.getDescription());
    assertEquals("updatedassignee", task.getAssignee());
    assertEquals("updatedowner", task.getOwner());
    assertEquals(dueDate, task.getDueDate());
    assertEquals(1, task.getPriority());
    assertEquals("updatetaskcaseinstanceid", task.getCaseInstanceId());
    if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
        HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
        assertEquals("updatedtaskname", historicTaskInstance.getName());
        assertEquals("updateddescription", historicTaskInstance.getDescription());
        assertEquals("updatedassignee", historicTaskInstance.getAssignee());
        assertEquals("updatedowner", historicTaskInstance.getOwner());
        assertEquals(dueDate, historicTaskInstance.getDueDate());
        assertEquals(1, historicTaskInstance.getPriority());
        assertEquals("updatetaskcaseinstanceid", historicTaskInstance.getCaseInstanceId());
    }
    // Finally, delete task
    taskService.deleteTask(task.getId(), true);
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Aggregations

HistoricTaskInstance (org.camunda.bpm.engine.history.HistoricTaskInstance)36 Deployment (org.camunda.bpm.engine.test.Deployment)20 Task (org.camunda.bpm.engine.task.Task)18 HistoricTaskInstanceQuery (org.camunda.bpm.engine.history.HistoricTaskInstanceQuery)10 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)6 Test (org.junit.Test)6 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)4 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)4 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)3 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 HashSet (java.util.HashSet)1 ProcessApplicationService (org.camunda.bpm.ProcessApplicationService)1