Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateHistoricIncidentAddScope()
        public virtual void testMigrateHistoricIncidentAddScope()
        {
            // given
            ProcessDefinition sourceProcess = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
            ProcessDefinition targetProcess = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_SUBPROCESS_USER_TASK_PROCESS);

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcess.Id, targetProcess.Id).mapActivities("userTask", "userTask").build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcess.Id);

            Job job = managementService.createJobQuery().singleResult();

            managementService.setJobRetries(job.Id, 0);

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

            // then
            ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.Id);

            HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult();

            Assert.assertNotNull(historicIncident);
            Assert.assertEquals(activityInstance.getTransitionInstances("userTask")[0].ExecutionId, historicIncident.ExecutionId);
        }
Beispiel #2
0
        protected internal virtual void executeJob()
        {
            Job job = managementService.createJobQuery().singleResult();

            assertNotNull(job);
            managementService.executeJob(job.Id);
        }
Beispiel #3
0
            public void execute(ProcessEngine engine, string scenarioName)
            {
                ProcessInstance procInstance = engine.RuntimeService.startProcessInstanceByKey(PROCESS_DEF_KEY, scenarioName);
                Job             job          = engine.ManagementService.createJobQuery().processInstanceId(procInstance.Id).singleResult();

                engine.ManagementService.executeJob(job.Id);
            }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDontWriteDuplicateLogOnBatchMigrationJobExecution()
        public virtual void testDontWriteDuplicateLogOnBatchMigrationJobExecution()
        {
            // given
            ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceDefinition.Id);

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

            batch = runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).executeAsync();
            Job seedJob = managementService.createJobQuery().singleResult();

            managementService.executeJob(seedJob.Id);

            Job migrationJob = managementService.createJobQuery().jobDefinitionId(batch.BatchJobDefinitionId).singleResult();

            // when
            managementService.executeJob(migrationJob.Id);

            // then
            assertEquals(9, userOperationLogQuery().count());
            assertEquals(2, userOperationLogQuery().operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE).entityType(EntityTypes.DEPLOYMENT).count());
            assertEquals(1, userOperationLogQuery().operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE).entityType(EntityTypes.PROCESS_INSTANCE).count());
            assertEquals(3, userOperationLogQuery().operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_MIGRATE).entityType(EntityTypes.PROCESS_INSTANCE).count());
        }
Beispiel #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testThrownAnErrorInEventSubprocessInSubprocess()
        public virtual void testThrownAnErrorInEventSubprocessInSubprocess()
        {
            runtimeService.startProcessInstanceByKey("eventSubProcess");

            Task taskBefore = taskService.createTaskQuery().singleResult();

            assertNotNull(taskBefore);
            assertEquals("inside subprocess", taskBefore.Name);

            Job job = managementService.createJobQuery().singleResult();

            assertNotNull(job);

            //when job is executed task is created
            managementService.executeJob(job.Id);

            Task taskAfter = taskService.createTaskQuery().singleResult();

            assertNotNull(taskAfter);
            assertEquals("after catch", taskAfter.Name);

            Job jobAfter = managementService.createJobQuery().singleResult();

            assertNull(jobAfter);
        }
Beispiel #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testExclusiveJobs()
        public virtual void testExclusiveJobs()
        {
            testRule.deploy(Bpmn.createExecutableProcess("testProcess").startEvent().serviceTask("task1").camundaExpression("${true}").camundaAsyncBefore().serviceTask("task2").camundaExpression("${true}").camundaAsyncBefore().endEvent().done());

            JobDefinition jobDefinition = managementService.createJobDefinitionQuery().activityIdIn("task2").singleResult();

            // given that the second task is suspended
            managementService.suspendJobDefinitionById(jobDefinition.Id);

            // if I start a process instance
            runtimeService.startProcessInstanceByKey("testProcess");

            testRule.waitForJobExecutorToProcessAllJobs(10000);

            // then the second task is not executed
            assertEquals(1, runtimeService.createProcessInstanceQuery().count());
            // there is a suspended job instance
            Job job = managementService.createJobQuery().singleResult();

            assertEquals(job.JobDefinitionId, jobDefinition.Id);
            assertTrue(job.Suspended);

            // if I unsuspend the job definition, the job is executed:
            managementService.activateJobDefinitionById(jobDefinition.Id, true);

            testRule.waitForJobExecutorToProcessAllJobs(10000);

            assertEquals(0, runtimeService.createProcessInstanceQuery().count());
        }
