use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class JobAuthorizationTest method testDeleteJobWithUpdateInstancePermissionOnProcessDefinition.
public void testDeleteJobWithUpdateInstancePermissionOnProcessDefinition() {
// given
String processInstanceId = startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, TIMER_BOUNDARY_PROCESS_KEY, userId, UPDATE_INSTANCE);
String jobId = selectJobByProcessInstanceId(processInstanceId).getId();
// when
managementService.deleteJob(jobId);
// then
Job job = selectJobByProcessInstanceId(processInstanceId);
assertNull(job);
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class JobAuthorizationTest method testSetJobRetriesByJobDefinitionIdWithUpdatePermissionOnAnyProcessInstance.
public void testSetJobRetriesByJobDefinitionIdWithUpdatePermissionOnAnyProcessInstance() {
// given
String processInstanceId = startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, UPDATE);
String jobId = selectJobByProcessInstanceId(processInstanceId).getId();
disableAuthorization();
managementService.setJobRetries(jobId, 0);
enableAuthorization();
String jobDefinitionId = selectJobDefinitionByProcessDefinitionKey(TIMER_BOUNDARY_PROCESS_KEY).getId();
// when
managementService.setJobRetriesByJobDefinitionId(jobDefinitionId, 1);
// then
Job job = selectJobByProcessInstanceId(processInstanceId);
assertNotNull(job);
assertEquals(1, job.getRetries());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testExecutionListenerWithTimerBoundaryEvent.
@Deployment
public void testExecutionListenerWithTimerBoundaryEvent() {
final AtomicInteger eventCount = new AtomicInteger();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
return new ExecutionListener() {
public void notify(DelegateExecution execution) throws Exception {
eventCount.incrementAndGet();
}
};
}
};
// register app so that it is notified about events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// 1. (start)startEvent(end) -(take)-> (start)userTask(end) -(take)-> (start)endEvent(end) (8 Events)
// start process instance
runtimeService.startProcessInstanceByKey("executionListener");
// complete task
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
assertEquals(10, eventCount.get());
// reset counter
eventCount.set(0);
// 2. (start)startEvent(end) -(take)-> (start)userTask(end)/(start)timerBoundaryEvent(end) -(take)-> (start)endEvent(end) (10 Events)
// start process instance
runtimeService.startProcessInstanceByKey("executionListener");
// fire timer event
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
assertEquals(12, eventCount.get());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AbstractAsyncOperationsTest method executeSeedJob.
protected void executeSeedJob(Batch batch) {
String seedJobDefinitionId = batch.getSeedJobDefinitionId();
Job seedJob = managementService.createJobQuery().jobDefinitionId(seedJobDefinitionId).singleResult();
assertNotNull(seedJob);
managementService.executeJob(seedJob.getId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class BatchHistoricDecisionInstanceDeletionUserOperationTest method executeJobs.
protected void executeJobs(Batch batch) {
Job job = managementService.createJobQuery().jobDefinitionId(batch.getSeedJobDefinitionId()).singleResult();
// seed job
managementService.executeJob(job.getId());
for (Job pending : managementService.createJobQuery().jobDefinitionId(batch.getBatchJobDefinitionId()).list()) {
managementService.executeJob(pending.getId());
}
}
Aggregations