use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.
the class JobQueryEscapeClauseTest method testQueryByTenantIdLike.
public void testQueryByTenantIdLike() {
JobQuery query = managementService.createJobQuery().jobTenantIdLike("%\\%%");
assertEquals("tenant%", query.singleResult().getTenantId());
assertEquals(1, query.list().size());
assertEquals(1, query.count());
query = managementService.createJobQuery().jobTenantIdLike("%\\_%");
assertEquals("tenant_", query.singleResult().getTenantId());
assertEquals(1, query.list().size());
assertEquals(1, query.count());
query = managementService.createJobQuery().jobTenantIdLike("%test%");
assertEquals("test", query.singleResult().getTenantId());
assertEquals(1, query.list().size());
assertEquals(1, query.count());
}
use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.
the class BoundaryTimerNonInterruptingEventTest method testReceiveTaskWithBoundaryTimer.
@Deployment
public /**
* see https://activiti.atlassian.net/browse/ACT-1106
*/
void testReceiveTaskWithBoundaryTimer() {
// Set the clock fixed
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("timeCycle", "R/PT1H");
// After process start, there should be a timer created
ProcessInstance pi = runtimeService.startProcessInstanceByKey("nonInterruptingCycle", variables);
JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
List<Job> jobs = jobQuery.list();
assertEquals(1, jobs.size());
// The Execution Query should work normally and find executions in state "task"
List<Execution> executions = runtimeService.createExecutionQuery().activityId("task").list();
assertEquals(1, executions.size());
List<String> activeActivityIds = runtimeService.getActiveActivityIds(executions.get(0).getId());
assertEquals(1, activeActivityIds.size());
assertEquals("task", activeActivityIds.get(0));
runtimeService.signal(executions.get(0).getId());
// // After setting the clock to time '1 hour and 5 seconds', the second timer should fire
// processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + ((60 * 60 * 1000) + 5000)));
// waitForJobExecutorToProcessAllJobs(5000L, 25L);
// assertEquals(0L, jobQuery.count());
// which means the process has ended
assertProcessEnded(pi.getId());
}
use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.
the class IntermediateTimerEventTest method testTimerEventWithStartAndDuration.
@Deployment
public void testTimerEventWithStartAndDuration() throws Exception {
Date testStartTime = new Date();
processEngineConfiguration.getClock().setCurrentTime(testStartTime);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("timerEventWithStartAndDuration");
List<Task> tasks = taskService.createTaskQuery().list();
assertEquals(1, tasks.size());
Task task = tasks.get(0);
assertEquals("Task A", task.getName());
JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
assertEquals(0, jobQuery.count());
Date startDate = new Date();
runtimeService.setVariable(pi.getId(), "StartDate", startDate);
taskService.complete(task.getId());
jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
assertEquals(1, jobQuery.count());
processEngineConfiguration.getClock().setCurrentTime(new Date(startDate.getTime() + 7000L));
jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
assertEquals(1, jobQuery.count());
jobQuery = managementService.createJobQuery().processInstanceId(pi.getId()).executable();
assertEquals(0, jobQuery.count());
processEngineConfiguration.getClock().setCurrentTime(new Date(startDate.getTime() + 11000L));
waitForJobExecutorToProcessAllJobs(15000L, 25L);
jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
assertEquals(0, jobQuery.count());
tasks = taskService.createTaskQuery().list();
assertEquals(1, tasks.size());
task = tasks.get(0);
assertEquals("Task B", task.getName());
taskService.complete(task.getId());
assertProcessEnded(pi.getProcessInstanceId());
}
use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.
the class IntermediateTimerEventTest method testCatchingTimerEvent.
@Deployment
public void testCatchingTimerEvent() throws Exception {
// Set the clock fixed
Date startTime = new Date();
// After process start, there should be timer created
ProcessInstance pi = runtimeService.startProcessInstanceByKey("intermediateTimerEventExample");
JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
assertEquals(1, jobQuery.count());
// After setting the clock to time '50minutes and 5 seconds', the second timer should fire
processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + ((50 * 60 * 1000) + 5000)));
waitForJobExecutorToProcessAllJobs(5000L, 25L);
assertEquals(0, jobQuery.count());
assertProcessEnded(pi.getProcessInstanceId());
}
use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.
the class BoundaryTimerEventTest method testNullExpressionOnTimer.
@Deployment
public void testNullExpressionOnTimer() {
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("duration", null);
// After process start, there should be a timer created
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testNullExpressionOnTimer", variables);
//NO job scheduled as null expression set
JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
List<Job> jobs = jobQuery.list();
assertEquals(0, jobs.size());
// which means the process is still running waiting for human task input.
ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(pi.getId()).singleResult();
assertNotNull(processInstance);
}
Aggregations