Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSetJobsRetryAsyncWithEmptyProcessQuery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testSetJobsRetryAsyncWithEmptyProcessQuery()
        {
            //expect
            thrown.expect(typeof(ProcessEngineException));

            //given
            ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().suspended();

            //when
            managementService.setJobRetriesAsync(null, query, RETRIES);
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void correlateStartMessageWithoutTenantId()
        public virtual void correlateStartMessageWithoutTenantId()
        {
            testRule.deploy(MESSAGE_START_PROCESS);
            testRule.deployForTenant(TENANT_ONE, MESSAGE_START_PROCESS);

            engineRule.RuntimeService.createMessageCorrelation("message").withoutTenantId().correlateStartMessage();

            ProcessInstanceQuery query = engineRule.RuntimeService.createProcessInstanceQuery();

            assertThat(query.count(), @is(1L));
            assertThat(query.singleResult().TenantId, @is(nullValue()));
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void sendSignalToStartEventForNonTenant()
        public virtual void sendSignalToStartEventForNonTenant()
        {
            testRule.deploy(SIGNAL_START_PROCESS);
            testRule.deployForTenant(TENANT_ONE, SIGNAL_START_PROCESS);

            engineRule.RuntimeService.createSignalEvent("signal").withoutTenantId().send();

            ProcessInstanceQuery query = engineRule.RuntimeService.createProcessInstanceQuery();

            assertThat(query.count(), @is(1L));
            assertThat(query.singleResult().TenantId, @is(nullValue()));
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void sendSignalToStartEventsForMultipleTenants()
        public virtual void sendSignalToStartEventsForMultipleTenants()
        {
            testRule.deployForTenant(TENANT_ONE, SIGNAL_START_PROCESS);
            testRule.deployForTenant(TENANT_TWO, SIGNAL_START_PROCESS);

            engineRule.RuntimeService.createSignalEvent("signal").send();

            ProcessInstanceQuery query = engineRule.RuntimeService.createProcessInstanceQuery();

            assertThat(query.tenantIdIn(TENANT_ONE).count(), @is(1L));
            assertThat(query.tenantIdIn(TENANT_TWO).count(), @is(1L));
        }
Пример #5
0
        public virtual void testDeleteProcessInstancesAsyncWithInvalidQueryParameter()
        {
            // given
            startTestProcesses(2);
            ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processInstanceBusinessKey("invalid");

            thrown.expect(typeof(ProcessEngineException));
            thrown.expectMessage("processInstanceIds is empty");

            // when
            runtimeService.deleteProcessInstancesAsync(null, query, TESTING_INSTANCE_DELETE);
        }
Пример #6
0
 private IList <ProcessInstance> executePaginatedQuery(ProcessInstanceQuery query, int?firstResult, int?maxResults)
 {
     if (firstResult == null)
     {
         firstResult = 0;
     }
     if (maxResults == null)
     {
         maxResults = int.MaxValue;
     }
     return(query.listPage(firstResult, maxResults));
 }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void correlateMessagesToStartEventsForMultipleTenants()
        public virtual void correlateMessagesToStartEventsForMultipleTenants()
        {
            testRule.deployForTenant(TENANT_ONE, MESSAGE_START_PROCESS);
            testRule.deployForTenant(TENANT_TWO, MESSAGE_START_PROCESS);

            engineRule.RuntimeService.createMessageCorrelation("message").correlateAll();

            ProcessInstanceQuery query = engineRule.RuntimeService.createProcessInstanceQuery();

            assertThat(query.tenantIdIn(TENANT_ONE).count(), @is(1L));
            assertThat(query.tenantIdIn(TENANT_TWO).count(), @is(1L));
        }
Пример #8
0
        public virtual CountResultDto queryProcessInstancesCount(ProcessInstanceQueryDto queryDto)
        {
            ProcessEngine engine = ProcessEngine;

            queryDto.ObjectMapper = ObjectMapper;
            ProcessInstanceQuery query = queryDto.toQuery(engine);

            long           count  = query.count();
            CountResultDto result = new CountResultDto();

            result.Count = count;

            return(result);
        }
Пример #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void suspendProcessDefinitionIncludeInstancesForNonTenant()
        public virtual void suspendProcessDefinitionIncludeInstancesForNonTenant()
        {
            // given activated process instances
            ProcessInstanceQuery query = engineRule.RuntimeService.createProcessInstanceQuery();

            assertThat(query.active().count(), @is(3L));
            assertThat(query.suspended().count(), @is(0L));

            engineRule.RepositoryService.updateProcessDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionWithoutTenantId().includeProcessInstances(true).suspend();

            assertThat(query.active().count(), @is(2L));
            assertThat(query.suspended().count(), @is(1L));
            assertThat(query.suspended().withoutTenantId().count(), @is(1L));
        }
Пример #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSetJobsRetryAsyncWithProcessQuery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testSetJobsRetryAsyncWithProcessQuery()
        {
            //given
            ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();

            //when
            Batch batch = managementService.setJobRetriesAsync(null, query, RETRIES);

            executeSeedJob(batch);
            IList <Exception> exceptions = executeBatchJobs(batch);

            // then
            assertThat(exceptions.Count, @is(0));
            assertRetries(ids, RETRIES);
            assertHistoricBatchExists(testRule);
        }
Пример #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSetJobsRetryAsyncWithProcessQueryAndList() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testSetJobsRetryAsyncWithProcessQueryAndList()
        {
            //given
            IList <string>       extraPi = startTestProcesses(1);
            ProcessInstanceQuery query   = runtimeService.createProcessInstanceQuery().processInstanceId(extraPi[0]);

            //when
            Batch batch = managementService.setJobRetriesAsync(processInstanceIds, query, RETRIES);

            executeSeedJob(batch);
            IList <Exception> exceptions = executeBatchJobs(batch);

            // then
            assertThat(exceptions.Count, @is(0));
            assertRetries(AllJobIds, RETRIES);
            assertHistoricBatchExists(testRule);
        }
Пример #12
0
        public virtual void testDeleteProcessInstancesAsyncWithQueryOnly()
        {
            // given
            IList <string>       processIds           = startTestProcesses(2);
            ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(new HashSet <string>(processIds));

            // when
            Batch batch = runtimeService.deleteProcessInstancesAsync(processInstanceQuery, TESTING_INSTANCE_DELETE);

            executeSeedJob(batch);
            executeBatchJobs(batch);

            // then
            assertHistoricTaskDeletionPresent(processIds, TESTING_INSTANCE_DELETE, testRule);
            assertHistoricBatchExists(testRule);
            assertProcessInstancesAreDeleted();
        }
Пример #13
0
        public virtual void testDeleteProcessInstancesAsyncWithQueryWithoutDeleteReason()
        {
            // given
            IList <string>       processIds           = startTestProcesses(2);
            ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(new HashSet <string>(processIds));

            // when
            Batch batch = runtimeService.deleteProcessInstancesAsync(null, processInstanceQuery, null);

            executeSeedJob(batch);
            executeBatchJobs(batch);

            // then
            assertHistoricTaskDeletionPresent(processIds, "deleted", testRule);
            assertHistoricBatchExists(testRule);
            assertProcessInstancesAreDeleted();
        }
Пример #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testOverlappingProcessInstanceIdsAndQuery()
        public virtual void testOverlappingProcessInstanceIdsAndQuery()
        {
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapEqualActivities().build();

            ProcessInstance processInstance1 = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);
            ProcessInstance processInstance2 = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.Id);
            ProcessInstanceQuery targetProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(targetProcessDefinition.Id);

            assertEquals(0, targetProcessInstanceQuery.count());

            runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance1.Id, processInstance2.Id)).processInstanceQuery(sourceProcessInstanceQuery).execute();

            assertEquals(2, targetProcessInstanceQuery.count());
        }
