Beispiel #1
0
        public virtual void checkCreateMigrationPlan(ProcessDefinition sourceProcessDefinition, ProcessDefinition targetProcessDefinition)
        {
            string sourceTenant = sourceProcessDefinition.TenantId;
            string targetTenant = targetProcessDefinition.TenantId;

            if (!TenantManager.isAuthenticatedTenant(sourceTenant))
            {
                throw LOG.exceptionCommandWithUnauthorizedTenant("get process definition '" + sourceProcessDefinition.Id + "'");
            }
            if (!TenantManager.isAuthenticatedTenant(targetTenant))
            {
                throw LOG.exceptionCommandWithUnauthorizedTenant("get process definition '" + targetProcessDefinition.Id + "'");
            }

            if (!string.ReferenceEquals(sourceTenant, null) && !string.ReferenceEquals(targetTenant, null) && !sourceTenant.Equals(targetTenant))
            {
                throw ProcessEngineLogger.MIGRATION_LOGGER.cannotMigrateBetweenTenants(sourceTenant, targetTenant);
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateCompensationSubscriptionAddRemoveSubProcessAssertExecutionTree()
        public virtual void testMigrateCompensationSubscriptionAddRemoveSubProcessAssertExecutionTree()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);

            // subProcess is not mapped
            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();

            ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            testHelper.completeTask("userTask1");

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then the execution tree is correct
            testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.Id).matches(describeExecutionTree("userTask2").scope().id(testHelper.snapshotBeforeMigration.ProcessInstanceId).child("subProcess").scope().eventScope().done());
        }
Beispiel #3
0
        public virtual void testFailToStartProcessInstanceByIdNoAuthenticatedTenants()
        {
            deploymentForTenant(TENANT_ONE, PROCESS);

            ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();

            identityService.setAuthentication("user", null, null);

            try
            {
                runtimeService.createProcessInstanceById(processDefinition.Id).execute();

                fail("expected exception");
            }
            catch (ProcessEngineException e)
            {
                assertThat(e.Message, containsString("Cannot create an instance of the process definition"));
            }
        }
Beispiel #4
0
        public virtual void testStartProcessInstanceWithLatestBindingDifferentVersion()
        {
            BpmnModelInstance callingProcess = Bpmn.createExecutableProcess("callingProcess").startEvent().callActivity().calledElement("subProcess").camundaCalledElementBinding("latest").endEvent().done();

            deploymentForTenant(TENANT_ONE, callingProcess, SUB_PROCESS);

            deploymentForTenant(TENANT_TWO, callingProcess, SUB_PROCESS);
            deploymentForTenant(TENANT_TWO, SUB_PROCESS);

            runtimeService.createProcessInstanceByKey("callingProcess").processDefinitionTenantId(TENANT_ONE).execute();
            runtimeService.createProcessInstanceByKey("callingProcess").processDefinitionTenantId(TENANT_TWO).execute();

            ProcessDefinition latestSubProcessTenantTwo = repositoryService.createProcessDefinitionQuery().tenantIdIn(TENANT_TWO).processDefinitionKey("subProcess").latestVersion().singleResult();

            ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processDefinitionKey("subProcess");

            assertThat(query.tenantIdIn(TENANT_ONE).count(), @is(1L));
            assertThat(query.tenantIdIn(TENANT_TWO).processDefinitionId(latestSubProcessTenantTwo.Id).count(), @is(1L));
        }
Beispiel #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateGatewayWithMessageEventMapEvent()
        public virtual void testMigrateGatewayWithMessageEventMapEvent()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.MESSAGE_EVENT_BASED_GW_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.MESSAGE_EVENT_BASED_GW_PROCESS);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("messageCatch", "messageCatch").build();

            // when
            ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);

            // then
            testHelper.assertEventSubscriptionMigrated("messageCatch", "messageCatch", EventBasedGatewayModels.MESSAGE_NAME);

            rule.RuntimeService.correlateMessage(EventBasedGatewayModels.MESSAGE_NAME);

            testHelper.completeTask("afterMessageCatch");
            testHelper.assertProcessEnded(processInstance.Id);
        }
