Search in sources :

Example 6 with HistoricActivityInstance

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

the class ProcessInstantiationAtActivitiesHistoryTest method testSkipCustomListenerEnsureHistoryWritten.

@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testSkipCustomListenerEnsureHistoryWritten() {
    // when creating the task skipping custom listeners
    runtimeService.createProcessInstanceByKey("exclusiveGateway").startBeforeActivity("task2").execute(true, false);
    // then the task assignment history (which uses a task listener) is written
    Task task = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult();
    HistoricActivityInstance instance = historyService.createHistoricActivityInstanceQuery().activityId("task2").singleResult();
    assertNotNull(instance);
    assertEquals(task.getId(), instance.getTaskId());
    assertEquals("kermit", instance.getAssignee());
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 7 with HistoricActivityInstance

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

the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricProcessInstanceForSingleActivityInstantiation.

@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testHistoricProcessInstanceForSingleActivityInstantiation() {
    // when
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").startBeforeActivity("task1").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("task1", historicInstance.getStartActivityId());
    HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().singleResult();
    assertNotNull(historicActivityInstance);
    assertEquals("task1", historicActivityInstance.getActivityId());
    assertNotNull(historicActivityInstance.getId());
    assertFalse(instance.getId().equals(historicActivityInstance.getId()));
    assertNotNull(historicActivityInstance.getStartTime());
    assertNull(historicActivityInstance.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 8 with HistoricActivityInstance

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

the class CompensateEventHistoryTest method testDefaultCompensationHandlerHistoryActivityInstance.

@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventHistoryTest.testDefaultCompensationHandlerHistory.bpmn20.xml")
public void testDefaultCompensationHandlerHistoryActivityInstance() {
    // given a process instance
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("defaultHandlerProcess");
    // when throwing compensation
    Task beforeCompensationTask = taskService.createTaskQuery().singleResult();
    taskService.complete(beforeCompensationTask.getId());
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    String compensationHandlerActivityInstanceId = tree.getActivityInstances("compensationHandler")[0].getId();
    String subProcessActivityInstanceId = tree.getActivityInstances("subProcess")[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(subProcessActivityInstanceId, historicCompensationHandlerInstance.getParentActivityInstanceId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 9 with HistoricActivityInstance

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

the class CompensateEventTest method FAILING_testDeleteInstanceWithEventScopeExecution.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void FAILING_testDeleteInstanceWithEventScopeExecution() {
    // given
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("foo").startEvent("start").subProcess("subProcess").embeddedSubProcess().startEvent("subProcessStart").endEvent("subProcessEnd").subProcessDone().userTask("userTask").done();
    modelInstance = ModifiableBpmnModelInstance.modify(modelInstance).addSubProcessTo("subProcess").id("eventSubProcess").triggerByEvent().embeddedSubProcess().startEvent().compensateEventDefinition().compensateEventDefinitionDone().endEvent().done();
    deployment(modelInstance);
    long dayInMillis = 1000 * 60 * 60 * 24;
    Date date1 = new Date(10 * dayInMillis);
    ClockUtil.setCurrentTime(date1);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("foo");
    // when
    Date date2 = new Date(date1.getTime() + dayInMillis);
    ClockUtil.setCurrentTime(date2);
    runtimeService.deleteProcessInstance(processInstance.getId(), null);
    // then
    List<HistoricActivityInstance> historicActivityInstance = historyService.createHistoricActivityInstanceQuery().orderByActivityId().asc().list();
    assertEquals(5, historicActivityInstance.size());
    assertEquals("start", historicActivityInstance.get(0).getActivityId());
    assertEquals(date1, historicActivityInstance.get(0).getEndTime());
    assertEquals("subProcess", historicActivityInstance.get(1).getActivityId());
    assertEquals(date1, historicActivityInstance.get(1).getEndTime());
    assertEquals("subProcessEnd", historicActivityInstance.get(2).getActivityId());
    assertEquals(date1, historicActivityInstance.get(2).getEndTime());
    assertEquals("subProcessStart", historicActivityInstance.get(3).getActivityId());
    assertEquals(date1, historicActivityInstance.get(3).getEndTime());
    assertEquals("userTask", historicActivityInstance.get(4).getActivityId());
    assertEquals(date2, historicActivityInstance.get(4).getEndTime());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) ModifiableBpmnModelInstance(org.camunda.bpm.engine.test.api.runtime.migration.ModifiableBpmnModelInstance) Date(java.util.Date) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 10 with HistoricActivityInstance

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

the class ProcessInstanceModificationHistoryTest method testSkipCustomListenerEnsureHistoryWritten.

@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testSkipCustomListenerEnsureHistoryWritten() {
    // given
    String processInstanceId = runtimeService.startProcessInstanceByKey("exclusiveGateway").getId();
    // when creating the task skipping custom listeners
    runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("task2").execute(true, false);
    // then the task assignment history (which uses a task listener) is written
    Task task = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult();
    HistoricActivityInstance instance = historyService.createHistoricActivityInstanceQuery().activityId("task2").singleResult();
    assertNotNull(instance);
    assertEquals(task.getId(), instance.getTaskId());
    assertEquals("kermit", instance.getAssignee());
}
Also used : Task(org.camunda.bpm.engine.task.Task) 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