use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.
the class SetProcessDefinitionVersionCmdTest method testSetProcessDefinitionVersionPIIsSubExecution.
@Deployment(resources = { TEST_PROCESS_WITH_PARALLEL_GATEWAY })
public void testSetProcessDefinitionVersionPIIsSubExecution() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("forkJoin");
Execution execution = runtimeService.createExecutionQuery().activityId("receivePayment").singleResult();
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
SetProcessDefinitionVersionCmd command = new SetProcessDefinitionVersionCmd(execution.getId(), 1);
try {
commandExecutor.execute(command);
fail("ProcessEngineException expected");
} catch (ProcessEngineException ae) {
assertTextPresent("A process instance id is required, but the provided id '" + execution.getId() + "' points to a child execution of process instance '" + pi.getId() + "'. Please invoke the " + command.getClass().getSimpleName() + " with a root execution id.", ae.getMessage());
}
}
use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.
the class SetProcessDefinitionVersionCmdTest method setProcessDefinitionVersion.
protected void setProcessDefinitionVersion(String processInstanceId, int newProcessDefinitionVersion) {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew();
commandExecutor.execute(new SetProcessDefinitionVersionCmd(processInstanceId, newProcessDefinitionVersion));
}
use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.
the class SetProcessDefinitionVersionCmdTest method testMigrateJobWithMultipleDefinitionsOnActivity.
@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);
}
use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.
the class SetProcessDefinitionVersionCmdTest method testSetProcessDefinitionVersionAttachedTimer.
@Deployment(resources = TEST_PROCESS_ATTACHED_TIMER)
public void testSetProcessDefinitionVersionAttachedTimer() {
// given a process instance
ProcessInstance instance = runtimeService.startProcessInstanceByKey("attachedTimer");
// and a second deployment of the process
org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_ATTACHED_TIMER).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));
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
assertEquals(newDefinition.getId(), job.getProcessDefinitionId());
repositoryService.deleteDeployment(deployment.getId(), true);
}
use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.
the class MigrateProcessInstanceDelegate method execute.
public void execute(DelegateExecution execution) throws Exception {
RepositoryService repoService = execution.getProcessEngineServices().getRepositoryService();
ProcessDefinition targetDefinition = repoService.createProcessDefinitionQuery().latestVersion().singleResult();
SetProcessDefinitionVersionCmd migrationCommand = new SetProcessDefinitionVersionCmd(execution.getProcessInstanceId(), targetDefinition.getVersion());
Context.getProcessEngineConfiguration().getCommandExecutorTxRequired().execute(migrationCommand);
}
Aggregations