use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class SecureScriptingBaseTest method assertProcessEnded.
public void assertProcessEnded(final String processInstanceId) {
ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (processInstance != null) {
throw new AssertionFailedError("Expected finished process instance '" + processInstanceId + "' but it was still in the db");
}
// Verify historical data if end times are correctly set
if (processEngine.getProcessEngineConfiguration().getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
// process instance
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
Assert.assertEquals(processInstanceId, historicProcessInstance.getId());
Assert.assertNotNull("Historic process instance has no start time", historicProcessInstance.getStartTime());
Assert.assertNotNull("Historic process instance has no end time", historicProcessInstance.getEndTime());
// tasks
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).list();
if (historicTaskInstances != null && historicTaskInstances.size() > 0) {
for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
Assert.assertEquals(processInstanceId, historicTaskInstance.getProcessInstanceId());
Assert.assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no start time", historicTaskInstance.getStartTime());
Assert.assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no end time", historicTaskInstance.getEndTime());
}
}
// activities
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();
if (historicActivityInstances != null && historicActivityInstances.size() > 0) {
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
Assert.assertEquals(processInstanceId, historicActivityInstance.getProcessInstanceId());
Assert.assertNotNull("Historic activity instance " + historicActivityInstance.getActivityId() + " has no start time", historicActivityInstance.getStartTime());
Assert.assertNotNull("Historic activity instance " + historicActivityInstance.getActivityId() + " has no end time", historicActivityInstance.getEndTime());
}
}
}
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class HistoricProcessInstanceQueryImpl method executeList.
public List<HistoricProcessInstance> executeList(CommandContext commandContext, Page page) {
checkQueryOk();
ensureVariablesInitialized();
List<HistoricProcessInstance> results = null;
if (includeProcessVariables) {
results = commandContext.getHistoricProcessInstanceEntityManager().findHistoricProcessInstancesAndVariablesByQueryCriteria(this);
} else {
results = commandContext.getHistoricProcessInstanceEntityManager().findHistoricProcessInstancesByQueryCriteria(this);
}
for (HistoricProcessInstance processInstance : results) {
localize(processInstance, commandContext);
}
return results;
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class CallActivityAdvancedTest method testCallSimpleSubProcess.
@Deployment(resources = { "org/activiti/engine/test/bpmn/callactivity/CallActivity.testCallSimpleSubProcess.bpmn20.xml", "org/activiti/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" })
public void testCallSimpleSubProcess() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callSimpleSubProcess");
// one task in the subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskBeforeSubProcess = taskQuery.singleResult();
assertEquals("Task before subprocess", taskBeforeSubProcess.getName());
// Completing the task continues the process which leads to calling the subprocess
taskService.complete(taskBeforeSubProcess.getId());
Task taskInSubProcess = taskQuery.singleResult();
assertEquals("Task in subprocess", taskInSubProcess.getName());
// Completing the task in the subprocess, finishes the subprocess
taskService.complete(taskInSubProcess.getId());
Task taskAfterSubProcess = taskQuery.singleResult();
assertEquals("Task after subprocess", taskAfterSubProcess.getName());
// Completing this task end the process instance
taskService.complete(taskAfterSubProcess.getId());
assertProcessEnded(processInstance.getId());
// Validate subprocess history
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
// Subprocess should have initial activity set
HistoricProcessInstance historicProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(taskInSubProcess.getProcessInstanceId()).singleResult();
assertNotNull(historicProcess);
assertEquals("theStart", historicProcess.getStartActivityId());
List<HistoricActivityInstance> historicInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(taskInSubProcess.getProcessInstanceId()).list();
// Should contain a start-event, the task and an end-event
assertEquals(3L, historicInstances.size());
Set<String> expectedActivities = new HashSet<String>(Arrays.asList(new String[] { "theStart", "task", "theEnd" }));
for (HistoricActivityInstance act : historicInstances) {
expectedActivities.remove(act.getActivityId());
}
assertTrue("Not all expected activities were found in the history", expectedActivities.isEmpty());
}
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class CallActivityAdvancedTest method testStartUserIdSetWhenLooping.
@Deployment(resources = { "org/activiti/engine/test/bpmn/callactivity/CallActivity.testStartUserIdSetWhenLooping.bpmn20.xml", "org/activiti/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" })
public void testStartUserIdSetWhenLooping() {
identityService.setAuthenticatedUserId("kermit");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("loopingCallActivity", CollectionUtil.singletonMap("input", 0));
for (int i = 1; i < 4; i++) {
Task task = taskService.createTaskQuery().singleResult();
assertEquals("Task in subprocess", task.getName());
identityService.setAuthenticatedUserId("kermit");
taskService.complete(task.getId(), CollectionUtil.singletonMap("input", i));
}
identityService.setAuthenticatedUserId(null);
Task task = taskService.createTaskQuery().singleResult();
assertEquals("Final task", task.getName());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().superProcessInstanceId(processInstance.getId()).list();
assertEquals(3, historicProcessInstances.size());
for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
assertNotNull(historicProcessInstance.getStartUserId());
assertNotNull(historicProcessInstance.getStartTime());
assertNotNull(historicProcessInstance.getEndTime());
}
}
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class TerminateEndEventTest method assertHistoricProcessInstanceDetails.
protected void assertHistoricProcessInstanceDetails(String processInstanceId) {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
assertHistoricProcessInstance(historicProcessInstance);
}
}
Aggregations