use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class JobRetryCmdWithDefaultPropertyTest method testDefaultNumberOfRetryProperty.
/**
* Check if property "DefaultNumberOfRetries" will be used
*/
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/async/FoxJobRetryCmdTest.testFailedTask.bpmn20.xml" })
public void testDefaultNumberOfRetryProperty() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("failedTask");
assertNotNull(pi);
Job job = managementService.createJobQuery().processInstanceId(pi.getProcessInstanceId()).singleResult();
assertNotNull(job);
assertEquals(pi.getProcessInstanceId(), job.getProcessInstanceId());
assertEquals(2, job.getRetries());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class JobRetryCmdWithDefaultPropertyTest method testOverwritingPropertyWithBpmnExtension.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/async/FoxJobRetryCmdTest.testFailedServiceTask.bpmn20.xml" })
public void testOverwritingPropertyWithBpmnExtension() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("failedServiceTask");
assertNotNull(pi);
Job job = managementService.createJobQuery().processInstanceId(pi.getProcessInstanceId()).singleResult();
assertNotNull(job);
assertEquals(pi.getProcessInstanceId(), job.getProcessInstanceId());
try {
managementService.executeJob(job.getId());
fail("Exception expected!");
} catch (Exception e) {
// expected
}
job = managementService.createJobQuery().jobId(job.getId()).singleResult();
assertEquals(4, job.getRetries());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class FoxJobRetryCmdTest method testBrokenFoxJobRetryValue.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/async/FoxJobRetryCmdTest.testBrokenFoxJobRetryValue.bpmn20.xml" })
public void testBrokenFoxJobRetryValue() {
Job job = managementService.createJobQuery().list().get(0);
assertNotNull(job);
assertEquals(3, job.getRetries());
waitForExecutedJobWithRetriesLeft(0, job.getId());
job = refreshJob(job.getId());
assertEquals(0, job.getRetries());
assertEquals(1, managementService.createJobQuery().noRetriesLeft().count());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class FoxJobRetryCmdTest method testRetryOnTimerStartEventInEventSubProcess.
@Deployment
public void testRetryOnTimerStartEventInEventSubProcess() {
runtimeService.startProcessInstanceByKey("process").getId();
Job job = managementService.createJobQuery().singleResult();
assertEquals(3, job.getRetries());
try {
managementService.executeJob(job.getId());
fail();
} catch (Exception e) {
// expected
}
job = managementService.createJobQuery().singleResult();
assertEquals(4, job.getRetries());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class FoxJobRetryCmdTest method waitForExecutedJobWithRetriesLeft.
protected void waitForExecutedJobWithRetriesLeft(int retriesLeft, String jobId) {
JobQuery jobQuery = managementService.createJobQuery();
if (jobId != null) {
jobQuery.jobId(jobId);
}
Job job = jobQuery.singleResult();
try {
managementService.executeJob(job.getId());
} catch (Exception e) {
}
// update job
job = jobQuery.singleResult();
if (job.getRetries() != retriesLeft) {
waitForExecutedJobWithRetriesLeft(retriesLeft, jobId);
}
}
Aggregations