Пример #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testEmptyProcessInstanceQuery()
        public virtual void testEmptyProcessInstanceQuery()
        {
            ProcessDefinition testProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            MigrationPlan     migrationPlan         = runtimeService.createMigrationPlan(testProcessDefinition.Id, testProcessDefinition.Id).mapEqualActivities().build();

            ProcessInstanceQuery emptyProcessInstanceQuery = runtimeService.createProcessInstanceQuery();

            assertEquals(0, emptyProcessInstanceQuery.count());

            try
            {
                runtimeService.newMigration(migrationPlan).processInstanceQuery(emptyProcessInstanceQuery).execute();
                fail("Should not be able to migrate");
            }
            catch (ProcessEngineException e)
            {
                assertThat(e.Message, CoreMatchers.containsString("process instance ids is empty"));
            }
        }
Пример #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void suspendAndActivateProcessDefinitionsIncludeInstancesForAllTenants()
        public virtual void suspendAndActivateProcessDefinitionsIncludeInstancesForAllTenants()
        {
            // given activated process instances
            ProcessInstanceQuery query = engineRule.RuntimeService.createProcessInstanceQuery();

            assertThat(query.active().count(), @is(3L));
            assertThat(query.suspended().count(), @is(0L));

            // first suspend
            engineRule.RepositoryService.updateProcessDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).includeProcessInstances(true).suspend();

            assertThat(query.active().count(), @is(0L));
            assertThat(query.suspended().count(), @is(3L));

            // then activate
            engineRule.RepositoryService.updateProcessDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).includeProcessInstances(true).activate();

            assertThat(query.active().count(), @is(3L));
            assertThat(query.suspended().count(), @is(0L));
        }