Beispiel #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canMigrateInstanceBetweenSameTenantCase1()
        public virtual void canMigrateInstanceBetweenSameTenantCase1()
        {
            // given
            ProcessDefinition sourceDefinition = defaultTestRule.deployForTenantAndGetDefinition(TENANT_ONE, ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetDefinition = defaultTestRule.deployForTenantAndGetDefinition(TENANT_ONE, ProcessModels.ONE_TASK_PROCESS);

            ProcessInstance processInstance = defaultEngineRule.RuntimeService.startProcessInstanceById(sourceDefinition.Id);
            MigrationPlan   migrationPlan   = defaultEngineRule.RuntimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapEqualActivities().build();

            Batch batch = defaultEngineRule.RuntimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).executeAsync();

            batchHelper.executeSeedJob(batch);

            // when
            batchHelper.executeJobs(batch);

            // then
            assertMigratedTo(processInstance, targetDefinition);
        }
Beispiel #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void cannotMigrateOfNonAuthenticatedTenant()
        public virtual void cannotMigrateOfNonAuthenticatedTenant()
        {
            // given
            ProcessDefinition sourceDefinition = testHelper.deployForTenantAndGetDefinition(TENANT_ONE, ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetDefinition = testHelper.deployForTenantAndGetDefinition(TENANT_ONE, ProcessModels.ONE_TASK_PROCESS);

            MigrationPlan migrationPlan = engineRule.RuntimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapEqualActivities().build();

            ProcessInstance processInstance = engineRule.RuntimeService.startProcessInstanceById(sourceDefinition.Id);

            engineRule.IdentityService.setAuthentication("user", null, Arrays.asList(TENANT_TWO));

            // then
            exception.expect(typeof(ProcessEngineException));
            exception.expectMessage("Cannot migrate process instance '" + processInstance.Id + "' because it belongs to no authenticated tenant");

            // when
            engineRule.RuntimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).execute();
        }
Beispiel #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateEventSubscription()
        public virtual void testMigrateEventSubscription()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ONE_CONDITION_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ONE_CONDITION_PROCESS);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities(CONDITION_ID, CONDITION_ID).updateEventTrigger().build();

            //when
            ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);

            testHelper.assertEventSubscriptionMigrated(CONDITION_ID, CONDITION_ID, null);

            //then it is possible to trigger the conditional event
            testHelper.setVariable(processInstance.Id, VAR_NAME, "1");

            testHelper.completeTask(USER_TASK_ID);
            testHelper.assertProcessEnded(processInstance.Id);
        }
Beispiel #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateGatewayWithSignalEventChangeId()
        public virtual void testMigrateGatewayWithSignalEventChangeId()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.SIGNAL_EVENT_BASED_GW_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.SIGNAL_EVENT_BASED_GW_PROCESS).changeElementId("signalCatch", "newSignalCatch"));

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("signalCatch", "newSignalCatch").build();

            // when
            ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);

            // then
            testHelper.assertEventSubscriptionMigrated("signalCatch", "newSignalCatch", EventBasedGatewayModels.SIGNAL_NAME);

            rule.RuntimeService.signalEventReceived(EventBasedGatewayModels.SIGNAL_NAME);

            testHelper.completeTask("afterSignalCatch");
            testHelper.assertProcessEnded(processInstance.Id);
        }
Beispiel #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCannotAddScopeOnTopOfEventSubProcess()
        public virtual void testCannotAddScopeOnTopOfEventSubProcess()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_EVENT_SUBPROCESS_MODEL);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.DOUBLE_SUBPROCESS_MODEL).addSubProcessTo("innerSubProcess").id("eventSubProcess").triggerByEvent().embeddedSubProcess().startEvent("eventSubProcessStart").compensateEventDefinition().compensateEventDefinitionDone().endEvent().done());


            try
            {
                // when
                rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("subProcess", "outerSubProcess").mapActivities("eventSubProcessStart", "eventSubProcessStart").mapActivities("compensationBoundary", "compensationBoundary").mapActivities("userTask2", "userTask2").build();
                Assert.fail("exception expected");
            }
            catch (MigrationPlanValidationException e)
            {
                // then
                assertThat(e.ValidationReport).hasInstructionFailures("eventSubProcessStart", "The source activity's event scope (subProcess) must be mapped to the target activity's event scope (innerSubProcess)");
            }
        }
