Search in sources :

Example 61 with HistoricActivityInstance

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

the class MultiInstanceTest method testSequentialSubProcessHistory.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testSequentialSubProcess.bpmn20.xml" })
public void testSequentialSubProcessHistory() {
    runtimeService.startProcessInstanceByKey("miSequentialSubprocess");
    for (int i = 0; i < 4; i++) {
        List<Task> tasks = taskService.createTaskQuery().list();
        taskService.complete(tasks.get(0).getId());
        taskService.complete(tasks.get(1).getId());
    }
    // Validate history
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
        List<HistoricActivityInstance> onlySubProcessInstances = historyService.createHistoricActivityInstanceQuery().activityType("subProcess").list();
        assertEquals(4, onlySubProcessInstances.size());
        List<HistoricActivityInstance> historicInstances = historyService.createHistoricActivityInstanceQuery().activityType("subProcess").list();
        assertEquals(4, historicInstances.size());
        for (HistoricActivityInstance hai : historicInstances) {
            assertNotNull(hai.getStartTime());
            assertNotNull(hai.getEndTime());
        }
        historicInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
        assertEquals(8, historicInstances.size());
        for (HistoricActivityInstance hai : historicInstances) {
            assertNotNull(hai.getStartTime());
            assertNotNull(hai.getEndTime());
        }
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 62 with HistoricActivityInstance

use of org.camunda.bpm.engine.history.HistoricActivityInstance 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 63 with HistoricActivityInstance

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

the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricActivityInstancesForSubprocess.

@Deployment(resources = SUBPROCESS_PROCESS)
public void testHistoricActivityInstancesForSubprocess() {
    // when
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("subprocess").startBeforeActivity("innerTask").startBeforeActivity("theSubProcessStart").execute();
    // then
    HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
    assertNotNull(historicInstance);
    assertEquals(instance.getId(), historicInstance.getId());
    assertNotNull(historicInstance.getStartTime());
    assertNull(historicInstance.getEndTime());
    // should be the first activity started
    assertEquals("innerTask", historicInstance.getStartActivityId());
    // subprocess, subprocess start event, two innerTasks
    assertEquals(4, historyService.createHistoricActivityInstanceQuery().count());
    HistoricActivityInstance subProcessInstance = historyService.createHistoricActivityInstanceQuery().activityId("subProcess").singleResult();
    assertNotNull(subProcessInstance);
    assertEquals("subProcess", subProcessInstance.getActivityId());
    assertNotNull(subProcessInstance.getId());
    assertFalse(instance.getId().equals(subProcessInstance.getId()));
    assertNotNull(subProcessInstance.getStartTime());
    assertNull(subProcessInstance.getEndTime());
    HistoricActivityInstance startEventInstance = historyService.createHistoricActivityInstanceQuery().activityId("theSubProcessStart").singleResult();
    assertNotNull(startEventInstance);
    assertEquals("theSubProcessStart", startEventInstance.getActivityId());
    assertNotNull(startEventInstance.getId());
    assertFalse(instance.getId().equals(startEventInstance.getId()));
    assertNotNull(startEventInstance.getStartTime());
    assertNotNull(startEventInstance.getEndTime());
    List<HistoricActivityInstance> innerTaskInstances = historyService.createHistoricActivityInstanceQuery().activityId("innerTask").list();
    assertEquals(2, innerTaskInstances.size());
    for (HistoricActivityInstance innerTaskInstance : innerTaskInstances) {
        assertNotNull(innerTaskInstance);
        assertEquals("innerTask", innerTaskInstance.getActivityId());
        assertNotNull(innerTaskInstance.getId());
        assertFalse(instance.getId().equals(innerTaskInstance.getId()));
        assertNotNull(innerTaskInstance.getStartTime());
        assertNull(innerTaskInstance.getEndTime());
    }
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) 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 64 with HistoricActivityInstance

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

the class RuntimeServiceTest method testDeleteProcessInstanceSkipCustomListenersEnsureHistoryWritten.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@Test
public void testDeleteProcessInstanceSkipCustomListenersEnsureHistoryWritten() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    // if we skip the custom listeners,
    runtimeService.deleteProcessInstance(processInstance.getId(), null, true);
    // buit-in listeners are still invoked and thus history is written
    if (!ProcessEngineConfiguration.HISTORY_NONE.equals(processEngineConfiguration.getHistory())) {
        // verify that all historic activity instances are ended
        List<HistoricActivityInstance> hais = historyService.createHistoricActivityInstanceQuery().list();
        for (HistoricActivityInstance hai : hais) {
            assertNotNull(hai.getEndTime());
        }
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 65 with HistoricActivityInstance

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

the class HistoricActivityInstanceTest method testHistoricActivityInstanceReceive.

@Deployment
public void testHistoricActivityInstanceReceive() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("receiveProcess");
    HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("receive").singleResult();
    assertEquals("receive", historicActivityInstance.getActivityId());
    assertEquals("receiveTask", historicActivityInstance.getActivityType());
    assertNull(historicActivityInstance.getEndTime());
    assertNull(historicActivityInstance.getDurationInMillis());
    assertNotNull(historicActivityInstance.getProcessDefinitionId());
    assertEquals(processInstance.getId(), historicActivityInstance.getProcessInstanceId());
    assertEquals(processInstance.getId(), historicActivityInstance.getExecutionId());
    assertNotNull(historicActivityInstance.getStartTime());
    // move clock by 1 second
    Date now = ClockUtil.getCurrentTime();
    ClockUtil.setCurrentTime(new Date(now.getTime() + 1000));
    runtimeService.signal(processInstance.getId());
    historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("receive").singleResult();
    assertEquals("receive", historicActivityInstance.getActivityId());
    assertEquals("receiveTask", historicActivityInstance.getActivityType());
    assertNotNull(historicActivityInstance.getEndTime());
    assertNotNull(historicActivityInstance.getProcessDefinitionId());
    assertEquals(processInstance.getId(), historicActivityInstance.getProcessInstanceId());
    assertEquals(processInstance.getId(), historicActivityInstance.getExecutionId());
    assertNotNull(historicActivityInstance.getStartTime());
    assertTrue(historicActivityInstance.getDurationInMillis() >= 1000);
    assertTrue(((HistoricActivityInstanceEventEntity) historicActivityInstance).getDurationRaw() >= 1000);
}
Also used : HistoricActivityInstanceEventEntity(org.camunda.bpm.engine.impl.history.event.HistoricActivityInstanceEventEntity) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Date(java.util.Date) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)80 Deployment (org.camunda.bpm.engine.test.Deployment)56 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)45 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)24 Task (org.camunda.bpm.engine.task.Task)19 Test (org.junit.Test)17 HistoricActivityInstanceQuery (org.camunda.bpm.engine.history.HistoricActivityInstanceQuery)13 HashMap (java.util.HashMap)12 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)8 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)6 Date (java.util.Date)5 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)5 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)5 HistoricTaskInstance (org.camunda.bpm.engine.history.HistoricTaskInstance)4 ArrayList (java.util.ArrayList)3 HistoryService (org.camunda.bpm.engine.HistoryService)3 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)3 Response (com.jayway.restassured.response.Response)2 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)2 HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)2