Пример #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void timerStartEventWithTimerCycle()
        public virtual void timerStartEventWithTimerCycle()
        {
            testRule.deployForTenant(TENANT_ONE, Bpmn.createExecutableProcess().startEvent().timerWithCycle("R2/PT1M").userTask().endEvent().done());

            // execute first timer cycle
            Job job = managementService.createJobQuery().singleResult();

            assertThat(job.TenantId, @is(TENANT_ONE));
            managementService.executeJob(job.Id);

            // execute second timer cycle
            job = managementService.createJobQuery().singleResult();
            assertThat(job.TenantId, @is(TENANT_ONE));
            managementService.executeJob(job.Id);

            ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();

            assertThat(query.tenantIdIn(TENANT_ONE).count(), @is(2L));
            assertThat(query.withoutTenantId().count(), @is(0L));
        }
Пример #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUpdateRetriesByProcessInstanceQuery()
        public virtual void shouldUpdateRetriesByProcessInstanceQuery()
        {
            // given
            ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();

            // when
            Batch batch = externalTaskService.updateRetries().processInstanceQuery(processInstanceQuery).setAsync(5);

            executeSeedAndBatchJobs(batch);

            // then
            IList <ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();

            assertEquals(6, tasks.Count);

            foreach (ExternalTask task in tasks)
            {
                assertEquals(5, (int)task.Retries);
            }
        }
Пример #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testWithQuery()
        public virtual void testWithQuery()
        {
            //given
            ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(new HashSet <string>(Arrays.asList(processInstance.Id, processInstance2.Id)));

            authRule.init(scenario).withUser("userId").bindResource("processInstance1", processInstance.Id).bindResource("processInstance2", processInstance2.Id).bindResource("Process_2", sourceDefinition2.Key).start();

            // when

            batch = runtimeService.deleteProcessInstancesAsync(null, processInstanceQuery, TEST_REASON);
            executeSeedAndBatchJobs();

            // then
            if (authRule.assertScenario(scenario))
            {
                if (testHelper.HistoryLevelFull)
                {
                    assertThat(engineRule.HistoryService.createUserOperationLogQuery().entityType(EntityTypes.PROCESS_INSTANCE).count(), @is(BATCH_OPERATIONS));
                }
            }
        }
