Search in sources :

Example 26 with JobQuery

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());
}
Also used : JobQuery(org.activiti.engine.runtime.JobQuery)

Example 27 with JobQuery

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());
}
Also used : Execution(org.activiti.engine.runtime.Execution) HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) JobQuery(org.activiti.engine.runtime.JobQuery) Job(org.activiti.engine.runtime.Job) Deployment(org.activiti.engine.test.Deployment)

Example 28 with JobQuery

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());
}
Also used : Task(org.activiti.engine.task.Task) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) JobQuery(org.activiti.engine.runtime.JobQuery) Date(java.util.Date) Deployment(org.activiti.engine.test.Deployment)

Example 29 with JobQuery

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());
}
Also used : ProcessInstance(org.activiti.engine.runtime.ProcessInstance) JobQuery(org.activiti.engine.runtime.JobQuery) Date(java.util.Date) Deployment(org.activiti.engine.test.Deployment)

Example 30 with JobQuery

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);
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) JobQuery(org.activiti.engine.runtime.JobQuery) Job(org.activiti.engine.runtime.Job) Deployment(org.activiti.engine.test.Deployment)

Aggregations

JobQuery (org.activiti.engine.runtime.JobQuery)39 Deployment (org.activiti.engine.test.Deployment)20 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)17 Date (java.util.Date)15 Job (org.activiti.engine.runtime.Job)9 Task (org.activiti.engine.task.Task)5 HashMap (java.util.HashMap)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)2 Execution (org.activiti.engine.runtime.Execution)2 ProcessInstanceQuery (org.activiti.engine.runtime.ProcessInstanceQuery)2 Test (org.junit.Test)2 InOrder (org.mockito.InOrder)2 ArrayList (java.util.ArrayList)1 HistoricProcessInstanceQuery (org.activiti.engine.history.HistoricProcessInstanceQuery)1