Search in sources :

Example 6 with HistoricVariableInstanceEntity

use of org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity in project Activiti by Activiti.

the class HistoricVariableInstanceTest method testTwoSubProcessInParallelWithinSubProcess.

@Deployment
public void testTwoSubProcessInParallelWithinSubProcess() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("twoSubProcessInParallelWithinSubProcess");
        assertProcessEnded(processInstance.getId());
        List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().orderByVariableName().asc().list();
        assertEquals(2, variables.size());
        HistoricVariableInstanceEntity historicVariable = (HistoricVariableInstanceEntity) variables.get(0);
        assertEquals("myVar", historicVariable.getName());
        assertEquals("test101112", historicVariable.getTextValue());
        HistoricVariableInstanceEntity historicVariable1 = (HistoricVariableInstanceEntity) variables.get(1);
        assertEquals("myVar1", historicVariable1.getName());
        assertEquals("test789", historicVariable1.getTextValue());
        assertEquals(18, historyService.createHistoricActivityInstanceQuery().count());
        assertEquals(7, historyService.createHistoricDetailQuery().count());
    }
}
Also used : HistoricVariableInstanceEntity(org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) Deployment(org.activiti.engine.test.Deployment)

Example 7 with HistoricVariableInstanceEntity

use of org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity in project Activiti by Activiti.

the class HistoricVariableInstanceTest method testSimpleNoWaitState.

@Deployment
public void testSimpleNoWaitState() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProc");
        assertProcessEnded(processInstance.getId());
        List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().list();
        assertEquals(1, variables.size());
        HistoricVariableInstanceEntity historicVariable = (HistoricVariableInstanceEntity) variables.get(0);
        assertEquals("test456", historicVariable.getTextValue());
        assertEquals(4, historyService.createHistoricActivityInstanceQuery().count());
        assertEquals(2, historyService.createHistoricDetailQuery().count());
    }
}
Also used : HistoricVariableInstanceEntity(org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) Deployment(org.activiti.engine.test.Deployment)

Example 8 with HistoricVariableInstanceEntity

use of org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity in project Activiti by Activiti.

the class HistoricVariableInstanceTest method testRestrictByExecutionId.

@Deployment
public void testRestrictByExecutionId() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProc");
        TaskQuery taskQuery = taskService.createTaskQuery();
        Task userTask = taskQuery.singleResult();
        assertEquals("userTask1", userTask.getName());
        taskService.complete(userTask.getId(), CollectionUtil.singletonMap("myVar", "test789"));
        assertProcessEnded(processInstance.getId());
        List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().executionId(processInstance.getId()).list();
        assertEquals(1, variables.size());
        HistoricVariableInstanceEntity historicVariable = (HistoricVariableInstanceEntity) variables.get(0);
        assertEquals("test456", historicVariable.getTextValue());
        assertEquals(5, historyService.createHistoricActivityInstanceQuery().count());
        assertEquals(3, historyService.createHistoricDetailQuery().count());
    }
}
Also used : Task(org.activiti.engine.task.Task) TaskQuery(org.activiti.engine.task.TaskQuery) HistoricVariableInstanceEntity(org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) Deployment(org.activiti.engine.test.Deployment)

Example 9 with HistoricVariableInstanceEntity

use of org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity in project Activiti by Activiti.

the class HistoricJPAVariableTest method testGetJPAEntityAsHistoricLog.

@Deployment
public void testGetJPAEntityAsHistoricLog() {
    setupJPAEntities();
    // -----------------------------------------------------------------------------
    // Simple test, Start process with JPA entities as variables
    // -----------------------------------------------------------------------------
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("simpleEntityFieldAccess", simpleEntityFieldAccess);
    // Start the process with the JPA-entities as variables. They will be stored in the DB.
    this.processInstanceId = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables).getId();
    // Finish tasks
    for (Task task : taskService.createTaskQuery().includeTaskLocalVariables().list()) {
        taskService.complete(task.getId());
    }
    // Get JPAEntity Variable by ProcessInstanceHistoryLogQuery
    ProcessInstanceHistoryLog log = historyService.createProcessInstanceHistoryLogQuery(processInstanceId).includeVariables().singleResult();
    List<HistoricData> events = log.getHistoricData();
    for (HistoricData event : events) {
        Object value = ((HistoricVariableInstanceEntity) event).getValue();
        assertTrue(value instanceof FieldAccessJPAEntity);
        assertEquals(((FieldAccessJPAEntity) value).getValue(), simpleEntityFieldAccess.getValue());
    }
}
Also used : Task(org.activiti.engine.task.Task) HistoricData(org.activiti.engine.history.HistoricData) HashMap(java.util.HashMap) ProcessInstanceHistoryLog(org.activiti.engine.history.ProcessInstanceHistoryLog) HistoricVariableInstanceEntity(org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity) Deployment(org.activiti.engine.test.Deployment)

Aggregations

HistoricVariableInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity)9 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)8 Deployment (org.activiti.engine.test.Deployment)7 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)6 Task (org.activiti.engine.task.Task)4 TaskQuery (org.activiti.engine.task.TaskQuery)3 HistoricData (org.activiti.engine.history.HistoricData)2 CacheableVariable (org.activiti.engine.impl.variable.CacheableVariable)2 HashMap (java.util.HashMap)1 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)1 HistoricVariableUpdate (org.activiti.engine.history.HistoricVariableUpdate)1 ProcessInstanceHistoryLog (org.activiti.engine.history.ProcessInstanceHistoryLog)1 HistoricProcessInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity)1