ProcessDefinition newDefinition =
repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
assertNotNull(newDefinition);
JobDefinition asnycBeforeJobDefinition =
managementService.createJobDefinitionQuery()
.jobConfiguration(MessageJobDeclaration.ASYNC_BEFORE)
.processDefinitionId(newDefinition.getId())
.singleResult();
JobDefinition asnycAfterJobDefinition =
managementService.createJobDefinitionQuery()
.jobConfiguration(MessageJobDeclaration.ASYNC_AFTER)
.processDefinitionId(newDefinition.getId())
.singleResult();
assertNotNull(asnycBeforeJobDefinition);
assertNotNull(asnycAfterJobDefinition);
// when the process instances are migrated
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new SetProcessDefinitionVersionCmd(asyncBeforeInstance.getId(), 2));
commandExecutor.execute(new SetProcessDefinitionVersionCmd(asyncAfterInstance.getId(), 2));
// then the the job's definition reference should also be migrated
Job migratedAsyncBeforeJob = managementService.createJobQuery()
.processInstanceId(asyncBeforeInstance.getId()).singleResult();
assertEquals(asyncBeforeJob.getId(), migratedAsyncBeforeJob.getId());
assertNotNull(migratedAsyncBeforeJob);
assertEquals(asnycBeforeJobDefinition.getId(), migratedAsyncBeforeJob.getJobDefinitionId());
Job migratedAsyncAfterJob = managementService.createJobQuery()
.processInstanceId(asyncAfterInstance.getId()).singleResult();
assertEquals(asyncAfterJob.getId(), migratedAsyncAfterJob.getId());
assertNotNull(migratedAsyncAfterJob);
assertEquals(asnycAfterJobDefinition.getId(), migratedAsyncAfterJob.getJobDefinitionId());
repositoryService.deleteDeployment(deployment.getId(), true);
}