Beispiel #7
0
            public void execute(ProcessEngine engine, string scenarioName)
            {
                ProcessInstance instance = engine.RuntimeService.startProcessInstanceByKey("NonInterruptingTimerBoundaryEventScenario", scenarioName);

                Job job = engine.ManagementService.createJobQuery().processInstanceId(instance.Id).singleResult();

                engine.ManagementService.executeJob(job.Id);
            }
Beispiel #8
0
        public virtual void testSuspensionState()
        {
            // given
            Job job = rule.ManagementService.createJobQuery().jobId(rule.BuisnessKey).singleResult();

            // then
            Assert.assertNotNull(job);
            Assert.assertFalse(job.Suspended);
        }
Beispiel #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void seedJobShouldHaveDefaultPriority()
        public virtual void seedJobShouldHaveDefaultPriority()
        {
            // when
            Batch batch = helper.migrateProcessInstancesAsync(1);

            // then
            Job seedJob = helper.getSeedJob(batch);

            assertEquals(DefaultJobPriorityProvider.DEFAULT_PRIORITY, seedJob.Priority);
        }
Beispiel #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testPriorityOnInstantiationAtActivity()
        public virtual void testPriorityOnInstantiationAtActivity()
        {
            // when
            processInstance = runtimeService.createProcessInstanceByKey("serviceTaskProcess").startBeforeActivity("serviceTask").execute();

            // then
            Job job = managementService.createJobQuery().singleResult();

            Assert.assertEquals(PriorityBean.PRIORITY, job.Priority);
        }
Beispiel #11
0
        public virtual void testDefaultPriorityWhenBeanMisses()
        {
            // creating a job with a priority that can't be resolved does not fail entirely but uses a default priority
            runtimeService.createProcessInstanceByKey("jobPrioExpressionProcess").startBeforeActivity("task1").execute();

            // then
            Job job = managementService.createJobQuery().singleResult();

            assertEquals(EXPECTED_DEFAULT_PRIORITY_ON_RESOLUTION_FAILURE, job.Priority);
        }
Beispiel #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testPriorityOnProcessStart()
        public virtual void testPriorityOnProcessStart()
        {
            // given
            processInstance = runtimeService.startProcessInstanceByKey("serviceTaskProcess");

            Job job = managementService.createJobQuery().singleResult();

            // then
            Assert.assertEquals(PriorityBean.PRIORITY, job.Priority);
        }
Beispiel #13
0
        public virtual void testVariableValueExpressionPrioritization()
        {
            // when
            runtimeService.createProcessInstanceByKey("jobPrioExpressionProcess").startBeforeActivity("task1").setVariable("priority", 22).execute();

            // then
            Job job = managementService.createJobQuery().singleResult();

            assertNotNull(job);
            assertEquals(22, job.Priority);
        }
Beispiel #14
0
        public virtual void testConcurrentLocalVariablesAreAccessible()
        {
            // when
            runtimeService.createProcessInstanceByKey("jobPrioExpressionProcess").startBeforeActivity("task2").startBeforeActivity("task1").setVariableLocal("priority", 14).execute();

            // then
            Job job = managementService.createJobQuery().activityId("task1").singleResult();

            assertNotNull(job);
            assertEquals(14, job.Priority);
        }
