Package org.camunda.bpm.engine.runtime

Examples of org.camunda.bpm.engine.runtime.Job


        repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_SERVICE_TASK_V2).deploy().getId();

    runtimeService.startProcessInstanceById(processDefinitionId);

    // execute job that triggers the migrating service task
    Job migrationJob = managementService.createJobQuery().singleResult();
    assertNotNull(migrationJob);

    managementService.executeJob(migrationJob.getId());

    Task followUpTask = taskService.createTaskQuery().singleResult();

    assertNotNull("Should have migrated to the new version and immediately executed the correct follow-up activity",
        followUpTask);
View Full Code Here


    //we have reached task4
    task = taskService.createTaskQuery().taskDefinitionKey("task4").singleResult();
    assertNotNull(task);

    //The timer job has been created
    Job job = managementService.createJobQuery().executionId(task.getExecutionId()).singleResult();
    assertNotNull(job);

    // check there are 2 user tasks task4 and task2
    assertEquals(2, taskService.createTaskQuery().count());
View Full Code Here

  public void testSetProcessDefinitionVersionMigrateJob() {
    // given a process instance
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneJobProcess");

    // with a job
    Job job = managementService.createJobQuery().singleResult();
    assertNotNull(job);

    // and a second deployment of the process
    org.camunda.bpm.engine.repository.Deployment deployment = repositoryService
      .createDeployment()
      .addClasspathResource(TEST_PROCESS_ONE_JOB)
      .deploy();

    ProcessDefinition newDefinition =
        repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
    assertNotNull(newDefinition);

    // when the process instance is migrated
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new SetProcessDefinitionVersionCmd(instance.getId(), 2));

    // then the the job should also be migrated
    Job migratedJob = managementService.createJobQuery().singleResult();
    assertNotNull(migratedJob);
    assertEquals(job.getId(), migratedJob.getId());
    assertEquals(newDefinition.getId(), migratedJob.getProcessDefinitionId());
    assertEquals(deployment.getId(), migratedJob.getDeploymentId());

    JobDefinition newJobDefinition = managementService
        .createJobDefinitionQuery().processDefinitionId(newDefinition.getId()).singleResult();
    assertNotNull(newJobDefinition);
    assertEquals(newJobDefinition.getId(), migratedJob.getJobDefinitionId());

    repositoryService.deleteDeployment(deployment.getId(), true);
  }
View Full Code Here

    ProcessInstance asyncAfterInstance = runtimeService.startProcessInstanceByKey("twoJobsProcess");

    // with an async after job
    String jobId = managementService.createJobQuery().singleResult().getId();
    managementService.executeJob(jobId);
    Job asyncAfterJob = managementService.createJobQuery().singleResult();

    // and a process instance with an before after job
    ProcessInstance asyncBeforeInstance = runtimeService.startProcessInstanceByKey("twoJobsProcess");
    Job asyncBeforeJob = managementService.createJobQuery()
        .processInstanceId(asyncBeforeInstance.getId()).singleResult();

    // and a second deployment of the process
    org.camunda.bpm.engine.repository.Deployment deployment = repositoryService
      .createDeployment()
      .addClasspathResource(TEST_PROCESS_TWO_JOBS)
      .deploy();

    ProcessDefinition newDefinition =
        repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
    assertNotNull(newDefinition);

    JobDefinition asnycBeforeJobDefinition =
        managementService.createJobDefinitionQuery()
          .jobConfiguration(MessageJobDeclaration.ASYNC_BEFORE)
          .processDefinitionId(newDefinition.getId())
          .singleResult();
    JobDefinition asnycAfterJobDefinition =
        managementService.createJobDefinitionQuery()
          .jobConfiguration(MessageJobDeclaration.ASYNC_AFTER)
          .processDefinitionId(newDefinition.getId())
          .singleResult();

    assertNotNull(asnycBeforeJobDefinition);
    assertNotNull(asnycAfterJobDefinition);

    // when the process instances are migrated
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new SetProcessDefinitionVersionCmd(asyncBeforeInstance.getId(), 2));
    commandExecutor.execute(new SetProcessDefinitionVersionCmd(asyncAfterInstance.getId(), 2));

    // then the the job's definition reference should also be migrated
    Job migratedAsyncBeforeJob = managementService.createJobQuery()
        .processInstanceId(asyncBeforeInstance.getId()).singleResult();
    assertEquals(asyncBeforeJob.getId(), migratedAsyncBeforeJob.getId());
    assertNotNull(migratedAsyncBeforeJob);
    assertEquals(asnycBeforeJobDefinition.getId(), migratedAsyncBeforeJob.getJobDefinitionId());

    Job migratedAsyncAfterJob = managementService.createJobQuery()
        .processInstanceId(asyncAfterInstance.getId()).singleResult();
    assertEquals(asyncAfterJob.getId(), migratedAsyncAfterJob.getId());
    assertNotNull(migratedAsyncAfterJob);
    assertEquals(asnycAfterJobDefinition.getId(), migratedAsyncAfterJob.getJobDefinitionId());

    repositoryService.deleteDeployment(deployment.getId(), true);
  }
