11-21-2012 10:36 AM
repositoryService.createDeployment().addClasspathResource("Process.bpmn20.xml").deploy();
ProcessInstance processInstance = engine.getRuntimeService().startProcessInstanceByKey("Process");
int version = processDefinition.getVersion();
// move the the workflow
System.out.println("Before (RE)Deployment");
Deployment deployment = repositoryService.createDeployment().addClasspathResource("Process-v2.bpmn20.xml").deploy();
ProcessInstance newVersionProcessInstance = engine.getRuntimeService().startProcessInstanceByKey("Process");
ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.getDeployedProcessDefinition(newVersionProcessInstance
.getProcessDefinitionId());
[b]assertEquals(version + 1, processDefinition.getVersion());[/b]
SetProcessDefinitionVersionCmd cmd = new SetProcessDefinitionVersionCmd(procId, processDefinition.getVersion() + 1);
((ProcessEngineConfigurationImpl) ((WorkflowConfigurationActivitiImpl) activitiConfig).getProcessEngineConfig())
.getCommandExecutorTxRequired().execute(cmd);
assertEquals(newVersionProcessDefinition.getVersion(), processDefinition.getVersion());
//continue moving through workflow
11-22-2012 04:32 AM
@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.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().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstance historicPI = historyService
.createHistoricProcessInstanceQuery()
.processInstanceId(pi.getId())
.singleResult();
assertEquals(newProcessDefinition.getId(), historicPI.getProcessDefinitionId());
}
// undeploy "manually" deployed process definition
repositoryService.deleteDeployment(deployment.getId(), true);
}
11-22-2012 12:10 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.