use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncAfterTest method testAsyncAfterServiceTask.
@Deployment
public void testAsyncAfterServiceTask() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess");
// listeners should be fired by now
assertListenerStartInvoked(pi);
assertListenerEndInvoked(pi);
// the process should wait *after* the catch event
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
// if the waiting job is executed, the process instance should end
managementService.executeJob(job.getId());
assertProcessEnded(pi.getId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncAfterTest method testAsyncAfterIntermediateCatchEvent.
@Deployment
public void testAsyncAfterIntermediateCatchEvent() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testIntermediateCatchEvent");
// the intermediate catch event is waiting for its message
runtimeService.correlateMessage("testMessage1");
// listeners should be fired by now
assertListenerStartInvoked(pi);
assertListenerEndInvoked(pi);
// the process should wait *after* the catch event
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
// if the waiting job is executed, the process instance should end
managementService.executeJob(job.getId());
assertProcessEnded(pi.getId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncTaskTest method testAsyncBeforeAndAfterParallelMultiInstanceWithAsyncBeforeAndAfterServiceWrappedInMultiInstance.
@Deployment
public void testAsyncBeforeAndAfterParallelMultiInstanceWithAsyncBeforeAndAfterServiceWrappedInMultiInstance() {
NUM_INVOCATIONS = 0;
// start process
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("asyncService");
// the service was not invoked:
assertEquals(0, NUM_INVOCATIONS);
// now there should be one job for the multi-instance body:
assertEquals(1, managementService.createJobQuery().count());
assertTransitionInstances(processInstance.getId(), "service" + BpmnParse.MULTI_INSTANCE_BODY_ID_SUFFIX, 1);
// when the mi body before job is executed
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
// then there are five inner async before jobs
List<Job> innerBeforeJobs = managementService.createJobQuery().list();
assertEquals(5, innerBeforeJobs.size());
assertTransitionInstances(processInstance.getId(), "service", 5);
assertEquals(0, NUM_INVOCATIONS);
// when executing all inner jobs
for (Job innerBeforeJob : innerBeforeJobs) {
managementService.executeJob(innerBeforeJob.getId());
}
assertEquals(5, NUM_INVOCATIONS);
// then there are five async after jobs
List<Job> innerAfterJobs = managementService.createJobQuery().list();
assertEquals(5, innerAfterJobs.size());
assertTransitionInstances(processInstance.getId(), "service", 5);
// when executing all inner jobs
for (Job innerAfterJob : innerAfterJobs) {
managementService.executeJob(innerAfterJob.getId());
}
// then there is one mi body after job
job = managementService.createJobQuery().singleResult();
assertNotNull(job);
assertTransitionInstances(processInstance.getId(), "service" + BpmnParse.MULTI_INSTANCE_BODY_ID_SUFFIX, 1);
// when executing this job, the process ends
managementService.executeJob(job.getId());
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncTaskTest method testFailingAsyncServiceTimer.
@Deployment
public void testFailingAsyncServiceTimer() {
// start process
runtimeService.startProcessInstanceByKey("asyncService");
// now there should be one job in the database, and it is a message
assertEquals(1, managementService.createJobQuery().count());
Job job = managementService.createJobQuery().singleResult();
if (!(job instanceof MessageEntity)) {
fail("the job must be a message");
}
executeAvailableJobs();
// the service failed: the execution is still sitting in the service task:
Execution execution = runtimeService.createExecutionQuery().singleResult();
assertNotNull(execution);
assertEquals("service", runtimeService.getActiveActivityIds(execution.getId()).get(0));
// there is still a single job because the timer was created in the same transaction as the
// service was executed (which rolled back)
assertEquals(1, managementService.createJobQuery().count());
runtimeService.deleteProcessInstance(execution.getId(), "dead");
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class FoxJobRetryCmdEventsTest method assertJobRetries.
protected void assertJobRetries(ProcessInstance pi) {
assertThat(pi, is(notNullValue()));
Job job = fetchJob(pi.getProcessInstanceId());
try {
engineRule.getManagementService().executeJob(job.getId());
} catch (Exception e) {
}
// update job
job = fetchJob(pi.getProcessInstanceId());
assertThat(job.getRetries(), is(4));
}
Aggregations