Search in sources :

Example 76 with Job

use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.

the class AsyncAfterTest method testAsyncAfterWithExecutionListener.

/**
 * Test for CAM-2518: Fixes an issue that creates an infinite loop when using
 * asyncAfter together with an execution listener on sequence flow event "take".
 * So the only required assertion here is that the process executes successfully.
 */
@Deployment
public void testAsyncAfterWithExecutionListener() {
    // given an async after job and an execution listener on that task
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
    Job job = managementService.createJobQuery().singleResult();
    assertNotNull(job);
    assertNotListenerTakeInvoked(processInstance);
    // when the job is executed
    managementService.executeJob(job.getId());
    // then the process should advance and not recreate the job
    job = managementService.createJobQuery().singleResult();
    assertNull(job);
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    assertListenerTakeInvoked(processInstance);
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 77 with Job

use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.

the class AsyncAfterTest method testAsyncAfterAndBeforeServiceTask.

@Deployment
public void testAsyncAfterAndBeforeServiceTask() {
    // start process instance
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess");
    // the service task is not yet invoked
    assertNotListenerStartInvoked(pi);
    assertNotBehaviorInvoked(pi);
    assertNotListenerEndInvoked(pi);
    Job job = managementService.createJobQuery().singleResult();
    assertNotNull(job);
    // if the job is executed
    managementService.executeJob(job.getId());
    // the manual task is invoked
    assertListenerStartInvoked(pi);
    assertListenerEndInvoked(pi);
    // and now the process is waiting *after* the manual task
    job = managementService.createJobQuery().singleResult();
    assertNotNull(job);
    // after executing the waiting job, the process instance will end
    managementService.executeJob(job.getId());
    assertProcessEnded(pi.getId());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 78 with Job

use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.

the class AsyncAfterTest method testAsyncAfterOnParallelGatewayFork.

@Deployment
public void testAsyncAfterOnParallelGatewayFork() {
    String configuration = PvmAtomicOperation.TRANSITION_NOTIFY_LISTENER_TAKE.getCanonicalName();
    String config1 = configuration + "$afterForkFlow1";
    String config2 = configuration + "$afterForkFlow2";
    runtimeService.startProcessInstanceByKey("process");
    // there are two jobs
    List<Job> jobs = managementService.createJobQuery().list();
    assertEquals(2, jobs.size());
    Job jobToExecute = fetchFirstJobByHandlerConfiguration(jobs, config1);
    assertNotNull(jobToExecute);
    managementService.executeJob(jobToExecute.getId());
    Task task1 = taskService.createTaskQuery().taskDefinitionKey("theTask1").singleResult();
    assertNotNull(task1);
    // there is one left
    jobs = managementService.createJobQuery().list();
    assertEquals(1, jobs.size());
    jobToExecute = fetchFirstJobByHandlerConfiguration(jobs, config2);
    managementService.executeJob(jobToExecute.getId());
    Task task2 = taskService.createTaskQuery().taskDefinitionKey("theTask2").singleResult();
    assertNotNull(task2);
    assertEquals(2, taskService.createTaskQuery().count());
}
Also used : Task(org.camunda.bpm.engine.task.Task) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 79 with Job

use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.

the class AsyncAfterTest method testAsyncAfterServiceTaskMultipleTransitions.

@Deployment
public void testAsyncAfterServiceTaskMultipleTransitions() {
    // start process instance
    Map<String, Object> varMap = new HashMap<String, Object>();
    varMap.put("flowToTake", "flow2");
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess", varMap);
    // 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);
    // if we execute the job, the process instance continues along the selected path
    managementService.executeJob(continuationJob.getId());
    assertNotNull(runtimeService.createExecutionQuery().activityId("taskAfterFlow2").singleResult());
    assertNull(runtimeService.createExecutionQuery().activityId("taskAfterFlow3").singleResult());
    // end the process
    runtimeService.signal(pi.getId());
    // ////////////////////////////////////////////////////////////
    // start process instance
    varMap = new HashMap<String, Object>();
    varMap.put("flowToTake", "flow3");
    pi = runtimeService.startProcessInstanceByKey("testProcess", varMap);
    // the service task is completely invoked
    assertListenerStartInvoked(pi);
    assertBehaviorInvoked(pi);
    assertListenerEndInvoked(pi);
    // and the execution is waiting *after* the service task
    continuationJob = managementService.createJobQuery().singleResult();
    assertNotNull(continuationJob);
    // if we execute the job, the process instance continues along the selected path
    managementService.executeJob(continuationJob.getId());
    assertNull(runtimeService.createExecutionQuery().activityId("taskAfterFlow2").singleResult());
    assertNotNull(runtimeService.createExecutionQuery().activityId("taskAfterFlow3").singleResult());
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 80 with Job

use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.

the class AsyncAfterTest method testAsyncAfterManualTask.

@Deployment
public void testAsyncAfterManualTask() {
    // start process instance
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("testManualTask");
    // listeners should be fired by now
    assertListenerStartInvoked(pi);
    assertListenerEndInvoked(pi);
    // the process should wait *after* the catch 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());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

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