Java Code Examples for org.camunda.bpm.engine.impl.interceptor.CommandExecutor#execute()

The following examples show how to use org.camunda.bpm.engine.impl.interceptor.CommandExecutor#execute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManagementServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void createJob(final int retries, final String owner, final Date lockExpirationTime) {
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  commandExecutor.execute(new Command<Void>() {
    @Override
    public Void execute(CommandContext commandContext) {
      JobManager jobManager = commandContext.getJobManager();
      MessageEntity job = new MessageEntity();
      job.setJobHandlerType("any");
      job.setLockOwner(owner);
      job.setLockExpirationTime(lockExpirationTime);
      job.setRetries(retries);

      jobManager.send(job);
      return null;
    }
  });
}
 
Example 2
Source File: JobQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
private void createJobWithoutExceptionStacktrace() {
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  commandExecutor.execute(new Command<Void>() {
    public Void execute(CommandContext commandContext) {
      JobManager jobManager = commandContext.getJobManager();

      timerEntity = new TimerEntity();
      timerEntity.setLockOwner(UUID.randomUUID().toString());
      timerEntity.setDuedate(new Date());
      timerEntity.setRetries(0);
      timerEntity.setExceptionMessage("I'm supposed to fail");

      jobManager.insert(timerEntity);

      assertNotNull(timerEntity.getId());

      return null;

    }
  });

}
 
Example 3
Source File: JobQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
private void createJobWithoutExceptionMsg() {
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  commandExecutor.execute(new Command<Void>() {
    public Void execute(CommandContext commandContext) {
      JobManager jobManager = commandContext.getJobManager();

      timerEntity = new TimerEntity();
      timerEntity.setLockOwner(UUID.randomUUID().toString());
      timerEntity.setDuedate(new Date());
      timerEntity.setRetries(0);

      StringWriter stringWriter = new StringWriter();
      NullPointerException exception = new NullPointerException();
      exception.printStackTrace(new PrintWriter(stringWriter));
      timerEntity.setExceptionStacktrace(stringWriter.toString());

      jobManager.insert(timerEntity);

      assertNotNull(timerEntity.getId());

      return null;

    }
  });

}
 
Example 4
Source File: SetProcessDefinitionVersionCmdTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = TEST_PROCESS_ONE_JOB)
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);
}
 
Example 5
Source File: UserOperationLogAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void clearDatabase() {
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  commandExecutor.execute(new Command<Object>() {
    public Object execute(CommandContext commandContext) {
      commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerSuspendProcessDefinitionHandler.TYPE);
      List<HistoricIncident> incidents = Context.getProcessEngineConfiguration().getHistoryService().createHistoricIncidentQuery().list();
      for (HistoricIncident incident : incidents) {
        commandContext.getHistoricIncidentManager().delete((HistoricIncidentEntity) incident);
      }
      return null;
    }
  });
}
 
Example 6
Source File: CommandInvocationContextTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public Void execute(CommandContext commandContext) {
  assertEquals(this, Context.getCommandInvocationContext().getCommand());

  if (innerCommand != null) {
    CommandExecutor commandExecutor = Context.getProcessEngineConfiguration().getCommandExecutorTxRequired();
    commandExecutor.execute(innerCommand);

    // should still be correct after command invocation
    assertEquals(this, Context.getCommandInvocationContext().getCommand());
  }

  return null;
}
 
Example 7
Source File: SetProcessDefinitionVersionCmdTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * See https://app.camunda.com/jira/browse/CAM-9505
 */
@Deployment(resources = TEST_PROCESS_ONE_JOB)
public void testPreserveTimestampOnUpdatedIncident() {
  // given
  ProcessInstance instance =
      runtimeService.startProcessInstanceByKey("oneJobProcess", Variables.createVariables().putValue("shouldFail", true));

  executeAvailableJobs();

  Incident incident = runtimeService.createIncidentQuery().singleResult();
  assertNotNull(incident);

  Date timestamp = incident.getIncidentTimestamp();

  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
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  commandExecutor.execute(new SetProcessDefinitionVersionCmd(instance.getId(), 2));

  Incident migratedIncident = runtimeService.createIncidentQuery().singleResult();

  // then
  assertEquals(timestamp, migratedIncident.getIncidentTimestamp());

  // cleanup
  repositoryService.deleteDeployment(deployment.getId(), true);
}
 