Beispiel #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateEventSubProcessToTransaction()
        public virtual void testMigrateEventSubProcessToTransaction()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventSubProcessModels.MESSAGE_EVENT_SUBPROCESS_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(TransactionModels.ONE_TASK_TRANSACTION);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("eventSubProcess", "transaction").mapActivities("eventSubProcessTask", "userTask").build();

            // when
            ProcessInstance processInstance = rule.RuntimeService.createProcessInstanceById(sourceProcessDefinition.Id).startBeforeActivity("eventSubProcessTask").execute();

            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then
            Assert.assertEquals(testHelper.getSingleActivityInstanceBeforeMigration("eventSubProcess").Id, testHelper.getSingleActivityInstanceAfterMigration("transaction").Id);

            testHelper.completeTask("userTask");
            testHelper.assertProcessEnded(processInstance.Id);
        }
Beispiel #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testParallelGatewayAssertTrees()
        public virtual void testParallelGatewayAssertTrees()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(GatewayModels.PARALLEL_GW);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(GatewayModels.PARALLEL_GW);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("parallel1", "parallel1").mapActivities("join", "join").build();

            ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            testHelper.completeTask("parallel2");

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then
            testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.Id).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.ProcessInstanceId).child("parallel1").noScope().concurrent().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("parallel1")).up().child("join").noScope().concurrent().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("join")).done());

            testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.Id).activity("parallel1", testHelper.getSingleActivityInstanceBeforeMigration("parallel1").Id).activity("join", testHelper.getSingleActivityInstanceBeforeMigration("join").Id).done());
        }
Beispiel #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testNoListenersCalled()
        public virtual void testNoListenersCalled()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL).activityBuilder("subProcess").camundaExecutionListenerClass([email protected]_Fields.EVENTNAME_END, typeof(RecorderExecutionListener).FullName).done());
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();

            ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            testHelper.completeTask("userTask1");

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then
            // the listener was only called once when the sub process completed properly
            Assert.assertEquals(1, RecorderExecutionListener.RecordedEvents.Count);
        }
Beispiel #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void cannotMigrateInstanceWithoutTenantIdToDifferentTenant()
        public virtual void cannotMigrateInstanceWithoutTenantIdToDifferentTenant()
        {
            // given
            ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetDefinition = testHelper.deployForTenantAndGetDefinition(TENANT_ONE, ProcessModels.ONE_TASK_PROCESS);

            ProcessInstance processInstance = engineRule.RuntimeService.startProcessInstanceById(sourceDefinition.Id);
            MigrationPlan   migrationPlan   = engineRule.RuntimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapEqualActivities().build();

            // when
            try
            {
                engineRule.RuntimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).execute();
                Assert.fail("exception expected");
            }
            catch (ProcessEngineException e)
            {
                Assert.assertThat(e.Message, CoreMatchers.containsString("Cannot migrate process instance '" + processInstance.Id + "' without tenant to a process definition with a tenant ('tenant1')"));
            }
        }
Beispiel #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canMigrateWithProcessInstanceQueryAllInstancesOfAuthenticatedTenants()
        public virtual void canMigrateWithProcessInstanceQueryAllInstancesOfAuthenticatedTenants()
        {
            // given
            ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);

            MigrationPlan migrationPlan = engineRule.RuntimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapEqualActivities().build();

            ProcessInstance processInstance1 = startInstanceForTenant(sourceDefinition, TENANT_ONE);
            ProcessInstance processInstance2 = startInstanceForTenant(sourceDefinition, TENANT_TWO);

            // when
            engineRule.IdentityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO));
            engineRule.RuntimeService.newMigration(migrationPlan).processInstanceQuery(engineRule.RuntimeService.createProcessInstanceQuery()).execute();
            engineRule.IdentityService.clearAuthentication();

            // then
            assertInstanceOfDefinition(processInstance1, targetDefinition);
            assertInstanceOfDefinition(processInstance2, targetDefinition);
        }
Beispiel #16
0
        public static ProcessDefinitionDto fromProcessDefinition(ProcessDefinition definition)
        {
            ProcessDefinitionDto dto = new ProcessDefinitionDto();

            dto.id                    = definition.Id;
            dto.key                   = definition.Key;
            dto.category              = definition.Category;
            dto.description           = definition.Description;
            dto.name                  = definition.Name;
            dto.version               = definition.Version;
            dto.resource              = definition.ResourceName;
            dto.deploymentId          = definition.DeploymentId;
            dto.diagram               = definition.DiagramResourceName;
            dto.suspended             = definition.Suspended;
            dto.tenantId              = definition.TenantId;
            dto.versionTag            = definition.VersionTag;
            dto.historyTimeToLive     = definition.HistoryTimeToLive;
            dto.isStartableInTasklist = definition.StartableInTasklist;
            return(dto);
        }
