use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.
the class SetProcessDefinitionVersionCmdTest method testSetProcessDefinitionVersionNonExistingPI.
public void testSetProcessDefinitionVersionNonExistingPI() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
try {
commandExecutor.execute(new SetProcessDefinitionVersionCmd("42", 23));
fail("ProcessEngineException expected");
} catch (ProcessEngineException ae) {
assertTextPresent("No process instance found for id = '42'.", ae.getMessage());
}
}
use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.
the class SetProcessDefinitionVersionCmdTest 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.camunda.bpm.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.getCommandExecutorTxRequired().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());
// continue
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
// undeploy "manually" deployed process definition
repositoryService.deleteDeployment(deployment.getId(), true);
} catch (Exception ex) {
ex.printStackTrace();
}
}
use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.
the class SetProcessDefinitionVersionCmdTest method testSetProcessDefinitionVersionNonExistingPD.
@Deployment(resources = { TEST_PROCESS })
public void testSetProcessDefinitionVersionNonExistingPD() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
try {
commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.getId(), 23));
fail("ProcessEngineException expected");
} catch (ProcessEngineException ae) {
assertTextPresent("no processes deployed with key = 'receiveTask', version = '23'", ae.getMessage());
}
}
use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.
the class SetProcessDefinitionVersionCmdTest 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.camunda.bpm.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.getCommandExecutorTxRequired();
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.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.
the class SetProcessDefinitionVersionCmdTest method testSetProcessDefinitionVersionMigrateIncident.
@Deployment(resources = TEST_PROCESS_ONE_JOB)
public void testSetProcessDefinitionVersionMigrateIncident() {
// given a process instance
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneJobProcess", Variables.createVariables().putValue("shouldFail", true));
// with a failed job
executeAvailableJobs();
// and an incident
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertNotNull(incident);
// 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 incident should also be migrated
Incident migratedIncident = runtimeService.createIncidentQuery().singleResult();
assertNotNull(migratedIncident);
assertEquals(newDefinition.getId(), migratedIncident.getProcessDefinitionId());
assertEquals(instance.getId(), migratedIncident.getProcessInstanceId());
assertEquals(instance.getId(), migratedIncident.getExecutionId());
repositoryService.deleteDeployment(deployment.getId(), true);
}
Aggregations