use of org.activiti.engine.impl.cmd.SetProcessDefinitionVersionCmd in project Activiti by Activiti.
the class ProcessInstanceMigrationTest method testSetProcessDefinitionVersionSubExecutions.
@Deployment(resources = { TEST_PROCESS_WITH_PARALLEL_GATEWAY })
public void testSetProcessDefinitionVersionSubExecutions() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("forkJoin");
// 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_WITH_PARALLEL_GATEWAY).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);
}
use of org.activiti.engine.impl.cmd.SetProcessDefinitionVersionCmd in project Activiti by Activiti.
the class ProcessInstanceMigrationTest method testSetProcessDefinitionVersionActivityMissing.
@Deployment(resources = { TEST_PROCESS })
public void testSetProcessDefinitionVersionActivityMissing() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
// check that receive task has been reached
Execution execution = runtimeService.createExecutionQuery().activityId("waitState1").singleResult();
assertNotNull(execution);
// deploy new version of the process definition
org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_ACTIVITY_MISSING).deploy();
assertEquals(2, repositoryService.createProcessDefinitionQuery().count());
// migrate process instance to new process definition version
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
SetProcessDefinitionVersionCmd setProcessDefinitionVersionCmd = new SetProcessDefinitionVersionCmd(pi.getId(), 2);
try {
commandExecutor.execute(setProcessDefinitionVersionCmd);
fail("ActivitiException expected");
} catch (ActivitiException ae) {
assertTextPresent("The new process definition (key = 'receiveTask') does not contain the current activity (id = 'waitState1') of the process instance (id = '", ae.getMessage());
}
// 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 testSetProcessDefinitionVersionNonExistingPD.
@Deployment(resources = { TEST_PROCESS })
public void testSetProcessDefinitionVersionNonExistingPD() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
try {
commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.getId(), 23));
fail("ActivitiException expected");
} catch (ActivitiObjectNotFoundException ae) {
assertTextPresent("no processes deployed with key = 'receiveTask' and version = '23'", ae.getMessage());
assertEquals(ProcessDefinition.class, ae.getObjectClass());
}
}
use of org.activiti.engine.impl.cmd.SetProcessDefinitionVersionCmd in project Activiti by Activiti.
the class ProcessInstanceMigrationTest method testSetProcessDefinitionVersionWithWithTask.
@Deployment(resources = { TEST_PROCESS_USER_TASK_V1 })
public void testSetProcessDefinitionVersionWithWithTask() {
try {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("userTask");
// check that user task has been reached
assertEquals(1, taskService.createTaskQuery().processInstanceId(pi.getId()).count());
// deploy new version of the process definition
org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_USER_TASK_V2).deploy();
assertEquals(2, repositoryService.createProcessDefinitionQuery().processDefinitionKey("userTask").count());
ProcessDefinition newProcessDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("userTask").processDefinitionVersion(2).singleResult();
// migrate process instance to new process definition version
processEngineConfiguration.getCommandExecutor().execute(new SetProcessDefinitionVersionCmd(pi.getId(), 2));
// check UserTask
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals(newProcessDefinition.getId(), task.getProcessDefinitionId());
assertEquals("testFormKey", formService.getTaskFormData(task.getId()).getFormKey());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().processInstanceId(pi.getId()).singleResult();
assertEquals(newProcessDefinition.getId(), historicTask.getProcessDefinitionId());
assertEquals("testFormKey", formService.getTaskFormData(historicTask.getId()).getFormKey());
}
// continue
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
// undeploy "manually" deployed process definition
repositoryService.deleteDeployment(deployment.getId(), true);
} catch (Exception ex) {
fail(ex.getMessage());
}
}
Aggregations