Beispiel #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateEventSubscription()
        public virtual void testMigrateEventSubscription()
        {
            // given
            ProcessDefinition sourceProcessDefinition   = testHelper.deployAndGetDefinition(MessageReceiveModels.MESSAGE_START_PROCESS);
            string            sourceProcessDefinitionId = sourceProcessDefinition.Id;

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinitionId, sourceProcessDefinitionId).mapEqualActivities().build();

            ProcessInstance   processInstance   = runtimeService.startProcessInstanceById(sourceProcessDefinitionId);
            EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().activityId("startEvent").eventName(MessageReceiveModels.MESSAGE_NAME).singleResult();

            // when
            runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance.Id).execute();

            // then
            assertEventSubscriptionMigrated(eventSubscription, "startEvent", MessageReceiveModels.MESSAGE_NAME);

            testHelper.completeTask("userTask");
            testHelper.assertProcessEnded(processInstance.Id);
        }
Beispiel #18
0
        public virtual ProcessDefinition build()
        {
            ProcessDefinition mockDefinition = mock(typeof(ProcessDefinition));

            when(mockDefinition.Id).thenReturn(id_Renamed);
            when(mockDefinition.Category).thenReturn(category_Renamed);
            when(mockDefinition.Name).thenReturn(name_Renamed);
            when(mockDefinition.Key).thenReturn(key_Renamed);
            when(mockDefinition.Description).thenReturn(description_Renamed);
            when(mockDefinition.Version).thenReturn(version_Renamed);
            when(mockDefinition.ResourceName).thenReturn(resource_Renamed);
            when(mockDefinition.DeploymentId).thenReturn(deploymentId_Renamed);
            when(mockDefinition.DiagramResourceName).thenReturn(diagram_Renamed);
            when(mockDefinition.Suspended).thenReturn(suspended_Renamed);
            when(mockDefinition.hasStartFormKey()).thenReturn(startFormKey_Renamed);
            when(mockDefinition.TenantId).thenReturn(tenantId_Renamed);
            when(mockDefinition.VersionTag).thenReturn(versionTag_Renamed);
            when(mockDefinition.StartableInTasklist).thenReturn(isStartableInTasklist_Renamed);
            return(mockDefinition);
        }
Beispiel #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void suspendProcessDefinitionByIdIncludeInstancesFromAllTenants()
        public virtual void suspendProcessDefinitionByIdIncludeInstancesFromAllTenants()
        {
            // given active process instances with tenant id of process definition without tenant id
            engineRule.RuntimeService.createProcessInstanceByKey(PROCESS_DEFINITION_KEY).processDefinitionWithoutTenantId().execute();

            ProcessDefinition processDefinition = engineRule.RepositoryService.createProcessDefinitionQuery().withoutTenantId().singleResult();

            ProcessInstanceQuery query = engineRule.RuntimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.Id);

            assertThat(query.active().count(), @is(1L));
            assertThat(query.active().tenantIdIn(TENANT_ONE).count(), @is(1L));
            assertThat(query.suspended().count(), @is(0L));

            // suspend all instances of process definition
            engineRule.RepositoryService.updateProcessDefinitionSuspensionState().byProcessDefinitionId(processDefinition.Id).includeProcessInstances(true).suspend();

            assertThat(query.active().count(), @is(0L));
            assertThat(query.suspended().count(), @is(1L));
            assertThat(query.suspended().tenantIdIn(TENANT_ONE).count(), @is(1L));
        }
Beispiel #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateGatewayAddSignalEvent()
        public virtual void testMigrateGatewayAddSignalEvent()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.SIGNAL_EVENT_BASED_GW_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.SIGNAL_EVENT_BASED_GW_PROCESS).flowNodeBuilder("eventBasedGateway").intermediateCatchEvent("newSignalCatch").signal("new" + EventBasedGatewayModels.SIGNAL_NAME).userTask("afterNewSignalCatch").endEvent().done());

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("signalCatch", "signalCatch").build();

            // when
            ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);

            // then
            testHelper.assertEventSubscriptionCreated("newSignalCatch", "new" + EventBasedGatewayModels.SIGNAL_NAME);
            testHelper.assertEventSubscriptionMigrated("signalCatch", "signalCatch", EventBasedGatewayModels.SIGNAL_NAME);

            rule.RuntimeService.signalEventReceived("new" + EventBasedGatewayModels.SIGNAL_NAME);

            testHelper.completeTask("afterNewSignalCatch");
            testHelper.assertProcessEnded(processInstance.Id);
        }
