Exemple #1
0
        public virtual 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.camunda.bpm.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.CommandExecutorTxRequired;
            SetProcessDefinitionVersionCmd setProcessDefinitionVersionCmd = new SetProcessDefinitionVersionCmd(pi.Id, 2);

            try
            {
                commandExecutor.execute(setProcessDefinitionVersionCmd);
                fail("ProcessEngineException expected");
            }
            catch (ProcessEngineException ae)
            {
                assertTextPresent("The new process definition (key = 'receiveTask') does not contain the current activity (id = 'waitState1') of the process instance (id = '", ae.Message);
            }

            // undeploy "manually" deployed process definition
            repositoryService.deleteDeployment(deployment.Id, true);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void execute(org.Camunda.bpm.Engine.Delegate.IDelegateExecution execution) throws Exception
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            var repoService      = ((IDelegateExecution)execution).ProcessEngineServices.RepositoryService;
            var targetDefinition = repoService.CreateProcessDefinitionQuery()
                                   /*.LatestVersion()*/
                                   .First();

            var migrationCommand = new SetProcessDefinitionVersionCmd(
                ((IDelegateExecution)execution).ProcessInstanceId,
                targetDefinition.Version);

            ESS.FW.Bpm.Engine.context.Impl.Context.ProcessEngineConfiguration.CommandExecutorTxRequired.Execute(migrationCommand);
        }
Exemple #3
0
        public virtual void testSetProcessDefinitionVersionPIIsSubExecution()
        {
            // start process instance
            ProcessInstance pi = runtimeService.startProcessInstanceByKey("forkJoin");

            Execution       execution              = runtimeService.createExecutionQuery().activityId("receivePayment").singleResult();
            CommandExecutor commandExecutor        = processEngineConfiguration.CommandExecutorTxRequired;
            SetProcessDefinitionVersionCmd command = new SetProcessDefinitionVersionCmd(execution.Id, 1);

            try
            {
                commandExecutor.execute(command);
                fail("ProcessEngineException expected");
            }
            catch (ProcessEngineException ae)
            {
                assertTextPresent("A process instance id is required, but the provided id '" + execution.Id + "' points to a child execution of process instance '" + pi.Id + "'. Please invoke the " + command.GetType().Name + " with a root execution id.", ae.Message);
            }
        }
        public virtual void testSetProcessDefinitionVersionActivityMissing()
        {
            // start process instance
            var pi = runtimeService.StartProcessInstanceByKey("receiveTask");

            // check that receive task has been reached
            var execution = runtimeService.CreateExecutionQuery(c => c.ActivityId == "waitState1")
                            .First();

            Assert.NotNull(execution);

            // deploy new version of the process definition
            var deployment = repositoryService.CreateDeployment()
                             .AddClasspathResource(TEST_PROCESS_ACTIVITY_MISSING)
                             .Deploy();

            Assert.AreEqual(2, repositoryService.CreateProcessDefinitionQuery()
                            .Count());

            // migrate process instance to new process definition version
            var commandExecutor = processEngineConfiguration.CommandExecutorTxRequired;
            var setProcessDefinitionVersionCmd = new SetProcessDefinitionVersionCmd(pi.Id, 2);

            try
            {
                commandExecutor.Execute(setProcessDefinitionVersionCmd);
                Assert.Fail("ProcessEngineException expected");
            }
            catch (ProcessEngineException ae)
            {
                AssertTextPresent(
                    "The new process definition (key = 'receiveTask') does not contain the current activity (id = 'waitState1') of the process instance (id = '",
                    ae.Message);
            }

            // undeploy "manually" deployed process definition
            repositoryService.DeleteDeployment(deployment.Id, true);
        }