Search in sources :

Example 6 with HistoricTaskInstance

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

the class MultiInstanceTest method testParallelCallActivityHistory.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.externalSubProcess.bpmn20.xml" })
public void testParallelCallActivityHistory() {
    runtimeService.startProcessInstanceByKey("miParallelCallActivity");
    List<Task> tasks = taskService.createTaskQuery().list();
    assertEquals(12, tasks.size());
    for (int i = 0; i < tasks.size(); i++) {
        taskService.complete(tasks.get(i).getId());
    }
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
        // Validate historic processes
        List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
        // 6 subprocesses + main process
        assertEquals(7, historicProcessInstances.size());
        for (HistoricProcessInstance hpi : historicProcessInstances) {
            assertNotNull(hpi.getStartTime());
            assertNotNull(hpi.getEndTime());
        }
        // Validate historic activities
        List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("callActivity").list();
        assertEquals(6, historicActivityInstances.size());
        for (HistoricActivityInstance hai : historicActivityInstances) {
            assertNotNull(hai.getStartTime());
            assertNotNull(hai.getEndTime());
        }
    }
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
        // Validate historic tasks
        List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list();
        assertEquals(12, historicTaskInstances.size());
        for (HistoricTaskInstance hti : historicTaskInstances) {
            assertNotNull(hti.getStartTime());
            assertNotNull(hti.getEndTime());
            assertNotNull(hti.getAssignee());
            assertEquals("completed", hti.getDeleteReason());
        }
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 7 with HistoricTaskInstance

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

the class HistoricTaskInstanceTest method testHistoricTaskInstanceAssignment.

public void testHistoricTaskInstanceAssignment() {
    Task task = taskService.newTask();
    taskService.saveTask(task);
    // task exists & has no assignee:
    HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertNull(hti.getAssignee());
    // assign task to jonny:
    taskService.setAssignee(task.getId(), "jonny");
    // should be reflected in history
    hti = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertEquals("jonny", hti.getAssignee());
    assertNull(hti.getOwner());
    taskService.deleteTask(task.getId());
    historyService.deleteHistoricTaskInstance(hti.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance)

Example 8 with HistoricTaskInstance

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

the class HistoricTaskInstanceTest method testHistoricTaskInstanceAssignmentListener.

@Deployment
public void testHistoricTaskInstanceAssignmentListener() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("assignee", "jonny");
    runtimeService.startProcessInstanceByKey("testProcess", variables);
    HistoricActivityInstance hai = historyService.createHistoricActivityInstanceQuery().activityId("task").singleResult();
    assertEquals("jonny", hai.getAssignee());
    HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertEquals("jonny", hti.getAssignee());
    assertNull(hti.getOwner());
}
Also used : HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) HashMap(java.util.HashMap) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 9 with HistoricTaskInstance

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

the class HistoricTaskInstanceTest method testHistoricTaskInstanceOwner.

public void testHistoricTaskInstanceOwner() {
    Task task = taskService.newTask();
    taskService.saveTask(task);
    // task exists & has no owner:
    HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertNull(hti.getOwner());
    // set owner to jonny:
    taskService.setOwner(task.getId(), "jonny");
    // should be reflected in history
    hti = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertEquals("jonny", hti.getOwner());
    taskService.deleteTask(task.getId());
    historyService.deleteHistoricTaskInstance(hti.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance)

Example 10 with HistoricTaskInstance

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

the class HistoricTaskInstanceTest method testQueryByCaseInstanceIdHierarchy.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricTaskInstanceTest.testQueryByCaseInstanceIdHierarchy.cmmn", "org/camunda/bpm/engine/test/history/HistoricTaskInstanceTest.testQueryByCaseInstanceIdHierarchy.bpmn20.xml" })
public void testQueryByCaseInstanceIdHierarchy() {
    // given
    String caseInstanceId = caseService.withCaseDefinitionByKey("case").create().getId();
    caseService.createCaseExecutionQuery().activityId("PI_ProcessTask_1").singleResult().getId();
    // then
    HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
    query.caseInstanceId(caseInstanceId);
    assertEquals(2, query.count());
    assertEquals(2, query.list().size());
    for (HistoricTaskInstance task : query.list()) {
        assertEquals(caseInstanceId, task.getCaseInstanceId());
        assertNull(task.getCaseDefinitionId());
        assertNull(task.getCaseExecutionId());
        taskService.complete(task.getId());
    }
    assertEquals(3, query.count());
    assertEquals(3, query.list().size());
    for (HistoricTaskInstance task : query.list()) {
        assertEquals(caseInstanceId, task.getCaseInstanceId());
        assertNull(task.getCaseDefinitionId());
        assertNull(task.getCaseExecutionId());
    }
}
Also used : HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

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