Search in sources :

Example 11 with HistoricActivityInstance

use of org.activiti.engine.history.HistoricActivityInstance in project Activiti by Activiti.

the class HistoricActivityInstanceTest method testHistoricActivityInstanceForEventsQuery.

@Deployment
public void testHistoricActivityInstanceForEventsQuery() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("eventProcess");
    assertEquals(1, taskService.createTaskQuery().count());
    runtimeService.signalEventReceived("signal");
    assertProcessEnded(pi.getId());
    assertEquals(1, historyService.createHistoricActivityInstanceQuery().activityId("noop").list().size());
    assertEquals(1, historyService.createHistoricActivityInstanceQuery().activityId("userTask").list().size());
    assertEquals(1, historyService.createHistoricActivityInstanceQuery().activityId("intermediate-event").list().size());
    assertEquals(1, historyService.createHistoricActivityInstanceQuery().activityId("start").list().size());
    assertEquals(1, historyService.createHistoricActivityInstanceQuery().activityId("end").list().size());
    // TODO: Discuss if boundary events will occur in the log!
    //    assertEquals(1, historyService.createHistoricActivityInstanceQuery().activityId("boundaryEvent").list().size());
    HistoricActivityInstance intermediateEvent = historyService.createHistoricActivityInstanceQuery().activityId("intermediate-event").singleResult();
    assertNotNull(intermediateEvent.getStartTime());
    assertNotNull(intermediateEvent.getEndTime());
    HistoricActivityInstance startEvent = historyService.createHistoricActivityInstanceQuery().activityId("start").singleResult();
    assertNotNull(startEvent.getStartTime());
    assertNotNull(startEvent.getEndTime());
    HistoricActivityInstance endEvent = historyService.createHistoricActivityInstanceQuery().activityId("end").singleResult();
    assertNotNull(endEvent.getStartTime());
    assertNotNull(endEvent.getEndTime());
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance) Deployment(org.activiti.engine.test.Deployment)

Example 12 with HistoricActivityInstance

use of org.activiti.engine.history.HistoricActivityInstance in project Activiti by Activiti.

the class HistoricActivityInstanceTest method testHistoricActivityInstanceCalledProcessId.

@Deployment(resources = { "org/activiti/engine/test/history/calledProcess.bpmn20.xml", "org/activiti/engine/test/history/HistoricActivityInstanceTest.testCallSimpleSubProcess.bpmn20.xml" })
public void testHistoricActivityInstanceCalledProcessId() {
    runtimeService.startProcessInstanceByKey("callSimpleSubProcess");
    HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("callSubProcess").singleResult();
    HistoricProcessInstance oldInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("calledProcess").singleResult();
    assertEquals(oldInstance.getId(), historicActivityInstance.getCalledProcessInstanceId());
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance) Deployment(org.activiti.engine.test.Deployment)

Example 13 with HistoricActivityInstance

use of org.activiti.engine.history.HistoricActivityInstance in project Activiti by Activiti.

the class HistoricActivityInstanceTest method testEventBasedGateway.

/**
   * Test to validate fix for ACT-1399: Boundary-event and event-based auditing
   */
@Deployment
public void testEventBasedGateway() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("catchSignal");
    Execution waitingExecution = runtimeService.createExecutionQuery().signalEventSubscriptionName("alert").singleResult();
    assertNotNull(waitingExecution);
    runtimeService.signalEventReceived("alert", waitingExecution.getId());
    assertEquals(0L, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
    HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("eventBasedgateway").processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(historicActivityInstance);
}
Also used : Execution(org.activiti.engine.runtime.Execution) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance) Deployment(org.activiti.engine.test.Deployment)

Example 14 with HistoricActivityInstance

use of org.activiti.engine.history.HistoricActivityInstance in project Activiti by Activiti.

the class HistoricActivityInstanceTest method testHistoricActivityInstanceNoop.

@Deployment
public void testHistoricActivityInstanceNoop() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("noopProcess");
    HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("noop").singleResult();
    assertEquals("noop", historicActivityInstance.getActivityId());
    assertEquals("serviceTask", historicActivityInstance.getActivityType());
    assertNotNull(historicActivityInstance.getProcessDefinitionId());
    assertEquals(processInstance.getId(), historicActivityInstance.getProcessInstanceId());
    assertEquals(processInstance.getId(), historicActivityInstance.getExecutionId());
    assertNotNull(historicActivityInstance.getStartTime());
    assertNotNull(historicActivityInstance.getEndTime());
    assertTrue(historicActivityInstance.getDurationInMillis() >= 0);
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance) Deployment(org.activiti.engine.test.Deployment)

Example 15 with HistoricActivityInstance

use of org.activiti.engine.history.HistoricActivityInstance in project Activiti by Activiti.

the class HistoricActivityInstanceTest method testBoundaryEvent.

/**
   * Test to validate fix for ACT-1399: Boundary-event and event-based auditing
   */
@Deployment
public void testBoundaryEvent() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("boundaryEventProcess");
    // Complete the task with the boundary-event on it
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(task);
    taskService.complete(task.getId());
    assertEquals(0L, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
    // Check if there is NO historic activity instance for a boundary-event that has not triggered
    HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("boundary").processInstanceId(processInstance.getId()).singleResult();
    assertNull(historicActivityInstance);
    // Now check the history when the boundary-event is fired
    processInstance = runtimeService.startProcessInstanceByKey("boundaryEventProcess");
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    runtimeService.signalEventReceived("alert", task.getExecutionId());
    assertEquals(0L, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
    historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("boundary").processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(historicActivityInstance);
}
Also used : Task(org.activiti.engine.task.Task) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance) Deployment(org.activiti.engine.test.Deployment)

Aggregations

HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)44 Deployment (org.activiti.engine.test.Deployment)30 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)24 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)18 Task (org.activiti.engine.task.Task)17 HashMap (java.util.HashMap)11 HistoricDetail (org.activiti.engine.history.HistoricDetail)6 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)6 DelegateTask (org.activiti.engine.delegate.DelegateTask)5 ArrayList (java.util.ArrayList)4 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)4 HistoricVariableUpdate (org.activiti.engine.history.HistoricVariableUpdate)4 HistoricActivityInstanceQuery (org.activiti.engine.history.HistoricActivityInstanceQuery)3 HistoricVariableInstanceQuery (org.activiti.engine.history.HistoricVariableInstanceQuery)3 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)3 Date (java.util.Date)2 AssertionFailedError (junit.framework.AssertionFailedError)2 BpmnModel (org.activiti.bpmn.model.BpmnModel)2 HistoricData (org.activiti.engine.history.HistoricData)2 HistoricActivityInstanceQueryImpl (org.activiti.engine.impl.HistoricActivityInstanceQueryImpl)2