Example 8
Source File: HistoryCleanupRemovalTimeTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void clearJobLog(final String jobId) {
  CommandExecutor commandExecutor = engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequired();
  commandExecutor.execute(new Command<Object>() {
    public Object execute(CommandContext commandContext) {
      commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
      return null;
    }
  });
}
 
Example 9
Source File: ManagementServiceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/api/mgmt/timerOnTask.bpmn20.xml"})
public void testDeleteJobThatWasAlreadyAcquired() {
  ClockUtil.setCurrentTime(new Date());

  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnTask");
  Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();

  // We need to move time at least one hour to make the timer executable
  ClockUtil.setCurrentTime(new Date(ClockUtil.getCurrentTime().getTime() + 7200000L));

  // Acquire job by running the acquire command manually
  ProcessEngineImpl processEngineImpl = (ProcessEngineImpl) processEngine;
  JobExecutor jobExecutor = processEngineImpl.getProcessEngineConfiguration().getJobExecutor();
  AcquireJobsCmd acquireJobsCmd = new AcquireJobsCmd(jobExecutor);
  CommandExecutor commandExecutor = processEngineImpl.getProcessEngineConfiguration().getCommandExecutorTxRequired();
  commandExecutor.execute(acquireJobsCmd);

  // Try to delete the job. This should fail.
  try {
    managementService.deleteJob(timerJob.getId());
    fail();
  } catch (ProcessEngineException e) {
    // Exception is expected
  }

  // Clean up
  managementService.executeJob(timerJob.getId());
}
 
Example 10
Source File: BpmnParseTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
@Test
public void testParseNamespaceInConditionExpressionType() {
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
    @Override
    public ProcessDefinitionEntity execute(CommandContext commandContext) {
      return Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedLatestProcessDefinitionByKey("resolvableNamespacesProcess");
    }
  });

  // Test that the process definition has been deployed
  assertNotNull(processDefinitionEntity);
  PvmActivity activity = processDefinitionEntity.findActivity("ExclusiveGateway_1");
  assertNotNull(activity);

  // Test that the conditions has been resolved
  for (PvmTransition transition : activity.getOutgoingTransitions()) {
    if (transition.getDestination().getId().equals("Task_2")) {
      assertTrue(transition.getProperty("conditionText").equals("#{approved}"));
    } else if (transition.getDestination().getId().equals("Task_3")) {
      assertTrue(transition.getProperty("conditionText").equals("#{!approved}"));
    } else {
      fail("Something went wrong");
    }

  }
}
 
Example 11
Source File: ExecutionTree.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static ExecutionTree forExecution(final String executionId, ProcessEngine processEngine) {
  ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl)
      processEngine.getProcessEngineConfiguration();

  CommandExecutor commandExecutor = configuration.getCommandExecutorTxRequired();

  ExecutionTree executionTree = commandExecutor.execute(new Command<ExecutionTree>() {
    public ExecutionTree execute(CommandContext commandContext) {
      ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(executionId);
      return ExecutionTree.forExecution(execution);
    }
  });

  return executionTree;
}
 
Example 12
Source File: AbstractRemovalTimeTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void clearJobLog(final String jobId) {
  CommandExecutor commandExecutor = engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequired();
  commandExecutor.execute(new Command<Object>() {
    public Object execute(CommandContext commandContext) {
      commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
      return null;
    }
  });
}
 
Example 13
Source File: SequentialJobAcquisitionRunnable.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected AcquiredJobs acquireJobs(
    JobAcquisitionContext context,
    JobAcquisitionStrategy acquisitionStrategy,
    ProcessEngineImpl currentProcessEngine) {
  CommandExecutor commandExecutor = currentProcessEngine.getProcessEngineConfiguration()
      .getCommandExecutorTxRequired();

  int numJobsToAcquire = acquisitionStrategy.getNumJobsToAcquire(currentProcessEngine.getName());

  AcquiredJobs acquiredJobs = null;

  if (numJobsToAcquire > 0) {
    jobExecutor.logAcquisitionAttempt(currentProcessEngine);
    acquiredJobs = commandExecutor.execute(jobExecutor.getAcquireJobsCmd(numJobsToAcquire));
  }
  else {
    acquiredJobs = new AcquiredJobs(numJobsToAcquire);
  }

  context.submitAcquiredJobs(currentProcessEngine.getName(), acquiredJobs);

  jobExecutor.logAcquiredJobs(currentProcessEngine, acquiredJobs.size());
  jobExecutor.logAcquisitionFailureJobs(currentProcessEngine, acquiredJobs.getNumberOfJobsFailedToLock());

  LOG.acquiredJobs(currentProcessEngine.getName(), acquiredJobs);

  return acquiredJobs;
}
 
