use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class MultiInstanceTest method testMultiInstanceSequentialReceiveTask.
@Deployment
public void testMultiInstanceSequentialReceiveTask() {
runtimeService.startProcessInstanceByKey("multi-instance-receive");
Execution execution = runtimeService.createExecutionQuery().activityId("theReceiveTask").singleResult();
assertNotNull(execution);
// Complete all four of the executions
while (execution != null) {
runtimeService.signal(execution.getId());
execution = runtimeService.createExecutionQuery().activityId("theReceiveTask").singleResult();
}
// There is one task after the task
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
taskService.complete(task.getId());
assertEquals(0, runtimeService.createExecutionQuery().count());
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class MultiInstanceTest method testSequentialScriptTasks.
@Deployment
public void testSequentialScriptTasks() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("sum", 0);
vars.put("nrOfLoops", 5);
runtimeService.startProcessInstanceByKey("miSequentialScriptTask", vars);
Execution waitStateExecution = runtimeService.createExecutionQuery().singleResult();
int sum = (Integer) runtimeService.getVariable(waitStateExecution.getId(), "sum");
assertEquals(10, sum);
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class RestResponseFactory method createExecutionResponseList.
public List<ExecutionResponse> createExecutionResponseList(List<Execution> executions) {
RestUrlBuilder urlBuilder = createUrlBuilder();
List<ExecutionResponse> responseList = new ArrayList<ExecutionResponse>();
for (Execution instance : executions) {
responseList.add(createExecutionResponse(instance, urlBuilder));
}
return responseList;
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class AsyncTaskTest method testFailingAsyncServiceTimer.
@Deployment
public void testFailingAsyncServiceTimer() {
// start process
runtimeService.startProcessInstanceByKey("asyncService");
// now there should be one job in the database, and it is a message
assertEquals(1, managementService.createJobQuery().count());
Job job = managementService.createJobQuery().singleResult();
if (!(job instanceof MessageEntity)) {
fail("the job must be a message");
}
try {
managementService.executeJob(job.getId());
fail();
} catch (Exception e) {
// exception expected
}
// the service failed: the execution is still sitting in the service task:
Execution execution = runtimeService.createExecutionQuery().singleResult();
assertNotNull(execution);
assertEquals("service", runtimeService.getActiveActivityIds(execution.getId()).get(0));
// there is still a single job because the timer was created in the same transaction as the
// service was executed (which rolled back)
assertEquals(1, managementService.createJobQuery().count());
runtimeService.deleteProcessInstance(execution.getId(), "dead");
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class AsyncTaskTest method FAILING_testFailingAsycServiceTimer.
// TODO: Think about this:
@Deployment
public void FAILING_testFailingAsycServiceTimer() {
// start process
runtimeService.startProcessInstanceByKey("asyncService");
// now there are two jobs the message and a timer:
assertEquals(2, managementService.createJobQuery().count());
// let 'max-retires' on the message be reached
waitForJobExecutorToProcessAllJobs(10000L, 100L);
// the service failed: the execution is still sitting in the service task:
Execution execution = runtimeService.createExecutionQuery().singleResult();
assertNotNull(execution);
assertEquals("service", runtimeService.getActiveActivityIds(execution.getId()).get(0));
// there are tow jobs, the message and the timer (the message will not be retried anymore, max retires is reached.)
assertEquals(2, managementService.createJobQuery().count());
// now the timer triggers:
Context.getProcessEngineConfiguration().getClock().setCurrentTime(new Date(System.currentTimeMillis() + 10000));
waitForJobExecutorToProcessAllJobs(10000L, 100L);
// and we are done:
assertNull(runtimeService.createExecutionQuery().singleResult());
// and there are no more jobs left:
assertEquals(0, managementService.createJobQuery().count());
}
Aggregations