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