Example 14
Source File: TimerRecalculationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void clearJobLog(final String jobId) {
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  commandExecutor.execute(new Command<Object>() {
    public Object execute(CommandContext commandContext) {
      commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
      return null;
    }
  });
}
 
Example 15
Source File: AbstractRemovalTimeTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void clearAttachment(final Attachment attachment) {
  CommandExecutor commandExecutor = engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequired();
  commandExecutor.execute(new Command<Object>() {
    public Object execute(CommandContext commandContext) {
      commandContext.getAttachmentManager().delete((AttachmentEntity) attachment);
      return null;
    }
  });
}
 
Example 16
Source File: BpmnParseTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment
@Test
public void testParseDiagramInterchangeElements() {

  // Graphical information is not yet exposed publicly, so we need to do some
  // plumbing
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
    @Override
    public ProcessDefinitionEntity execute(CommandContext commandContext) {
      return Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedLatestProcessDefinitionByKey("myProcess");
    }
  });

  assertNotNull(processDefinitionEntity);
  assertEquals(7, processDefinitionEntity.getActivities().size());

  // Check if diagram has been created based on Diagram Interchange when it's
  // not a headless instance
  List<String> resourceNames = repositoryService.getDeploymentResourceNames(processDefinitionEntity.getDeploymentId());
  if (processEngineConfiguration.isCreateDiagramOnDeploy()) {
    assertEquals(2, resourceNames.size());
  } else {
    assertEquals(1, resourceNames.size());
  }

  for (ActivityImpl activity : processDefinitionEntity.getActivities()) {

    if (activity.getId().equals("theStart")) {
      assertActivityBounds(activity, 70, 255, 30, 30);
    } else if (activity.getId().equals("task1")) {
      assertActivityBounds(activity, 176, 230, 100, 80);
    } else if (activity.getId().equals("gateway1")) {
      assertActivityBounds(activity, 340, 250, 40, 40);
    } else if (activity.getId().equals("task2")) {
      assertActivityBounds(activity, 445, 138, 100, 80);
    } else if (activity.getId().equals("gateway2")) {
      assertActivityBounds(activity, 620, 250, 40, 40);
    } else if (activity.getId().equals("task3")) {
      assertActivityBounds(activity, 453, 304, 100, 80);
    } else if (activity.getId().equals("theEnd")) {
      assertActivityBounds(activity, 713, 256, 28, 28);
    }

    for (PvmTransition sequenceFlow : activity.getOutgoingTransitions()) {
      assertTrue(((TransitionImpl) sequenceFlow).getWaypoints().size() >= 4);

      TransitionImpl transitionImpl = (TransitionImpl) sequenceFlow;
      if (transitionImpl.getId().equals("flowStartToTask1")) {
        assertSequenceFlowWayPoints(transitionImpl, 100, 270, 176, 270);
      } else if (transitionImpl.getId().equals("flowTask1ToGateway1")) {
        assertSequenceFlowWayPoints(transitionImpl, 276, 270, 340, 270);
      } else if (transitionImpl.getId().equals("flowGateway1ToTask2")) {
        assertSequenceFlowWayPoints(transitionImpl, 360, 250, 360, 178, 445, 178);
      } else if (transitionImpl.getId().equals("flowGateway1ToTask3")) {
        assertSequenceFlowWayPoints(transitionImpl, 360, 290, 360, 344, 453, 344);
      } else if (transitionImpl.getId().equals("flowTask2ToGateway2")) {
        assertSequenceFlowWayPoints(transitionImpl, 545, 178, 640, 178, 640, 250);
      } else if (transitionImpl.getId().equals("flowTask3ToGateway2")) {
        assertSequenceFlowWayPoints(transitionImpl, 553, 344, 640, 344, 640, 290);
      } else if (transitionImpl.getId().equals("flowGateway2ToEnd")) {
        assertSequenceFlowWayPoints(transitionImpl, 660, 270, 713, 270);
      }

    }
  }
}
 