Пример #20
0
        public async Task ProcessInstances_分页获取流程实例列表(int pageSize)
        {
            var ex = await Record.ExceptionAsync(async() =>
            {
                int offset = 1;
                Resources <ProcessInstance> list = null;
                while (true)
                {
                    ProcessInstanceQuery query = new ProcessInstanceQuery
                    {
                        TenantId = ctx.TenantId,
                        Pageable = new Pageable
                        {
                            PageNo   = offset,
                            PageSize = pageSize,
                            Sort     = new Sort(new Sort.Order[]
                            {
                                new Sort.Order
                                {
                                    Property  = "name",
                                    Direction = Sort.Direction.ASC
                                }
                            })
                        }
                    };

                    list = await client.ProcessInstances(query).ConfigureAwait(false);
                    if (list.List.Count() < pageSize)
                    {
                        break;
                    }

                    offset = offset + 1;
                }

                Assert.True(offset == 1 && list.TotalCount <= 0 ? true : list.TotalCount / pageSize + 1 == offset);
            }).ConfigureAwait(false);

            Assert.Null(ex);
        }
Пример #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testTimerRecalculationBasedOnProcessVariable()
        public virtual void testTimerRecalculationBasedOnProcessVariable()
        {
            // given
            IDictionary <string, object> variables = new Dictionary <string, object>();

            variables["timerExpression"] = "PT10S";
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("TimerRecalculationProcess", variables);

            ProcessInstanceQuery instancesQuery = runtimeService.createProcessInstanceQuery().processInstanceId(instance.Id);
            JobQuery             jobQuery       = managementService.createJobQuery();

            assertEquals(1, instancesQuery.count());
            assertEquals(1, jobQuery.count());

            Job      job        = jobQuery.singleResult();
            DateTime oldDueDate = job.Duedate;

            // when
            runtimeService.setVariable(instance.Id, "timerExpression", "PT1S");
            managementService.recalculateJobDuedate(job.Id, true);

            // then
            assertEquals(1, jobQuery.count());
            Job jobRecalculated = jobQuery.singleResult();

            assertNotEquals(oldDueDate, jobRecalculated.Duedate);

            DateTime calendar = new DateTime();

            calendar = new DateTime(jobRecalculated.CreateTime);
            calendar.AddSeconds(1);
            DateTime expectedDate = calendar;

            assertEquals(expectedDate, jobRecalculated.Duedate);

            waitForJobExecutorToProcessAllJobs();

            assertEquals(0, instancesQuery.count());
        }
Пример #22
0
        public virtual void testQueryByProcessDefinitionWithoutTenantId_VaryingProcessInstanceTenantId()
        {
            // given
            StaticTenantIdTestProvider tenantIdProvider = new StaticTenantIdTestProvider(null);

            processEngineConfiguration.TenantIdProvider = tenantIdProvider;

            tenantIdProvider.TenantIdProvider = "anotherTenantId";

            runtimeService.createProcessInstanceByKey("testProcess").processDefinitionWithoutTenantId().execute();

            // when
            ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processDefinitionWithoutTenantId();

            // then
            assertThat(query.count(), @is(2L));
            assertThat(query.withoutTenantId().count(), @is(1L));
            assertThat(query.tenantIdIn("anotherTenantId").count(), @is(1L));

            // cleanup
            processEngineConfiguration.TenantIdProvider = null;
        }
Пример #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testProcessInstanceQueryOfWrongProcessDefinition()
        public virtual void testProcessInstanceQueryOfWrongProcessDefinition()
        {
            ProcessDefinition testProcessDefinition  = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition wrongProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);

            runtimeService.startProcessInstanceById(wrongProcessDefinition.Id);

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

            ProcessInstanceQuery wrongProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(wrongProcessDefinition.Id);

            assertEquals(1, wrongProcessInstanceQuery.count());

            try
            {
                runtimeService.newMigration(migrationPlan).processInstanceQuery(wrongProcessInstanceQuery).execute();
                fail("Should not be able to migrate");
            }
            catch (ProcessEngineException e)
            {
                assertThat(e.Message, CoreMatchers.StartsWith("ENGINE-23002"));
            }
        }
