Search in sources :

Example 56 with HistoricActivityInstance

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

the class CompensateEventHistoryTest method testBoundaryCompensationHandlerHistoryActivityInstance.

@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventHistoryTest.testBoundaryCompensationHandlerHistory.bpmn20.xml")
public void testBoundaryCompensationHandlerHistoryActivityInstance() {
    // given a process instance
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("boundaryHandlerProcess");
    // when throwing compensation
    Task beforeCompensationTask = taskService.createTaskQuery().singleResult();
    taskService.complete(beforeCompensationTask.getId());
    String compensationHandlerActivityInstanceId = runtimeService.getActivityInstance(processInstance.getId()).getActivityInstances("compensationHandler")[0].getId();
    // .. and completing compensation
    Task compensationHandler = taskService.createTaskQuery().singleResult();
    taskService.complete(compensationHandler.getId());
    // then there is a historic activity instance for the compensation handler
    HistoricActivityInstance historicCompensationHandlerInstance = historyService.createHistoricActivityInstanceQuery().activityId("compensationHandler").singleResult();
    assertNotNull(historicCompensationHandlerInstance);
    assertEquals(compensationHandlerActivityInstanceId, historicCompensationHandlerInstance.getId());
    assertEquals(processInstance.getId(), historicCompensationHandlerInstance.getParentActivityInstanceId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 57 with HistoricActivityInstance

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

the class CompensateEventOrderTest method testTwoCompensateEventsInReverseOrder.

@Test
public void testTwoCompensateEventsInReverseOrder() {
    // given
    BpmnModelInstance model = Bpmn.createExecutableProcess("Process_1").startEvent().serviceTask("serviceTask1").camundaClass(IncreaseCurrentTimeServiceTask.class.getName()).boundaryEvent("compensationBoundary1").compensateEventDefinition().compensateEventDefinitionDone().moveToActivity("serviceTask1").serviceTask("serviceTask2").camundaClass(IncreaseCurrentTimeServiceTask.class.getName()).boundaryEvent("compensationBoundary2").compensateEventDefinition().compensateEventDefinitionDone().moveToActivity("serviceTask2").intermediateThrowEvent("compensationEvent").compensateEventDefinition().waitForCompletion(true).compensateEventDefinitionDone().endEvent().done();
    addServiceTaskCompensationHandler(model, "compensationBoundary1", "A");
    addServiceTaskCompensationHandler(model, "compensationBoundary2", "B");
    testHelper.deploy(model);
    // when
    engineRule.getRuntimeService().startProcessInstanceByKey("Process_1", Variables.createVariables().putValue("currentTime", new Date()));
    // then compensation activities are executed in the reverse order
    List<HistoricActivityInstance> list = engineRule.getHistoryService().createHistoricActivityInstanceQuery().orderByHistoricActivityInstanceEndTime().asc().list();
    long indexA = searchForActivityIndex(list, "A");
    long indexB = searchForActivityIndex(list, "B");
    assertNotEquals(-1, indexA);
    assertNotEquals(-1, indexB);
    assertTrue("Compensation activities were executed in wrong order.", indexA > indexB);
}
Also used : IncreaseCurrentTimeServiceTask(org.camunda.bpm.engine.test.bpmn.event.compensate.helper.IncreaseCurrentTimeServiceTask) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Date(java.util.Date) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Test(org.junit.Test)

Example 58 with HistoricActivityInstance

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

the class LinkEventTest method testEventLinkMultipleSources.

@Deployment
public void testEventLinkMultipleSources() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("linkEventValid");
    List<String> activeActivities = runtimeService.getActiveActivityIds(pi.getId());
    // assert that the link event was triggered and that we are
    assertEquals(Arrays.asList(new String[] { "WaitAfterLink", "WaitAfterLink" }), activeActivities);
    runtimeService.deleteProcessInstance(pi.getId(), "test done");
    // validate history
    if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
        List<HistoricActivityInstance> activities = historyService.createHistoricActivityInstanceQuery().processInstanceId(pi.getId()).orderByActivityId().asc().list();
        assertEquals(5, activities.size());
        assertEquals("ManualTask_1", activities.get(0).getActivityId());
        assertEquals("ParallelGateway_1", activities.get(1).getActivityId());
        assertEquals("StartEvent_1", activities.get(2).getActivityId());
        assertEquals("WaitAfterLink", activities.get(3).getActivityId());
        assertEquals("WaitAfterLink", activities.get(4).getActivityId());
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 59 with HistoricActivityInstance

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

the class LinkEventTest method testValidEventLink.

@Deployment
public void testValidEventLink() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("linkEventValid");
    List<String> activeActivities = runtimeService.getActiveActivityIds(pi.getId());
    // assert that now the first receive task is active
    assertEquals(Arrays.asList(new String[] { "waitAfterLink1" }), activeActivities);
    runtimeService.signal(pi.getId());
    activeActivities = runtimeService.getActiveActivityIds(pi.getId());
    // assert that now the second receive task is active
    assertEquals(Arrays.asList(new String[] { "waitAfterLink2" }), activeActivities);
    runtimeService.signal(pi.getId());
    assertProcessEnded(pi.getId());
    // validate history
    if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
        List<HistoricActivityInstance> activities = historyService.createHistoricActivityInstanceQuery().processInstanceId(pi.getId()).orderByActivityId().asc().list();
        assertEquals(4, activities.size());
        assertEquals("EndEvent_1", activities.get(0).getActivityId());
        assertEquals("StartEvent_1", activities.get(1).getActivityId());
        assertEquals("waitAfterLink1", activities.get(2).getActivityId());
        assertEquals("waitAfterLink2", activities.get(3).getActivityId());
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 60 with HistoricActivityInstance

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

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