use of org.activiti.engine.history.HistoricActivityInstance in project Activiti by Activiti.
the class TenancyTest method testHistoryTenancy.
public void testHistoryTenancy() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
// Generate 3 tasks with tenant
String processDefinitionIdWithTenant = deployTestProcessWithTestTenant();
int nrOfProcessInstancesWithTenant = 3;
for (int i = 0; i < nrOfProcessInstancesWithTenant; i++) {
runtimeService.startProcessInstanceById(processDefinitionIdWithTenant);
}
// Generate 2 tasks without tenant
String processDefinitionIdNoTenant = deployOneTaskTestProcess();
int nrOfProcessInstancesNoTenant = 2;
for (int i = 0; i < nrOfProcessInstancesNoTenant; i++) {
runtimeService.startProcessInstanceById(processDefinitionIdNoTenant);
}
// Complete all tasks
for (Task task : taskService.createTaskQuery().list()) {
taskService.complete(task.getId());
}
// Verify process instances
assertEquals(TEST_TENANT_ID, historyService.createHistoricProcessInstanceQuery().processDefinitionId(processDefinitionIdWithTenant).list().get(0).getTenantId());
assertEquals("", historyService.createHistoricProcessInstanceQuery().processDefinitionId(processDefinitionIdNoTenant).list().get(0).getTenantId());
assertEquals(nrOfProcessInstancesWithTenant + nrOfProcessInstancesNoTenant, historyService.createHistoricProcessInstanceQuery().list().size());
assertEquals(nrOfProcessInstancesWithTenant, historyService.createHistoricProcessInstanceQuery().processInstanceTenantId(TEST_TENANT_ID).list().size());
assertEquals(nrOfProcessInstancesWithTenant, historyService.createHistoricProcessInstanceQuery().processInstanceTenantIdLike("%e%").list().size());
assertEquals(nrOfProcessInstancesNoTenant, historyService.createHistoricProcessInstanceQuery().processInstanceWithoutTenantId().list().size());
// verify tasks
assertEquals(TEST_TENANT_ID, historyService.createHistoricTaskInstanceQuery().processDefinitionId(processDefinitionIdWithTenant).list().get(0).getTenantId());
assertEquals("", historyService.createHistoricTaskInstanceQuery().processDefinitionId(processDefinitionIdNoTenant).list().get(0).getTenantId());
assertEquals(nrOfProcessInstancesWithTenant + nrOfProcessInstancesNoTenant, historyService.createHistoricTaskInstanceQuery().list().size());
assertEquals(nrOfProcessInstancesWithTenant, historyService.createHistoricTaskInstanceQuery().taskTenantId(TEST_TENANT_ID).list().size());
assertEquals(nrOfProcessInstancesWithTenant, historyService.createHistoricTaskInstanceQuery().taskTenantIdLike("my%").list().size());
assertEquals(nrOfProcessInstancesNoTenant, historyService.createHistoricTaskInstanceQuery().taskWithoutTenantId().list().size());
// verify activities
List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().processDefinitionId(processDefinitionIdWithTenant).list();
for (HistoricActivityInstance historicActivityInstance : activityInstances) {
assertEquals(TEST_TENANT_ID, historicActivityInstance.getTenantId());
}
assertEquals("", historyService.createHistoricActivityInstanceQuery().processDefinitionId(processDefinitionIdNoTenant).list().get(0).getTenantId());
assertEquals(3 * (nrOfProcessInstancesWithTenant + nrOfProcessInstancesNoTenant), historyService.createHistoricActivityInstanceQuery().list().size());
assertEquals(3 * nrOfProcessInstancesWithTenant, historyService.createHistoricActivityInstanceQuery().activityTenantId(TEST_TENANT_ID).list().size());
assertEquals(3 * nrOfProcessInstancesWithTenant, historyService.createHistoricActivityInstanceQuery().activityTenantIdLike("my%").list().size());
assertEquals(3 * nrOfProcessInstancesNoTenant, historyService.createHistoricActivityInstanceQuery().activityWithoutTenantId().list().size());
}
}
use of org.activiti.engine.history.HistoricActivityInstance in project Activiti by Activiti.
the class TaskServiceTest method testGetVariableByHistoricActivityInstance.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testGetVariableByHistoricActivityInstance() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
assertNotNull(processInstance);
Task task = taskService.createTaskQuery().singleResult();
taskService.setVariable(task.getId(), "variable1", "value1");
taskService.setVariable(task.getId(), "variable1", "value2");
HistoricActivityInstance historicActivitiInstance = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).activityId("theTask").singleResult();
assertNotNull(historicActivitiInstance);
List<HistoricDetail> resultSet = historyService.createHistoricDetailQuery().variableUpdates().activityInstanceId(historicActivitiInstance.getId()).orderByTime().asc().list();
assertEquals(2, resultSet.size());
assertEquals("variable1", ((HistoricVariableUpdate) resultSet.get(0)).getVariableName());
assertEquals("value1", ((HistoricVariableUpdate) resultSet.get(0)).getValue());
assertEquals("variable1", ((HistoricVariableUpdate) resultSet.get(1)).getVariableName());
assertEquals("value2", ((HistoricVariableUpdate) resultSet.get(1)).getValue());
}
use of org.activiti.engine.history.HistoricActivityInstance in project Activiti by Activiti.
the class MultiInstanceTest method testParallelScriptTasksHistory.
@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelScriptTasks.bpmn20.xml" })
public void testParallelScriptTasksHistory() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("sum", 0);
vars.put("nrOfLoops", 4);
runtimeService.startProcessInstanceByKey("miParallelScriptTask", vars);
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("scriptTask").list();
assertEquals(4, historicActivityInstances.size());
for (HistoricActivityInstance hai : historicActivityInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getStartTime());
}
}
}
use of org.activiti.engine.history.HistoricActivityInstance in project Activiti by Activiti.
the class MultiInstanceTest method testSequentialSubProcessHistory.
@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testSequentialSubProcess.bpmn20.xml" })
public void testSequentialSubProcessHistory() {
runtimeService.startProcessInstanceByKey("miSequentialSubprocess");
for (int i = 0; i < 4; i++) {
List<Task> tasks = taskService.createTaskQuery().list();
taskService.complete(tasks.get(0).getId());
taskService.complete(tasks.get(1).getId());
}
// Validate history
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
List<HistoricActivityInstance> onlySubProcessInstances = historyService.createHistoricActivityInstanceQuery().activityType("subProcess").list();
assertEquals(4, onlySubProcessInstances.size());
List<HistoricActivityInstance> historicInstances = historyService.createHistoricActivityInstanceQuery().activityType("subProcess").list();
assertEquals(4, historicInstances.size());
for (HistoricActivityInstance hai : historicInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
historicInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
assertEquals(8, historicInstances.size());
for (HistoricActivityInstance hai : historicInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
}
}
Aggregations