View Full Code Here

    assertEquals(5, taskList.size());
    for (Task task : taskList) {
      assertEquals("First Task", task.getName());
    }

    Job job = managementService.createJobQuery()
        .processInstanceId(pi.getId())
        .singleResult();
    assertNotNull(job);

    // execute the timer
    managementService.executeJob(job.getId());

    // now there are 6 tasks
    taskList = taskService.createTaskQuery()
        .orderByTaskName()
        .asc()
View Full Code Here

    // After process start, there should be 3 timers created
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("testJoin");
    Task task1 = taskService.createTaskQuery().singleResult();
    assertEquals("Main Task", task1.getName());

    Job job = managementService.createJobQuery().processInstanceId(pi.getId()).singleResult();
    assertNotNull(job);

    managementService.executeJob(job.getId());

    // we now have both tasks
    assertEquals(2L, taskService.createTaskQuery().count());

    // end the first
View Full Code Here

    assertEquals("Second Task", secondTask.getName());
    for (Task task : taskList) {
      assertEquals("First Task", task.getName());
    }

    Job job = managementService.createJobQuery()
        .processInstanceId(pi.getId())
        .singleResult();
    assertNotNull(job);

    // execute the timer
    managementService.executeJob(job.getId());

    // now there are 7 tasks
    taskList = taskService.createTaskQuery()
        .orderByTaskName()
        .asc()
View Full Code Here

    // suspended job definitions and corresponding jobs
    managementService.suspendJobDefinitionByProcessDefinitionKey("suspensionProcess", true);

    // the failed job
    JobQuery jobQuery = managementService.createJobQuery();
    Job job = jobQuery.singleResult();
    assertTrue(job.isSuspended());

    // when
    // the job will be activated
    managementService.activateJobById(job.getId());

    // then
    // the job should be active
    assertEquals(1, jobQuery.active().count());
    assertEquals(0, jobQuery.suspended().count());

    Job activeJob = jobQuery.active().singleResult();

    assertEquals(job.getId(), activeJob.getId());
    assertFalse(activeJob.isSuspended());
  }
View Full Code Here

  @Deployment
  public void testTimerOnConcurrentTasks() {
    String procId = runtimeService.startProcessInstanceByKey("nonInterruptingOnConcurrentTasks").getId();
    assertEquals(2, taskService.createTaskQuery().count());

    Job timer = managementService.createJobQuery().singleResult();
    managementService.executeJob(timer.getId());
    assertEquals(3, taskService.createTaskQuery().count());

    // Complete task that was reached by non interrupting timer
    Task task = taskService.createTaskQuery().taskDefinitionKey("timerFiredTask").singleResult();
    taskService.complete(task.getId());
View Full Code Here

  @Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/timer/BoundaryTimerNonInterruptingEventTest.testTimerOnConcurrentTasks.bpmn20.xml"})
  public void testTimerOnConcurrentTasks2() {
    String procId = runtimeService.startProcessInstanceByKey("nonInterruptingOnConcurrentTasks").getId();
    assertEquals(2, taskService.createTaskQuery().count());

    Job timer = managementService.createJobQuery().singleResult();
    managementService.executeJob(timer.getId());
    assertEquals(3, taskService.createTaskQuery().count());

    // Complete 2 tasks that will trigger the join
    Task task = taskService.createTaskQuery().taskDefinitionKey("firstTask").singleResult();
    taskService.complete(task.getId());
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.runtime.Job

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.