use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.
the class BoundaryTimerEventTest method testExpressionOnTimer.
@Deployment
public void testExpressionOnTimer() {
// Set the clock fixed
Date startTime = new Date();
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("duration", "PT1H");
// After process start, there should be a timer created
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testExpressionOnTimer", variables);
JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
List<Job> jobs = jobQuery.list();
assertEquals(1, jobs.size());
// 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());
// start execution listener is not executed
assertFalse(listenerExecutedStartEvent);
assertTrue(listenerExecutedEndEvent);
// which means the process has ended
assertProcessEnded(pi.getId());
}
use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.
the class ProcessInstanceQueryAndWithExceptionTest method testQueryWithException.
public void testQueryWithException() throws InterruptedException {
ProcessInstance processNoException = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY_NO_EXCEPTION);
ProcessInstanceQuery queryNoException = runtimeService.createProcessInstanceQuery();
assertEquals(1, queryNoException.count());
assertEquals(1, queryNoException.list().size());
assertEquals(processNoException.getId(), queryNoException.list().get(0).getId());
ProcessInstanceQuery queryWithException = runtimeService.createProcessInstanceQuery();
assertEquals(0, queryWithException.withJobException().count());
assertEquals(0, queryWithException.withJobException().list().size());
ProcessInstance processWithException1 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1);
JobQuery jobQuery1 = managementService.createJobQuery().processInstanceId(processWithException1.getId());
assertEquals(1, jobQuery1.withException().count());
assertEquals(1, jobQuery1.withException().list().size());
assertEquals(1, queryWithException.withJobException().count());
assertEquals(1, queryWithException.withJobException().list().size());
assertEquals(processWithException1.getId(), queryWithException.withJobException().list().get(0).getId());
ProcessInstance processWithException2 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2);
JobQuery jobQuery2 = managementService.createJobQuery().processInstanceId(processWithException2.getId());
assertEquals(2, jobQuery2.withException().count());
assertEquals(2, jobQuery2.withException().list().size());
assertEquals(2, queryWithException.withJobException().count());
assertEquals(2, queryWithException.withJobException().list().size());
assertEquals(processWithException1.getId(), queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1).list().get(0).getId());
assertEquals(processWithException2.getId(), queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2).list().get(0).getId());
}
use of org.activiti.engine.runtime.JobQuery in project herd by FINRAOS.
the class ActivitiServiceTest method testGetJobsWithExceptionByProcessInstanceId.
@Test
public void testGetJobsWithExceptionByProcessInstanceId() {
String processInstanceId = "processInstanceId";
JobQuery jobQuery = mock(JobQuery.class);
when(activitiManagementService.createJobQuery()).thenReturn(jobQuery);
when(jobQuery.withException()).thenReturn(jobQuery);
when(jobQuery.processInstanceId(processInstanceId)).thenReturn(jobQuery);
List<Job> expectedJobs = new ArrayList<>();
when(jobQuery.list()).thenReturn(expectedJobs);
List<Job> actualJobs = activitiService.getJobsWithExceptionByProcessInstanceId(processInstanceId);
assertSame(expectedJobs, actualJobs);
InOrder inOrder = inOrder(jobQuery);
inOrder.verify(jobQuery).withException();
inOrder.verify(jobQuery).processInstanceId(processInstanceId);
inOrder.verify(jobQuery).list();
inOrder.verifyNoMoreInteractions();
}
use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.
the class JobQueryTest method testQueryByInvalidProcessInstanceId.
public void testQueryByInvalidProcessInstanceId() {
JobQuery query = managementService.createJobQuery().processInstanceId("invalid");
verifyQueryResults(query, 0);
try {
managementService.createJobQuery().processInstanceId(null);
fail();
} catch (ActivitiIllegalArgumentException e) {
}
}
use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.
the class JobQueryTest method testQueryByRetriesLeft.
public void testQueryByRetriesLeft() {
JobQuery query = managementService.createJobQuery().withRetriesLeft();
verifyQueryResults(query, 4);
setRetries(processInstanceIdOne, 0);
// Re-running the query should give only 3 jobs now, since one job has retries=0
verifyQueryResults(query, 3);
}
Aggregations