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());
}
}
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());
}
}
Aggregations