Search in sources :

Example 11 with ProcessInstanceHistoryLog

use of org.activiti.engine.history.ProcessInstanceHistoryLog 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)

Example 12 with ProcessInstanceHistoryLog

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

the class HistoricJPAVariableTest method testGetJPAUpdateEntityAsHistoricLog.

@Deployment(resources = { "org/activiti/standalone/jpa/HistoricJPAVariableTest.testGetJPAEntityAsHistoricLog.bpmn20.xml" })
public void testGetJPAUpdateEntityAsHistoricLog() {
    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().includeProcessVariables().list()) {
        taskService.setVariable(task.getId(), "simpleEntityFieldAccess", simpleEntityFieldAccess);
        taskService.complete(task.getId());
    }
    // Get JPAEntity Variable by ProcessInstanceHistoryLogQuery
    ProcessInstanceHistoryLog log = historyService.createProcessInstanceHistoryLogQuery(processInstanceId).includeVariableUpdates().singleResult();
    List<HistoricData> events = log.getHistoricData();
    for (HistoricData event : events) {
        Object value = ((HistoricDetailVariableInstanceUpdateEntity) 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) HistoricDetailVariableInstanceUpdateEntity(org.activiti.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity) Deployment(org.activiti.engine.test.Deployment)

Aggregations

ProcessInstanceHistoryLog (org.activiti.engine.history.ProcessInstanceHistoryLog)12 HistoricData (org.activiti.engine.history.HistoricData)11 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)3 HashMap (java.util.HashMap)2 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)2 HistoricVariableUpdate (org.activiti.engine.history.HistoricVariableUpdate)2 Comment (org.activiti.engine.task.Comment)2 Task (org.activiti.engine.task.Task)2 Deployment (org.activiti.engine.test.Deployment)2 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)1 HistoricDetailVariableInstanceUpdateEntity (org.activiti.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity)1 HistoricVariableInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity)1