use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class MultiInstanceTest method testRunProcess.
@Deployment(resources = { "process/multiinstanceReceive.bpmn20.xml" })
public void testRunProcess() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miProcessExample");
List<Job> jobList = managementService.createJobQuery().list();
assertEquals(5, jobList.size());
assertEquals(5, runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId("serviceTask1").count());
waitForJobExecutorToProcessAllJobs(3000, 500);
int counter = 0;
long processInstanceCount = 1;
while (processInstanceCount == 1 && counter < 20) {
Thread.sleep(500);
processInstanceCount = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count();
counter++;
}
assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
}
use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class CamelExceptionTest method testHappyPathAsynchronous.
// check happy path in asynchronous camel call
@Deployment(resources = { "org/activiti/camel/exception/bpmnExceptionInRouteAsynchronous.bpmn20.xml" })
public void testHappyPathAsynchronous() {
// Signal ThrowBpmnExceptionBean to throw no exception
ThrowBpmnExceptionBean.setExceptionType(ThrowBpmnExceptionBean.ExceptionType.NO_EXCEPTION);
runtimeService.startProcessInstanceByKey("exceptionInRouteSynchron");
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
assertFalse(JobTestHelper.areJobsAvailable(managementService));
assertFalse(ExceptionServiceMock.isCalled());
assertTrue(NoExceptionServiceMock.isCalled());
}
use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class ErrorHandlingTest method testCamelRouteWorksAsIntended.
/**
* Process instance should be removed after completion. Works as intended,
* if no exception interrupts the Camel route.
*
* @throws Exception
*/
@Deployment(resources = { "process/errorHandling.bpmn20.xml" })
public void testCamelRouteWorksAsIntended() throws Exception {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("routing", Routing.DEFAULT);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ErrorHandling", variables);
Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(job);
managementService.executeJob(job.getId());
Thread.sleep(WAIT);
assertEquals("Process instance not completed", 0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
}
use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class JobQueryTest method verifyFailedJob.
private void verifyFailedJob(JobQuery query, ProcessInstance processInstance) {
verifyQueryResults(query, 1);
Job failedJob = query.singleResult();
assertNotNull(failedJob);
assertEquals(processInstance.getId(), failedJob.getProcessInstanceId());
assertNotNull(failedJob.getExceptionMessage());
assertTextPresent(EXCEPTION_MESSAGE, failedJob.getExceptionMessage());
}
use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class ProcessInstanceSuspensionTest method testJobsNotVisisbleToAcquisitionIfDefinitionSuspended.
@Deployment(resources = { "org/activiti/engine/test/db/oneJobProcess.bpmn20.xml" })
public void testJobsNotVisisbleToAcquisitionIfDefinitionSuspended() {
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().singleResult();
runtimeService.startProcessInstanceByKey(pd.getKey());
// now there is one job:
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
makeSureJobDue(job);
// the acquirejobs command sees the job:
AcquiredJobEntities acquiredJobs = executeAcquireJobsCommand();
assertEquals(1, acquiredJobs.size());
// suspend the process instance:
repositoryService.suspendProcessDefinitionById(pd.getId());
// now, the acquirejobs command does not see the job:
acquiredJobs = executeAcquireJobsCommand();
assertEquals(0, acquiredJobs.size());
}
Aggregations