Search in sources :

Example 6 with JobQuery

use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.

the class StartTimerEventTest method testExpressionStartTimerEvent.

@Deployment
public void testExpressionStartTimerEvent() throws Exception {
    // ACT-1415: fixed start-date is an expression
    JobQuery jobQuery = managementService.createJobQuery();
    assertEquals(1, jobQuery.count());
    processEngineConfiguration.getClock().setCurrentTime(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").parse("15/11/2036 11:12:30"));
    waitForJobExecutorToProcessAllJobs(5000L, 25L);
    List<ProcessInstance> pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").list();
    assertEquals(1, pi.size());
    assertEquals(0, jobQuery.count());
}
Also used : JobQuery(org.activiti.engine.runtime.JobQuery) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) SimpleDateFormat(java.text.SimpleDateFormat) Deployment(org.activiti.engine.test.Deployment)

Example 7 with JobQuery

use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.

the class StartTimerEventTest method testCycleDateStartTimerEvent.

// FIXME: This test likes to run in an endless loop when invoking the waitForJobExecutorOnCondition method
@Deployment
public void testCycleDateStartTimerEvent() throws Exception {
    processEngineConfiguration.getClock().setCurrentTime(new Date());
    // After process start, there should be timer created
    JobQuery jobQuery = managementService.createJobQuery();
    assertEquals(1, jobQuery.count());
    final ProcessInstanceQuery piq = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample");
    moveByMinutes(5);
    waitForJobExecutorOnCondition(10000, 500, new Callable<Boolean>() {

        public Boolean call() throws Exception {
            return 1 == piq.count();
        }
    });
    assertEquals(1, jobQuery.count());
    moveByMinutes(5);
    waitForJobExecutorOnCondition(10000, 500, new Callable<Boolean>() {

        public Boolean call() throws Exception {
            return 2 == piq.count();
        }
    });
    assertEquals(1, jobQuery.count());
    //have to manually delete pending timer
    cleanDB();
}
Also used : ProcessInstanceQuery(org.activiti.engine.runtime.ProcessInstanceQuery) JobQuery(org.activiti.engine.runtime.JobQuery) Date(java.util.Date) Deployment(org.activiti.engine.test.Deployment)

Example 8 with JobQuery

use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.

the class StartTimerEventTest method testTimerShouldNotBeRecreatedOnDeploymentCacheReboot.

@Deployment
public void testTimerShouldNotBeRecreatedOnDeploymentCacheReboot() {
    // Just to be sure, I added this test. Sounds like something that could easily happen
    // when the order of deploy/parsing is altered.
    // After process start, there should be timer created
    JobQuery jobQuery = managementService.createJobQuery();
    assertEquals(1, jobQuery.count());
    // Reset deployment cache
    processEngineConfiguration.getProcessDefinitionCache().clear();
    // Start one instance of the process definition, this will trigger a cache reload
    runtimeService.startProcessInstanceByKey("startTimer");
    // No new jobs should have been created
    assertEquals(1, jobQuery.count());
}
Also used : JobQuery(org.activiti.engine.runtime.JobQuery) Deployment(org.activiti.engine.test.Deployment)

Example 9 with JobQuery

use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.

the class StartTimerEventTest method testDurationStartTimerEvent.

@Deployment
public void testDurationStartTimerEvent() throws Exception {
    // Set the clock fixed
    Date startTime = new Date();
    // After process start, there should be timer created
    JobQuery jobQuery = managementService.createJobQuery();
    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);
    List<ProcessInstance> pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").list();
    assertEquals(1, pi.size());
    assertEquals(0, jobQuery.count());
}
Also used : JobQuery(org.activiti.engine.runtime.JobQuery) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Date(java.util.Date) Deployment(org.activiti.engine.test.Deployment)

Example 10 with JobQuery

use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.

the class ExclusiveTimerEventTest method testCatchingTimerEvent.

@Deployment
public void testCatchingTimerEvent() throws Exception {
    // Set the clock fixed
    Date startTime = new Date();
    // After process start, there should be 3 timers created
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("exclusiveTimers");
    JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
    assertEquals(3, jobQuery.count());
    // After setting the clock to time '50minutes and 5 seconds', the timers should fire
    processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + ((50 * 60 * 1000) + 5000)));
    waitForJobExecutorToProcessAllJobs(5000L, 100L);
    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)

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