Search in sources :

Example 26 with HistoricActivityInstance

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

the class CallActivityTest method testNotInheritVariablesSubprocess.

public void testNotInheritVariablesSubprocess() throws Exception {
    BpmnModel mainBpmnModel = loadBPMNModel(NOT_INHERIT_VARIABLES_MAIN_PROCESS_RESOURCE);
    BpmnModel childBpmnModel = loadBPMNModel(INHERIT_VARIABLES_CHILD_PROCESS_RESOURCE);
    processEngine.getRepositoryService().createDeployment().name("childProcessDeployment").addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();
    processEngine.getRepositoryService().createDeployment().name("mainProcessDeployment").addBpmnModel("mainProcess.bpmn20.xml", mainBpmnModel).deploy();
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("var1", "String test value");
    variables.put("var2", true);
    variables.put("var3", 12345);
    variables.put("var4", 67890);
    ProcessInstance mainProcessInstance = runtimeService.startProcessInstanceByKey("mainProcess", variables);
    HistoricActivityInstanceQuery activityInstanceQuery = historyService.createHistoricActivityInstanceQuery();
    activityInstanceQuery.processInstanceId(mainProcessInstance.getId());
    activityInstanceQuery.activityId("childProcessCall");
    HistoricActivityInstance activityInstance = activityInstanceQuery.singleResult();
    String calledInstanceId = activityInstance.getCalledProcessInstanceId();
    HistoricVariableInstanceQuery variableInstanceQuery = historyService.createHistoricVariableInstanceQuery();
    variableInstanceQuery.processInstanceId(calledInstanceId);
    List<HistoricVariableInstance> variableInstances = variableInstanceQuery.list();
    assertEquals(0, variableInstances.size());
}
Also used : HistoricActivityInstanceQuery(org.activiti.engine.history.HistoricActivityInstanceQuery) HashMap(java.util.HashMap) HistoricVariableInstanceQuery(org.activiti.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) BpmnModel(org.activiti.bpmn.model.BpmnModel) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance)

Example 27 with HistoricActivityInstance

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

the class SubProcessTest method testSimpleSubProcessWithTimer.

@Deployment
public void testSimpleSubProcessWithTimer() {
    Date startTime = new Date();
    // After staring the process, the task in the subprocess should be active
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("simpleSubProcess");
    Task subProcessTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Task in subprocess", subProcessTask.getName());
    // Setting the clock forward 2 hours 1 second (timer fires in 2 hours) and fire up the job executor 
    processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + (2 * 60 * 60 * 1000) + 1000));
    waitForJobExecutorToProcessAllJobs(5000L, 50L);
    // The subprocess should be left, and the escalated task should be active
    Task escalationTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Fix escalated problem", escalationTask.getName());
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
        // Verify history for task that was killed
        HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskName("Task in subprocess").singleResult();
        assertNotNull(historicTaskInstance.getEndTime());
        HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("subProcessTask").singleResult();
        assertNotNull(historicActivityInstance.getEndTime());
    }
}
Also used : Task(org.activiti.engine.task.Task) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Date(java.util.Date) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance) Deployment(org.activiti.engine.test.Deployment)

Example 28 with HistoricActivityInstance

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

the class MultiInstanceTest method testParallelCallActivityHistory.

@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelCallActivity.bpmn20.xml", "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.externalSubProcess.bpmn20.xml" })
public void testParallelCallActivityHistory() {
    runtimeService.startProcessInstanceByKey("miParallelCallActivity");
    List<Task> tasks = taskService.createTaskQuery().list();
    assertEquals(12, tasks.size());
    for (int i = 0; i < tasks.size(); i++) {
        taskService.complete(tasks.get(i).getId());
    }
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        // Validate historic processes
        List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
        // 6 subprocesses + main process
        assertEquals(7, historicProcessInstances.size());
        for (HistoricProcessInstance hpi : historicProcessInstances) {
            assertNotNull(hpi.getStartTime());
            assertNotNull(hpi.getEndTime());
        }
        // Validate historic tasks
        List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list();
        assertEquals(12, historicTaskInstances.size());
        for (HistoricTaskInstance hti : historicTaskInstances) {
            assertNotNull(hti.getStartTime());
            assertNotNull(hti.getEndTime());
            assertNotNull(hti.getAssignee());
            assertEquals("completed", hti.getDeleteReason());
        }
        // Validate historic activities
        List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("callActivity").list();
        assertEquals(6, historicActivityInstances.size());
        for (HistoricActivityInstance hai : historicActivityInstances) {
            assertNotNull(hai.getStartTime());
            assertNotNull(hai.getEndTime());
        }
    }
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance) Deployment(org.activiti.engine.test.Deployment)

Example 29 with HistoricActivityInstance

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

the class MultiInstanceTest method testParallelUserTasksHistory.

@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelUserTasks.bpmn20.xml" })
public void testParallelUserTasksHistory() {
    runtimeService.startProcessInstanceByKey("miParallelUserTasks");
    for (Task task : taskService.createTaskQuery().list()) {
        taskService.complete(task.getId());
    }
    // Validate history
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        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());
        }
        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());
        }
    }
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance) Deployment(org.activiti.engine.test.Deployment)

Example 30 with HistoricActivityInstance

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

the class MultiInstanceTest method testParallelSubProcessHistory.

@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelSubProcess.bpmn20.xml" })
public void testParallelSubProcessHistory() {
    runtimeService.startProcessInstanceByKey("miParallelSubprocess");
    for (Task task : taskService.createTaskQuery().list()) {
        taskService.complete(task.getId());
    }
    // Validate history
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityId("miSubProcess").list();
        assertEquals(2, historicActivityInstances.size());
        for (HistoricActivityInstance hai : historicActivityInstances) {
            assertNotNull(hai.getStartTime());
            assertNotNull(hai.getEndTime());
        }
    }
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) 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