use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class FoxJobRetryCmdTest method assertJobRetriesForActivity.
protected void assertJobRetriesForActivity(ProcessInstance pi, String activityId) {
assertNotNull(pi);
waitForExecutedJobWithRetriesLeft(4);
stillOneJobWithExceptionAndRetriesLeft();
Job job = fetchJob(pi.getProcessInstanceId());
assertNotNull(job);
assertEquals(pi.getProcessInstanceId(), job.getProcessInstanceId());
assertEquals(4, job.getRetries());
ExecutionEntity execution = fetchExecutionEntity(pi.getProcessInstanceId(), activityId);
assertNotNull(execution);
waitForExecutedJobWithRetriesLeft(3);
job = refreshJob(job.getId());
assertEquals(3, job.getRetries());
stillOneJobWithExceptionAndRetriesLeft();
execution = refreshExecutionEntity(execution.getId());
assertEquals(activityId, execution.getActivityId());
waitForExecutedJobWithRetriesLeft(2);
job = refreshJob(job.getId());
assertEquals(2, job.getRetries());
stillOneJobWithExceptionAndRetriesLeft();
execution = refreshExecutionEntity(execution.getId());
assertEquals(activityId, execution.getActivityId());
waitForExecutedJobWithRetriesLeft(1);
job = refreshJob(job.getId());
assertEquals(1, job.getRetries());
stillOneJobWithExceptionAndRetriesLeft();
execution = refreshExecutionEntity(execution.getId());
assertEquals(activityId, execution.getActivityId());
waitForExecutedJobWithRetriesLeft(0);
job = refreshJob(job.getId());
assertEquals(0, job.getRetries());
assertEquals(1, managementService.createJobQuery().withException().count());
assertEquals(0, managementService.createJobQuery().withRetriesLeft().count());
assertEquals(1, managementService.createJobQuery().noRetriesLeft().count());
execution = refreshExecutionEntity(execution.getId());
assertEquals(activityId, execution.getActivityId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class FoxJobRetryCmdTest method testFailedJobRetryTimeCycleWithChangingExpression.
public void testFailedJobRetryTimeCycleWithChangingExpression() throws ParseException {
BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess("process").startEvent().serviceTask().camundaClass("foo").camundaAsyncBefore().camundaFailedJobRetryTimeCycle("${var}").endEvent().done();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date startDate = simpleDateFormat.parse("2017-01-01T09:55:00");
ClockUtil.setCurrentTime(startDate);
deployment(bpmnModelInstance);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValue("var", "R10/PT5M"));
startDate = simpleDateFormat.parse("2017-01-01T10:00:00");
ClockUtil.setCurrentTime(startDate);
Job job = managementService.createJobQuery().singleResult();
// when
try {
managementService.executeJob(job.getId());
} catch (Exception e) {
// ignore
}
job = managementService.createJobQuery().singleResult();
Assert.assertEquals(9, job.getRetries());
startDate = simpleDateFormat.parse("2017-01-01T10:05:00");
ClockUtil.setCurrentTime(startDate);
runtimeService.setVariable(pi.getProcessInstanceId(), "var", "R10/PT10M");
try {
managementService.executeJob(job.getId());
} catch (Exception e) {
// ignore
}
// then
Date expectedDate = simpleDateFormat.parse("2017-01-01T10:15:00");
Date lockExpirationTime = ((JobEntity) managementService.createJobQuery().singleResult()).getLockExpirationTime();
assertEquals(expectedDate, lockExpirationTime);
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncAfterTest method testAsyncAfterIntermediateThrowEvent.
@Deployment
public void testAsyncAfterIntermediateThrowEvent() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testIntermediateThrowEvent");
// listeners should be fired by now
assertListenerStartInvoked(pi);
assertListenerEndInvoked(pi);
// the process should wait *after* the throw 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 testAsyncAfterAndBeforeInclusiveGateway.
@Deployment
public void testAsyncAfterAndBeforeInclusiveGateway() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testInclusiveGateway");
// no listeners are fired:
assertNotListenerStartInvoked(pi);
assertNotListenerEndInvoked(pi);
// we should wait *before* the gateway:
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
// after executing the gateway:
managementService.executeJob(job.getId());
// the listeners are fired:
assertListenerStartInvoked(pi);
assertListenerEndInvoked(pi);
// and we will wait *after* the gateway:
List<Job> jobs = managementService.createJobQuery().active().list();
assertEquals(2, jobs.size());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncAfterTest method testAsyncAfterInNestedWithoutTransition.
@Deployment
public void testAsyncAfterInNestedWithoutTransition() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess");
// the service task is completely invoked
assertListenerStartInvoked(pi);
assertBehaviorInvoked(pi);
assertListenerEndInvoked(pi);
// and the execution is waiting *after* the service task
Job continuationJob = managementService.createJobQuery().singleResult();
assertNotNull(continuationJob);
// but the subprocess end listeners have not been invoked yet
assertNull(runtimeService.getVariable(pi.getId(), "subprocess-listenerEndInvoked"));
// if we execute the job, the listeners are invoked;
managementService.executeJob(continuationJob.getId());
assertTrue((Boolean) runtimeService.getVariable(pi.getId(), "subprocess-listenerEndInvoked"));
}
Aggregations