use of org.activiti.engine.impl.cmd.SetProcessDefinitionVersionCmd in project Activiti by Activiti.
the class ProcessInstanceMigrationTest 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.getCommandExecutor();
SetProcessDefinitionVersionCmd command = new SetProcessDefinitionVersionCmd(execution.getId(), 1);
try {
commandExecutor.execute(command);
fail("ActivitiException expected");
} catch (ActivitiException 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.activiti.engine.impl.cmd.SetProcessDefinitionVersionCmd in project Activiti by Activiti.
the class ProcessInstanceMigrationTest method testSetProcessDefinitionVersionNonExistingPI.
public void testSetProcessDefinitionVersionNonExistingPI() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
try {
commandExecutor.execute(new SetProcessDefinitionVersionCmd("42", 23));
fail("ActivitiException expected");
} catch (ActivitiObjectNotFoundException ae) {
assertTextPresent("No process instance found for id = '42'.", ae.getMessage());
assertEquals(ProcessInstance.class, ae.getObjectClass());
}
}
use of org.activiti.engine.impl.cmd.SetProcessDefinitionVersionCmd in project Activiti by Activiti.
the class ProcessInstanceMigrationTest method testSetProcessDefinitionVersion.
@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.activiti.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.getCommandExecutor();
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().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstance historicPI = historyService.createHistoricProcessInstanceQuery().processInstanceId(pi.getId()).singleResult();
assertEquals(newProcessDefinition.getId(), historicPI.getProcessDefinitionId());
List<HistoricActivityInstance> historicActivities = historyService.createHistoricActivityInstanceQuery().processInstanceId(pi.getId()).unfinished().list();
assertEquals(1, historicActivities.size());
assertEquals(newProcessDefinition.getId(), historicActivities.get(0).getProcessDefinitionId());
}
// undeploy "manually" deployed process definition
repositoryService.deleteDeployment(deployment.getId(), true);
}
use of org.activiti.engine.impl.cmd.SetProcessDefinitionVersionCmd in project Activiti by Activiti.
the class ProcessInstanceMigrationTest method testSetProcessDefinitionVersionWithCallActivity.
@Deployment(resources = { TEST_PROCESS_CALL_ACTIVITY })
public void testSetProcessDefinitionVersionWithCallActivity() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("parentProcess");
// check that receive task has been reached
Execution execution = runtimeService.createExecutionQuery().activityId("waitState1").processDefinitionKey("childProcess").singleResult();
assertNotNull(execution);
// deploy new version of the process definition
org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_CALL_ACTIVITY).deploy();
assertEquals(2, repositoryService.createProcessDefinitionQuery().processDefinitionKey("parentProcess").count());
// migrate process instance to new process definition version
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.getId(), 2));
// signal process instance
runtimeService.signal(execution.getId());
// should be finished now
assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).count());
// undeploy "manually" deployed process definition
repositoryService.deleteDeployment(deployment.getId(), true);
}
use of org.activiti.engine.impl.cmd.SetProcessDefinitionVersionCmd in project Activiti by Activiti.
the class ProcessInstanceMigrationTest method testSetProcessDefinitionVersionSubExecutionsNested.
@Deployment(resources = { TEST_PROCESS_NESTED_SUB_EXECUTIONS })
public void testSetProcessDefinitionVersionSubExecutionsNested() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("forkJoinNested");
// check that the user tasks have been reached
assertEquals(2, taskService.createTaskQuery().count());
// deploy new version of the process definition
org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_NESTED_SUB_EXECUTIONS).deploy();
assertEquals(2, repositoryService.createProcessDefinitionQuery().count());
// migrate process instance to new process definition version
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.getId(), 2));
// check that all executions of the instance now use the new process definition version
ProcessDefinition newProcessDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(2).singleResult();
List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).list();
for (Execution execution : executions) {
assertEquals(newProcessDefinition.getId(), ((ExecutionEntity) execution).getProcessDefinitionId());
}
// undeploy "manually" deployed process definition
repositoryService.deleteDeployment(deployment.getId(), true);
}
Aggregations