use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncAfterTest method testAsyncAfterErrorEvent.
public void testAsyncAfterErrorEvent() {
// given
BpmnModelInstance instance = Bpmn.createExecutableProcess("process").startEvent().serviceTask("servTask").camundaClass(ThrowBpmnErrorDelegate.class).boundaryEvent().camundaAsyncAfter(true).camundaFailedJobRetryTimeCycle("R10/PT10S").errorEventDefinition().errorEventDefinitionDone().serviceTask().camundaClass("foo").endEvent().moveToActivity("servTask").endEvent().done();
deployment(instance);
runtimeService.startProcessInstanceByKey("process");
Job job = managementService.createJobQuery().singleResult();
// when job fails
try {
managementService.executeJob(job.getId());
} catch (Exception e) {
// ignore
}
// then
job = managementService.createJobQuery().singleResult();
Assert.assertEquals(9, job.getRetries());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncCallActivityTest method testCallProcessWithAsyncOnStartEvent.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/async/AsyncCallActivityTest.asyncStartEvent.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/async/AsyncCallActivityTest.testCallSubProcess.bpmn20.xml" })
public void testCallProcessWithAsyncOnStartEvent() {
runtimeService.startProcessInstanceByKey("callAsyncSubProcess");
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
managementService.executeJob(job.getId());
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
taskService.complete(task.getId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class ProcessDefinitionManager method deleteTimerStartEventsForProcessDefinition.
/**
* Deletes the timer start events for the given process definition.
*
* @param processDefinition the process definition
*/
protected void deleteTimerStartEventsForProcessDefinition(ProcessDefinition processDefinition) {
List<JobEntity> timerStartJobs = getJobManager().findJobsByConfiguration(TimerStartEventJobHandler.TYPE, processDefinition.getKey(), processDefinition.getTenantId());
ProcessDefinitionEntity latestVersion = getProcessDefinitionManager().findLatestProcessDefinitionByKeyAndTenantId(processDefinition.getKey(), processDefinition.getTenantId());
// delete timer start event jobs only if this is the latest version of the process definition.
if (latestVersion != null && latestVersion.getId().equals(processDefinition.getId())) {
for (Job job : timerStartJobs) {
((JobEntity) job).delete();
}
}
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class HistoricIncidentAuthorizationTest method testMixedQueryWithReadHistoryPermissionOnAnyProcessDefinition.
public void testMixedQueryWithReadHistoryPermissionOnAnyProcessDefinition() {
// given
disableAuthorization();
repositoryService.suspendProcessDefinitionByKey(ONE_INCIDENT_PROCESS_KEY, true, new Date());
String firstJobId = null;
List<Job> jobs = managementService.createJobQuery().withRetriesLeft().list();
for (Job job : jobs) {
if (job.getProcessDefinitionKey() == null) {
firstJobId = job.getId();
break;
}
}
managementService.setJobRetries(firstJobId, 0);
repositoryService.suspendProcessDefinitionByKey(ONE_INCIDENT_PROCESS_KEY, true, new Date());
String secondJobId = null;
jobs = managementService.createJobQuery().withRetriesLeft().list();
for (Job job : jobs) {
if (job.getProcessDefinitionKey() == null) {
secondJobId = job.getId();
break;
}
}
managementService.setJobRetries(secondJobId, 0);
enableAuthorization();
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY);
// when
HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();
// then
verifyQueryResults(query, 7);
disableAuthorization();
managementService.deleteJob(firstJobId);
managementService.deleteJob(secondJobId);
enableAuthorization();
clearDatabase();
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class HistoricIncidentAuthorizationTest method testMixedQueryWithoutAuthorization.
// historic job log (mixed) //////////////////////////////////////////
public void testMixedQueryWithoutAuthorization() {
// given
disableAuthorization();
repositoryService.suspendProcessDefinitionByKey(ONE_INCIDENT_PROCESS_KEY, true, new Date());
String firstJobId = null;
List<Job> jobs = managementService.createJobQuery().withRetriesLeft().list();
for (Job job : jobs) {
if (job.getProcessDefinitionKey() == null) {
firstJobId = job.getId();
break;
}
}
managementService.setJobRetries(firstJobId, 0);
repositoryService.suspendProcessDefinitionByKey(ONE_INCIDENT_PROCESS_KEY, true, new Date());
String secondJobId = null;
jobs = managementService.createJobQuery().withRetriesLeft().list();
for (Job job : jobs) {
if (job.getProcessDefinitionKey() == null) {
secondJobId = job.getId();
break;
}
}
managementService.setJobRetries(secondJobId, 0);
enableAuthorization();
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
// when
HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();
// then
verifyQueryResults(query, 2);
disableAuthorization();
managementService.deleteJob(firstJobId);
managementService.deleteJob(secondJobId);
enableAuthorization();
clearDatabase();
}
Aggregations