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