use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class BoundaryTimerNonInterruptingEventTest method testTimerWithCycle.
@Deployment
public void testTimerWithCycle() throws Exception {
runtimeService.startProcessInstanceByKey("nonInterruptingCycle").getId();
List<Job> jobs = managementService.createJobQuery().list();
assertEquals(1, jobs.size());
//boundary events
try {
waitForJobExecutorToProcessAllJobs(2000, 100);
fail("a new job must be prepared because there are undefinite number of repeats 1 hour interval");
} catch (Exception ex) {
//expected exception because a new job is prepared
}
moveByMinutes(60);
try {
waitForJobExecutorToProcessAllJobs(2000, 100);
fail("a new job must be prepared because there are undefinite number of repeats 1 hour interval");
} catch (Exception ex) {
//expected exception because a new job is prepared
}
Task task = taskService.createTaskQuery().taskDefinitionKey("task").singleResult();
taskService.complete(task.getId());
moveByMinutes(60);
try {
waitForJobExecutorToProcessAllJobs(2000, 100);
} catch (Exception ex) {
fail("No more jobs since the user completed the task");
}
}
use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class IntermediateTimerEventTest method testExpression.
@Deployment
public void testExpression() {
// Set the clock fixed
HashMap<String, Object> variables1 = new HashMap<String, Object>();
variables1.put("dueDate", new Date());
HashMap<String, Object> variables2 = new HashMap<String, Object>();
variables2.put("dueDate", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date()));
// After process start, there should be timer created
ProcessInstance pi1 = runtimeService.startProcessInstanceByKey("intermediateTimerEventExample", variables1);
ProcessInstance pi2 = runtimeService.startProcessInstanceByKey("intermediateTimerEventExample", variables2);
assertEquals(1, managementService.createJobQuery().processInstanceId(pi1.getId()).count());
assertEquals(1, managementService.createJobQuery().processInstanceId(pi2.getId()).count());
// After setting the clock to one second in the future the timers should fire
List<Job> jobs = managementService.createJobQuery().executable().list();
assertEquals(2, jobs.size());
for (Job job : jobs) {
managementService.executeJob(job.getId());
}
assertEquals(0, managementService.createJobQuery().processInstanceId(pi1.getId()).count());
assertEquals(0, managementService.createJobQuery().processInstanceId(pi2.getId()).count());
assertProcessEnded(pi1.getProcessInstanceId());
assertProcessEnded(pi2.getProcessInstanceId());
}
use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class IntermediateTimerEventTest method testLoop.
@Deployment
public void testLoop() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testLoop");
// After looping 3 times, the process should end
for (int i = 0; i < 3; i++) {
Job timer = managementService.createJobQuery().singleResult();
managementService.executeJob(timer.getId());
}
assertProcessEnded(processInstance.getId());
}
use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class IntermediateTimerEventTest method testLoopWithCycle.
@Deployment
public void testLoopWithCycle() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testLoop");
// After looping 3 times, the process should end. Cycle should NOT repeat itself
for (int i = 0; i < 3; i++) {
Job timer = managementService.createJobQuery().singleResult();
managementService.executeJob(timer.getId());
}
assertProcessEnded(processInstance.getId());
}
use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class BoundaryTimerEventTest method testTimerOnNestingOfSubprocesses.
@Deployment
public void testTimerOnNestingOfSubprocesses() {
Date testStartTime = processEngineConfiguration.getClock().getCurrentTime();
runtimeService.startProcessInstanceByKey("timerOnNestedSubprocesses");
List<Task> tasks = taskService.createTaskQuery().orderByTaskName().asc().list();
assertEquals(2, tasks.size());
assertEquals("Inner subprocess task 1", tasks.get(0).getName());
assertEquals("Inner subprocess task 2", tasks.get(1).getName());
// Timer will fire in 2 hours
processEngineConfiguration.getClock().setCurrentTime(new Date(testStartTime.getTime() + ((2 * 60 * 60 * 1000) + 5000)));
Job timer = managementService.createJobQuery().timers().singleResult();
managementService.executeJob(timer.getId());
Task task = taskService.createTaskQuery().singleResult();
assertEquals("task outside subprocess", task.getName());
}
Aggregations