Beispiel #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCase2AssertActivityInstance()
        public virtual void testCase2AssertActivityInstance()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();

            ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            testHelper.completeTask("userTask1");
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // when throwing compensation
            testHelper.completeTask("userTask2");

            // then the activity instance tree is correct
            ActivityInstance activityInstance = rule.RuntimeService.getActivityInstance(processInstance.Id);

            assertThat(activityInstance).hasStructure(describeActivityInstanceTree(targetProcessDefinition.Id).activity("compensationEvent").beginScope("subProcess").activity("compensationHandler").done());
        }
Beispiel #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void cannotMigrateInstanceWithoutTenantIdToDifferentTenant()
        public virtual void cannotMigrateInstanceWithoutTenantIdToDifferentTenant()
        {
            // given
            ProcessDefinition sourceDefinition = defaultTestRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetDefinition = defaultTestRule.deployForTenantAndGetDefinition(TENANT_ONE, ProcessModels.ONE_TASK_PROCESS);

            ProcessInstance processInstance = defaultEngineRule.RuntimeService.startProcessInstanceById(sourceDefinition.Id);
            MigrationPlan   migrationPlan   = defaultEngineRule.RuntimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapEqualActivities().build();

            Batch batch = defaultEngineRule.RuntimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).executeAsync();

            batchHelper.executeSeedJob(batch);

            // when
            batchHelper.executeJobs(batch);

            // then
            Job migrationJob = batchHelper.getExecutionJobs(batch)[0];

            Assert.assertThat(migrationJob.ExceptionMessage, CoreMatchers.containsString("Cannot migrate process instance '" + processInstance.Id + "' without tenant to a process definition with a tenant ('tenant1')"));
        }
Beispiel #23
0
        /// <summary>
        /// Ensures that suspending a process definition and its process instances will also increase the revision of the executions
        /// such that concurrent updates fail with an OptimisticLockingException.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testCompetingSuspension()
        public virtual void testCompetingSuspension()
        {
            ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("CompetingSuspensionProcess").singleResult();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.Id);
            Execution       execution       = runtimeService.createExecutionQuery().processInstanceId(processInstance.Id).activityId("wait1").singleResult();

            SuspendProcessDefinitionThread suspensionThread = new SuspendProcessDefinitionThread(this, processDefinition.Id);

            suspensionThread.startAndWaitUntilControlIsReturned();

            SignalThread signalExecutionThread = new SignalThread(this, execution.Id);

            signalExecutionThread.startAndWaitUntilControlIsReturned();

            suspensionThread.proceedAndWaitTillDone();
            assertNull(suspensionThread.exception);

            signalExecutionThread.proceedAndWaitTillDone();
            assertNotNull(signalExecutionThread.exception);
        }
Beispiel #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateGatewayWithTimerEventChangeId()
        public virtual void testMigrateGatewayWithTimerEventChangeId()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS).changeElementId("timerCatch", "newTimerCatch"));

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("timerCatch", "newTimerCatch").build();

            // when
            ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);

            // then
            testHelper.assertIntermediateTimerJobMigrated("timerCatch", "newTimerCatch");

            Job timerJob = testHelper.snapshotAfterMigration.Jobs[0];

            rule.ManagementService.executeJob(timerJob.Id);

            testHelper.completeTask("afterTimerCatch");
            testHelper.assertProcessEnded(processInstance.Id);
        }
Beispiel #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateGatewayRemoveIncidentOnMigration()
        public virtual void testMigrateGatewayRemoveIncidentOnMigration()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("eventBasedGateway", "eventBasedGateway").build();

            ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(migrationPlan.SourceProcessDefinitionId);

            Job timerJob = rule.ManagementService.createJobQuery().singleResult();

            // create an incident
            rule.ManagementService.setJobRetries(timerJob.Id, 0);

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then the incident is gone
            Assert.assertEquals(0, rule.RuntimeService.createIncidentQuery().count());
        }
