use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class HistoryServiceTest method testHistoricProcessInstanceQueryOrderBy.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testHistoricProcessInstanceQueryOrderBy() {
// With a clean ProcessEngine, no instances should be available
assertTrue(historyService.createHistoricProcessInstanceQuery().count() == 0);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertEquals(1, tasks.size());
taskService.complete(tasks.get(0).getId());
historyService.createHistoricTaskInstanceQuery().orderByDeleteReason().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByExecutionId().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByHistoricActivityInstanceId().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByHistoricTaskInstanceStartTime().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByHistoricTaskInstanceDuration().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByHistoricTaskInstanceEndTime().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByProcessDefinitionId().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByProcessInstanceId().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByTaskAssignee().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByTaskDefinitionKey().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByTaskDescription().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByTaskId().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByTaskName().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByTaskOwner().asc().list();
historyService.createHistoricTaskInstanceQuery().orderByTaskPriority().asc().list();
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class HistoryServiceTest method testHistoricVariableInstancesOnParallelExecution.
@Deployment(resources = { "org/activiti/engine/test/api/runtime/concurrentExecution.bpmn20.xml" })
public void testHistoricVariableInstancesOnParallelExecution() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("rootValue", "test");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("concurrent", vars);
List<Task> tasks = taskService.createTaskQuery().processInstanceId(pi.getId()).list();
for (Task task : tasks) {
Map<String, Object> variables = new HashMap<String, Object>();
// set token local variable
log.debug("setting variables on task {}, execution {}", task.getId(), task.getExecutionId());
runtimeService.setVariableLocal(task.getExecutionId(), "parallelValue1", task.getName());
runtimeService.setVariableLocal(task.getExecutionId(), "parallelValue2", "test");
taskService.complete(task.getId(), variables);
}
taskService.complete(taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult().getId());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("rootValue", "test").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("parallelValue1", "Receive Payment").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("parallelValue1", "Ship Order").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("parallelValue2", "test").count());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class JobQueryTest method startProcessInstanceWithFailingJob.
private ProcessInstance startProcessInstanceWithFailingJob() {
// start a process with a failing job
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exceptionInJobExecution");
// The execution is waiting in the first usertask. This contains a boundary
// timer event which we will execute manual for testing purposes.
Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull("No job found for process instance", timerJob);
try {
managementService.executeJob(timerJob.getId());
fail("RuntimeException from within the script task expected");
} catch (RuntimeException re) {
assertTextPresent(EXCEPTION_MESSAGE, re.getCause().getMessage());
}
return processInstance;
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ManagementServiceTest method testDeleteJobDeletion.
@Deployment(resources = { "org/activiti/engine/test/api/mgmt/timerOnTask.bpmn20.xml" })
public void testDeleteJobDeletion() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnTask");
Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull("Task timer should be there", timerJob);
managementService.deleteJob(timerJob.getId());
timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNull("There should be no job now. It was deleted", timerJob);
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ManagementServiceTest method testSetJobRetries.
@Deployment(resources = { "org/activiti/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml" })
public void testSetJobRetries() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exceptionInJobExecution");
// The execution is waiting in the first usertask. This contains a boundary
// timer event.
Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
Date duedate = timerJob.getDuedate();
assertNotNull("No job found for process instance", timerJob);
assertEquals(JobEntity.DEFAULT_RETRIES, timerJob.getRetries());
managementService.setJobRetries(timerJob.getId(), 5);
timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertEquals(5, timerJob.getRetries());
assertEquals(duedate, timerJob.getDuedate());
}
Aggregations