Beispiel #15
0
            public virtual void trigger(string processInstanceId)
            {
                ManagementService managementService = engine.ManagementService;
                Job timerJob = managementService.createJobQuery().processInstanceId(processInstanceId).activityId(activityId).singleResult();

                if (timerJob == null)
                {
                    throw new ProcessEngineException("No job for this event found in context of process instance " + processInstanceId);
                }

                managementService.executeJob(timerJob.Id);
            }
Beispiel #16
0
        protected internal virtual void executeSeedAndBatchJobs()
        {
            Job job = engineRule.ManagementService.createJobQuery().jobDefinitionId(batch.SeedJobDefinitionId).singleResult();

            //seed job
            managementService.executeJob(job.Id);

            foreach (Job pending in managementService.createJobQuery().jobDefinitionId(batch.BatchJobDefinitionId).list())
            {
                managementService.executeJob(pending.Id);
            }
        }
Beispiel #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testOriginalExceptionFromEjbReachesCaller()
        public virtual void testOriginalExceptionFromEjbReachesCaller()
        {
            runtimeService.startProcessInstanceByKey("callProcessWithExceptionFromEjb");
            Job job = managementService.createJobQuery().singleResult();

            managementService.setJobRetries(job.Id, 1);

            waitForJobExecutorToProcessAllJobs();

            Incident incident = runtimeService.createIncidentQuery().activityId("servicetask1").singleResult();

            assertThat(incident.IncidentMessage, @is("error"));
        }
Beispiel #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testPriorityOnAsyncAfterIntermediateCatchEvent()
        public virtual void testPriorityOnAsyncAfterIntermediateCatchEvent()
        {
            // given
            processInstance = runtimeService.startProcessInstanceByKey("intermediateMessageProcess");

            // when
            runtimeService.correlateMessage("Message");

            // then
            Job asyncAfterJob = managementService.createJobQuery().singleResult();

            Assert.assertEquals(PriorityBean.PRIORITY, asyncAfterJob.Priority);
        }
Beispiel #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void batchExecutionJobShouldHaveDefaultPriority()
        public virtual void batchExecutionJobShouldHaveDefaultPriority()
        {
            // given
            Batch batch = helper.migrateProcessInstancesAsync(1);

            // when
            helper.executeSeedJob(batch);

            // then
            Job executionJob = helper.getExecutionJobs(batch)[0];

            assertEquals(DefaultJobPriorityProvider.DEFAULT_PRIORITY, executionJob.Priority);
        }
Beispiel #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void seedJobShouldGetPriorityFromProcessEngineConfiguration()
        public virtual void seedJobShouldGetPriorityFromProcessEngineConfiguration()
        {
            // given
            BatchJobPriority = CUSTOM_PRIORITY;

            // when
            Batch batch = helper.migrateProcessInstancesAsync(1);

            // then
            Job seedJob = helper.getSeedJob(batch);

            assertEquals(CUSTOM_PRIORITY, seedJob.Priority);
        }
Beispiel #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void propagateTenantIdToAsyncJob()
        public virtual void propagateTenantIdToAsyncJob()
        {
            testRule.deploy(Bpmn.createExecutableProcess("process").startEvent().userTask().camundaAsyncBefore().endEvent().done());

            engineRule.RuntimeService.startProcessInstanceByKey("process");

            // the job is created when the asynchronous activity is reached
            Job job = engineRule.ManagementService.createJobQuery().singleResult();

            assertThat(job, @is(notNullValue()));
            // inherit the tenant id from execution
            assertThat(job.TenantId, @is(TENANT_ID));
        }
Beispiel #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateActivatedExecutionJobs()
        public virtual void shouldCreateActivatedExecutionJobs()
        {
            // given
            Batch batch = helper.migrateProcessInstancesAsync(1);

            // when
            helper.executeSeedJob(batch);

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

            assertFalse(migrationJob.Suspended);
        }