Example 17
Source File: UserOperationLogQueryTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/api/repository/ProcessDefinitionSuspensionTest.testWithOneAsyncServiceTask.bpmn"})
public void testQueryProcessDefinitionOperationWithDelayedProcessDefinition() {
  // given
  ClockUtil.setCurrentTime(today);
  final long hourInMs = 60 * 60 * 1000;

  String key = "oneFailingServiceTaskProcess";

  // a running process instance with a failed service task
  Map<String, Object> params = new HashMap<String, Object>();
  params.put("fail", Boolean.TRUE);
  runtimeService.startProcessInstanceByKey(key, params);

  // when
  // the process definition will be suspended
  repositoryService.suspendProcessDefinitionByKey(key, false, new Date(today.getTime() + (2 * hourInMs)));

  // then
  // there exists a timer job to suspend the process definition delayed
  Job timerToSuspendProcessDefinition = managementService.createJobQuery().timers().singleResult();
  assertNotNull(timerToSuspendProcessDefinition);

  // there is a user log entry for the activation
  Long processDefinitionEntryCount = query()
    .entityType(PROCESS_DEFINITION)
    .operationType(UserOperationLogEntry.OPERATION_TYPE_SUSPEND_PROCESS_DEFINITION)
    .processDefinitionKey(key)
    .category(UserOperationLogEntry.CATEGORY_OPERATOR)
    .property(SUSPENSION_STATE_PROPERTY)
    .count();

  assertEquals(1, processDefinitionEntryCount.longValue());

  // when
  // execute job
  managementService.executeJob(timerToSuspendProcessDefinition.getId());

  // then
  // there is a user log entry for the activation
  processDefinitionEntryCount = query()
    .entityType(PROCESS_DEFINITION)
    .operationType(UserOperationLogEntry.OPERATION_TYPE_SUSPEND_PROCESS_DEFINITION)
    .processDefinitionKey(key)
    .category(UserOperationLogEntry.CATEGORY_OPERATOR)
    .property(SUSPENSION_STATE_PROPERTY)
    .count();

  assertEquals(1, processDefinitionEntryCount.longValue());

  // clean up op log
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  commandExecutor.execute(new Command<Object>() {
    public Object execute(CommandContext commandContext) {
      commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerSuspendProcessDefinitionHandler.TYPE);
      return null;
    }
  });
}
 
Example 18
Source File: SetProcessDefinitionVersionCmdTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment
  public void testSetProcessDefinitionVersion() {
    // start process instance
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");

    // check that receive task has been reached
    Execution execution = runtimeService.createExecutionQuery()
      .processInstanceId(pi.getId())
      .activityId("waitState1")
      .singleResult();
    assertNotNull(execution);

    // deploy new version of the process definition
    org.camunda.bpm.engine.repository.Deployment deployment = repositoryService
      .createDeployment()
      .addClasspathResource(TEST_PROCESS)
      .deploy();
    assertEquals(2, repositoryService.createProcessDefinitionQuery().count());

    // migrate process instance to new process definition version
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.getId(), 2));

    // signal process instance
    runtimeService.signal(execution.getId());

    // check that the instance now uses the new process definition version
    ProcessDefinition newProcessDefinition = repositoryService
      .createProcessDefinitionQuery()
      .processDefinitionVersion(2)
      .singleResult();
    pi = runtimeService
      .createProcessInstanceQuery()
      .processInstanceId(pi.getId())
      .singleResult();
    assertEquals(newProcessDefinition.getId(), pi.getProcessDefinitionId());

    // check history
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
      HistoricProcessInstance historicPI = historyService
        .createHistoricProcessInstanceQuery()
        .processInstanceId(pi.getId())
        .singleResult();

//      assertEquals(newProcessDefinition.getId(), historicPI.getProcessDefinitionId());
    }

    // undeploy "manually" deployed process definition
    repositoryService.deleteDeployment(deployment.getId(), true);
  }
 
Example 19
Source File: SetProcessDefinitionVersionCmdTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = TEST_PROCESS_TWO_JOBS)
public void testMigrateJobWithMultipleDefinitionsOnActivity() {
  // given a process instance
  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);
}
 
Example 20
Source File: StartTimerEventTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
private void cleanDB() {
  String jobId = managementService.createJobQuery().singleResult().getId();
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  commandExecutor.execute(new DeleteJobsCmd(jobId, true));
}