Search in sources :

Example 26 with HistoricTaskInstance

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

the class MultiInstanceTest method testParallelUserTasksHistory.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelUserTasks.bpmn20.xml" })
public void testParallelUserTasksHistory() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("miParallelUserTasks");
    for (Task task : taskService.createTaskQuery().list()) {
        taskService.complete(task.getId());
    }
    // Validate history
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
        List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().orderByTaskAssignee().asc().list();
        for (int i = 0; i < historicTaskInstances.size(); i++) {
            HistoricTaskInstance hi = historicTaskInstances.get(i);
            assertNotNull(hi.getStartTime());
            assertNotNull(hi.getEndTime());
            assertEquals("kermit_" + i, hi.getAssignee());
        }
        HistoricActivityInstance multiInstanceBodyInstance = historyService.createHistoricActivityInstanceQuery().activityId("miTasks#multiInstanceBody").singleResult();
        assertNotNull(multiInstanceBodyInstance);
        assertEquals(pi.getId(), multiInstanceBodyInstance.getParentActivityInstanceId());
        List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
        assertEquals(3, historicActivityInstances.size());
        for (HistoricActivityInstance hai : historicActivityInstances) {
            assertNotNull(hai.getStartTime());
            assertNotNull(hai.getEndTime());
            assertNotNull(hai.getAssignee());
            assertEquals("userTask", hai.getActivityType());
            assertEquals(multiInstanceBodyInstance.getId(), hai.getParentActivityInstanceId());
            assertNotNull(hai.getTaskId());
        }
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 27 with HistoricTaskInstance

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

the class MultiInstanceTest method testSequentialUserTasksHistory.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.sequentialUserTasks.bpmn20.xml" })
public void testSequentialUserTasksHistory() {
    runtimeService.startProcessInstanceByKey("miSequentialUserTasks", CollectionUtil.singletonMap("nrOfLoops", 4)).getId();
    for (int i = 0; i < 4; i++) {
        taskService.complete(taskService.createTaskQuery().singleResult().getId());
    }
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
        List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
        assertEquals(4, historicActivityInstances.size());
        for (HistoricActivityInstance hai : historicActivityInstances) {
            assertNotNull(hai.getActivityId());
            assertNotNull(hai.getActivityName());
            assertNotNull(hai.getStartTime());
            assertNotNull(hai.getEndTime());
            assertNotNull(hai.getAssignee());
        }
    }
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
        List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list();
        assertEquals(4, historicTaskInstances.size());
        for (HistoricTaskInstance ht : historicTaskInstances) {
            assertNotNull(ht.getAssignee());
            assertNotNull(ht.getStartTime());
            assertNotNull(ht.getEndTime());
        }
    }
}
Also used : HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 28 with HistoricTaskInstance

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

the class HistoricTaskDurationReportTest method testHistoricTaskInstanceDurationReportResults.

@Test
public void testHistoricTaskInstanceDurationReportResults() {
    startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 7, 14, 11, 43);
    startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 7, 14, 11, 43);
    DurationReportResult taskReportResult = historyService.createHistoricTaskInstanceReport().duration(PeriodUnit.MONTH).get(0);
    List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).list();
    long min = 0;
    long max = 0;
    long sum = 0;
    for (int i = 0; i < historicTaskInstances.size(); i++) {
        HistoricTaskInstance historicProcessInstance = historicTaskInstances.get(i);
        Long duration = historicProcessInstance.getDurationInMillis();
        sum = sum + duration;
        max = i > 0 ? Math.max(max, duration) : duration;
        min = i > 0 ? Math.min(min, duration) : duration;
    }
    long avg = sum / historicTaskInstances.size();
    assertEquals("maximum", max, taskReportResult.getMaximum());
    assertEquals("minimum", min, taskReportResult.getMinimum());
    assertEquals("average", avg, taskReportResult.getAverage(), 0);
}
Also used : HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) DurationReportResult(org.camunda.bpm.engine.history.DurationReportResult) Test(org.junit.Test)

Example 29 with HistoricTaskInstance

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

the class HistoricTaskInstanceTest method testQueryByCaseInstanceId.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseInstanceId() {
    // given
    String key = "oneTaskCase";
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).singleResult().getId();
    String caseInstanceId = caseService.withCaseDefinitionByKey(key).create().getId();
    String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    // then
    HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
    query.caseInstanceId(caseInstanceId);
    assertEquals(1, query.count());
    assertEquals(1, query.list().size());
    assertNotNull(query.singleResult());
    HistoricTaskInstance task = query.singleResult();
    assertNotNull(task);
    assertEquals(caseDefinitionId, task.getCaseDefinitionId());
    assertEquals(caseInstanceId, task.getCaseInstanceId());
    assertEquals(humanTaskId, 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)

Example 30 with HistoricTaskInstance

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

the class HistoricTaskInstanceTest method testQueryByCaseDefinitionName.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseDefinitionName() {
    // given
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
    String caseDefinitionName = caseDefinition.getName();
    String caseDefinitionId = caseDefinition.getId();
    String caseInstanceId = caseService.withCaseDefinitionByKey("oneTaskCase").create().getId();
    String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    // then
    HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
    query.caseDefinitionName(caseDefinitionName);
    assertEquals(1, query.count());
    assertEquals(1, query.list().size());
    assertNotNull(query.singleResult());
    HistoricTaskInstance task = query.singleResult();
    assertNotNull(task);
    assertEquals(caseDefinitionId, task.getCaseDefinitionId());
    assertEquals(caseInstanceId, task.getCaseInstanceId());
    assertEquals(humanTaskId, task.getCaseExecutionId());
}
Also used : HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) 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