Пример #24
0
        public virtual BatchDto deleteAsync(DeleteProcessInstancesDto dto)
        {
            RuntimeService runtimeService = ProcessEngine.RuntimeService;

            ProcessInstanceQuery processInstanceQuery = null;

            if (dto.ProcessInstanceQuery != null)
            {
                processInstanceQuery = dto.ProcessInstanceQuery.toQuery(ProcessEngine);
            }

            Batch batch = null;

            try
            {
                batch = runtimeService.deleteProcessInstancesAsync(dto.ProcessInstanceIds, processInstanceQuery, dto.DeleteReason, dto.SkipCustomListeners, dto.SkipSubprocesses);
                return(BatchDto.fromBatch(batch));
            }
            catch (BadUserRequestException e)
            {
                throw new InvalidRequestException(Status.BAD_REQUEST, e.Message);
            }
        }
Пример #25
0
        /// <summary>
        /// 读取分页记录
        /// </summary>
        /// <param name="runtimeService">运行时仓储服务</param>
        /// <param name="pageableRepositoryService">分页仓储服务</param>
        /// <param name="qo">查询对象</param>
        /// <returns></returns>
        public IPage <ProcessInstance> LoadPage(IRuntimeService runtimeService,
                                                PageableProcessInstanceRepositoryService pageableRepositoryService, ProcessInstanceQuery qo)
        {
            ProcessInstanceQueryImpl query = runtimeService.CreateProcessInstanceQuery() as ProcessInstanceQueryImpl;

            FastCopy.Copy <ProcessInstanceQuery, ProcessInstanceQueryImpl>(qo, query);
            query.OnlyProcessInstances = true;

            pageableRepositoryService.SortApplier.ApplySort(query, qo.Pageable);

            IPage <ProcessInstance> defs = pageableRepositoryService.PageRetriever.LoadPage(runtimeService as ServiceImpl, query, qo.Pageable, pageableRepositoryService.ProcessDefinitionConverter, (q, firstResult, pageSize) =>
            {
                return(new GetProcessInstancesCmd(q, firstResult, pageSize));
            });

            return(defs);
        }
 public List <ProcessInstanceInfo> QueryProcessInstances(ProcessInstanceQuery processInstanceQuery)
 {
     return(CamundaClient.ProcessInstances.Query(processInstanceQuery).List().Result);
 }
Пример #27
0
 public SetJobsRetriesByProcessBatchCmd(IList <string> processInstanceIds, ProcessInstanceQuery query, int retries)
 {
     this.processInstanceIds = processInstanceIds;
     this.query   = query;
     this.retries = retries;
 }
Пример #28
0
 public virtual Batch setJobRetriesAsync(IList <string> processInstanceIds, ProcessInstanceQuery query, int retries)
 {
     return(commandExecutor.execute(new SetJobsRetriesByProcessBatchCmd(processInstanceIds, query, retries)));
 }
Пример #29
0
 public virtual Batch deleteProcessInstancesAsync(IList <string> processInstanceIds, ProcessInstanceQuery processInstanceQuery, string deleteReason, bool skipCustomListeners, bool skipSubprocesses)
 {
     return(commandExecutor.execute(new DeleteProcessInstanceBatchCmd(processInstanceIds, processInstanceQuery, deleteReason, skipCustomListeners, skipSubprocesses)));
 }
Пример #30
0
 public virtual Batch deleteProcessInstancesAsync(IList <string> processInstanceIds, ProcessInstanceQuery processInstanceQuery, string deleteReason, bool skipCustomListeners)
 {
     return(deleteProcessInstancesAsync(processInstanceIds, processInstanceQuery, deleteReason, skipCustomListeners, false));
 }