Beispiel #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateActivatedSeedJob()
        public virtual void shouldCreateActivatedSeedJob()
        {
            // given
            Batch batch = helper.migrateProcessInstancesAsync(2);

            // when
            helper.executeSeedJob(batch);

            // then
            Job seedJob = helper.getSeedJob(batch);

            assertFalse(seedJob.Suspended);
        }
Beispiel #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void propagateTenantIdToIntermediateTimerJob()
        public virtual void propagateTenantIdToIntermediateTimerJob()
        {
            testRule.deploy(Bpmn.createExecutableProcess("process").startEvent().intermediateCatchEvent().timerWithDuration("PT1M").endEvent().done());

            engineRule.RuntimeService.startProcessInstanceByKey("process");

            // the job is created when the timer event is reached
            Job job = engineRule.ManagementService.createJobQuery().singleResult();

            assertThat(job, @is(notNullValue()));
            // inherit the tenant id from execution
            assertThat(job.TenantId, @is(TENANT_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 seedJobShouldGetPriorityFromOverridingJobDefinitionPriorityWithCascade()
        public virtual void seedJobShouldGetPriorityFromOverridingJobDefinitionPriorityWithCascade()
        {
            // given
            Batch         batch             = helper.migrateProcessInstancesAsync(1);
            JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);

            // when
            managementService.setOverridingJobPriorityForJobDefinition(seedJobDefinition.Id, CUSTOM_PRIORITY, true);

            // then
            Job seedJob = helper.getSeedJob(batch);

            assertEquals(CUSTOM_PRIORITY, seedJob.Priority);
        }
Beispiel #26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testPriorityOnAsyncAfterUserTask()
        public virtual void testPriorityOnAsyncAfterUserTask()
        {
            // given
            processInstance = runtimeService.startProcessInstanceByKey("userTaskProcess");
            Task task = taskService.createTaskQuery().singleResult();

            // when
            taskService.complete(task.Id);

            // then
            Job asyncAfterJob = managementService.createJobQuery().singleResult();

            Assert.assertEquals(PriorityBean.PRIORITY, asyncAfterJob.Priority);
        }
Beispiel #27
0
        public virtual void testCallProcessWithAsyncOnStartEvent()
        {
            runtimeService.startProcessInstanceByKey("callAsyncSubProcess");

            Job job = managementService.createJobQuery().singleResult();

            assertNotNull(job);

            managementService.executeJob(job.Id);

            Task task = taskService.createTaskQuery().singleResult();

            assertNotNull(task);
            taskService.complete(task.Id);
        }
Beispiel #28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testPriorityOnModification()
        public virtual void testPriorityOnModification()
        {
            // given
            processInstance = runtimeService.startProcessInstanceByKey("serviceTaskProcess");

            TransitionInstance transitionInstance = runtimeService.getActivityInstance(processInstance.Id).getTransitionInstances("serviceTask")[0];

            // when
            runtimeService.createProcessInstanceModification(processInstance.Id).startBeforeActivity("serviceTask").cancelTransitionInstance(transitionInstance.Id).execute();

            // then
            Job job = managementService.createJobQuery().singleResult();

            Assert.assertEquals(PriorityBean.PRIORITY, job.Priority);
        }
Beispiel #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testExclusiveStartEvent()
        public virtual void testExclusiveStartEvent()
        {
            // start process
            runtimeService.startProcessInstanceByKey("exclusive");
            // now there should be 1 exclusive job in the database:
            Job job = managementService.createJobQuery().singleResult();

            assertNotNull(job);
            assertTrue(((JobEntity)job).Exclusive);

            waitForJobExecutorToProcessAllJobs(6000L);

            // all the jobs are done
            assertEquals(0, managementService.createJobQuery().count());
        }
Beispiel #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateSuspendedExecutionJobs()
        public virtual void shouldCreateSuspendedExecutionJobs()
        {
            // given
            Batch batch = helper.migrateProcessInstancesAsync(1);

            managementService.suspendBatchById(batch.Id);

            // when
            helper.executeSeedJob(batch);

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

            assertTrue(migrationJob.Suspended);
        }