Beispiel #26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateGatewayWithIncident()
        public virtual void testMigrateGatewayWithIncident()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("timerCatch", "timerCatch").build();

            ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(migrationPlan.SourceProcessDefinitionId);

            Job timerJob = rule.ManagementService.createJobQuery().singleResult();

            // create an incident
            rule.ManagementService.setJobRetries(timerJob.Id, 0);
            Incident incidentBeforeMigration = rule.RuntimeService.createIncidentQuery().singleResult();

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then job and incident still exist
            testHelper.assertIntermediateTimerJobMigrated("timerCatch", "timerCatch");

            Job jobAfterMigration = testHelper.snapshotAfterMigration.Jobs[0];

            Incident incidentAfterMigration = rule.RuntimeService.createIncidentQuery().singleResult();

            assertNotNull(incidentAfterMigration);

            assertEquals(incidentBeforeMigration.Id, incidentAfterMigration.Id);
            assertEquals(jobAfterMigration.Id, incidentAfterMigration.Configuration);

            assertEquals("timerCatch", incidentAfterMigration.ActivityId);
            assertEquals(targetProcessDefinition.Id, incidentAfterMigration.ProcessDefinitionId);

            // and it is possible to complete the process
            rule.ManagementService.executeJob(jobAfterMigration.Id);

            testHelper.completeTask("afterTimerCatch");
            testHelper.assertProcessEnded(processInstance.Id);
        }
Beispiel #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCanRemoveEventScopeWithVariables()
        public virtual void testCanRemoveEventScopeWithVariables()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();

            ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            Execution subProcessExecution = rule.RuntimeService.createExecutionQuery().activityId("userTask1").singleResult();

            rule.RuntimeService.setVariableLocal(subProcessExecution.Id, "foo", "bar");

            testHelper.completeTask("userTask1");

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then
            Assert.assertEquals(0, rule.RuntimeService.createVariableInstanceQuery().count());
        }
Beispiel #28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateGatewayAddTimerEvent()
        public virtual void testMigrateGatewayAddTimerEvent()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS).flowNodeBuilder("eventBasedGateway").intermediateCatchEvent("newTimerCatch").timerWithDuration("PT50M").userTask("afterNewTimerCatch").endEvent().done());

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("timerCatch", "timerCatch").build();

            // when
            ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);

            // then
            testHelper.assertIntermediateTimerJobCreated("newTimerCatch");
            testHelper.assertIntermediateTimerJobMigrated("timerCatch", "timerCatch");

            Job newTimerJob = rule.ManagementService.createJobQuery().activityId("newTimerCatch").singleResult();

            rule.ManagementService.executeJob(newTimerJob.Id);

            testHelper.completeTask("afterNewTimerCatch");
            testHelper.assertProcessEnded(processInstance.Id);
        }
Beispiel #29
0
        /// <summary>
        /// The guarantee given by the API is: Compensation can be triggered in the scope that it could be triggered before
        ///   migration. Thus, it should not be possible to trigger compensation from the new sub process instance but only from the
        ///   parent scope, i.e. the process definition instance
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCase1CannotTriggerCompensationInNewScope()
        public virtual void testCase1CannotTriggerCompensationInNewScope()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.COMPENSATION_TWO_TASKS_SUBPROCESS_MODEL).endEventBuilder("subProcessEnd").compensateEventDefinition().waitForCompletion(true).compensateEventDefinitionDone().done());

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();

            ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            testHelper.completeTask("userTask1");

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then compensation is only caught outside of the subProcess
            testHelper.completeTask("userTask2");

            ActivityInstance activityInstance = rule.RuntimeService.getActivityInstance(processInstance.Id);

            assertThat(activityInstance).hasStructure(describeActivityInstanceTree(targetProcessDefinition.Id).activity("compensationEvent").beginScope("subProcess").activity("compensationHandler").done());
        }
Beispiel #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void cannotMigrateInstanceBetweenDifferentTenants()
        public virtual void cannotMigrateInstanceBetweenDifferentTenants()
        {
            // given
            ProcessDefinition sharedDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition tenantDefinition = testHelper.deployForTenantAndGetDefinition(TENANT_TWO, ProcessModels.ONE_TASK_PROCESS);

            ProcessInstance processInstance = startInstanceForTenant(sharedDefinition, TENANT_ONE);
            MigrationPlan   migrationPlan   = engineRule.RuntimeService.createMigrationPlan(sharedDefinition.Id, tenantDefinition.Id).mapEqualActivities().build();

            // when
            try
            {
                engineRule.RuntimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).execute();
                Assert.fail("exception expected");
            }
            catch (ProcessEngineException e)
            {
                Assert.assertThat(e.Message, CoreMatchers.containsString("Cannot migrate process instance '" + processInstance.Id + "' " + "to a process definition of a different tenant ('tenant1' != 'tenant2')"));
            }

            // then
            Assert.assertNotNull(migrationPlan);
        }