Search in sources :

Example 21 with Job

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);
}
Also used : Job(org.camunda.bpm.engine.runtime.Job)

Example 22 with 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());
}
Also used : Job(org.camunda.bpm.engine.runtime.Job)

Example 23 with Job

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());
}
Also used : DelegateTask(org.camunda.bpm.engine.delegate.DelegateTask) Task(org.camunda.bpm.engine.task.Task) EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) Job(org.camunda.bpm.engine.runtime.Job) ExecutionListener(org.camunda.bpm.engine.delegate.ExecutionListener) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 24 with Job

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());
}
Also used : Job(org.camunda.bpm.engine.runtime.Job)

Example 25 with Job

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());
    }
}
Also used : Job(org.camunda.bpm.engine.runtime.Job)

Aggregations

Job (org.camunda.bpm.engine.runtime.Job)696 Deployment (org.camunda.bpm.engine.test.Deployment)310 Test (org.junit.Test)232 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)189 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)148 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)135 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)116 HashMap (java.util.HashMap)98 Batch (org.camunda.bpm.engine.batch.Batch)78 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)78 Task (org.camunda.bpm.engine.task.Task)71 Date (java.util.Date)67 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)48 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)24 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)23 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)21 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)20 Incident (org.camunda.bpm.engine.runtime.Incident)17 HistoricJobLog (org.camunda.bpm.engine.history.HistoricJobLog)15 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)15