AnsweredAssumed Answered

Undeployment Testing

Question asked by izaak on Nov 21, 2012
Latest reply on Nov 22, 2012 by izaak
I'm attempting to verify some methods for programmatically migrating between versions of a given process definition. I'm having a hard time simulating it in a test however. I expected i could deploy my process once, create a process instance and move it through workflow a bit:


repositoryService.createDeployment().addClasspathResource("Process.bpmn20.xml").deploy();
ProcessInstance processInstance = engine.getRuntimeService().startProcessInstanceByKey("Process");
int version = processDefinition.getVersion();

// move the the workflow

Then redeploy it, verify the new version exists:


      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]

Then forceably modify the version of the given instance (this code seems awful – is there a more intended way to do this?):


SetProcessDefinitionVersionCmd cmd = new SetProcessDefinitionVersionCmd(procId, processDefinition.getVersion() + 1);
      ((ProcessEngineConfigurationImpl) ((WorkflowConfigurationActivitiImpl) activitiConfig).getProcessEngineConfig())
            .getCommandExecutorTxRequired().execute(cmd);

      assertEquals(newVersionProcessDefinition.getVersion(), processDefinition.getVersion());
//continue moving through workflow

Then continue moving through the workflow. Everytime i do this however the new process doesn't seem to update the version number on the bolded assertion. Any suggestions for accomplishing this?

Any suggestions on resources for people who've had to do this (it seems a bit sparse out there – and i haven't even gotten near the real problem of what happens when there is a significant change to the process).

Outcomes