示例#1
0
        public virtual void testActivationById_shouldActivateJob()
        {
            // given

            // a running process instance with a failed job
            IDictionary <string, object> @params = new Dictionary <string, object>();

            @params["fail"] = true;
            runtimeService.startProcessInstanceByKey("suspensionProcess", @params);

            // suspended job definitions and corresponding jobs
            managementService.suspendJobDefinitionByProcessDefinitionKey("suspensionProcess", true);

            // the failed job
            JobQuery jobQuery = managementService.createJobQuery();
            Job      job      = jobQuery.singleResult();

            assertTrue(job.Suspended);

            // when
            // the job will be activated
            managementService.activateJobById(job.Id);

            // then
            // the job should be active
            assertEquals(1, jobQuery.active().count());
            assertEquals(0, jobQuery.suspended().count());

            Job activeJob = jobQuery.active().singleResult();

            assertEquals(job.Id, activeJob.Id);
            assertFalse(activeJob.Suspended);
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void suspendJobDefinitionIncludingJobsForNonTenant()
        public virtual void suspendJobDefinitionIncludingJobsForNonTenant()
        {
            // given activated job definitions
            JobQuery query = engineRule.ManagementService.createJobQuery();

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

            engineRule.ManagementService.updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionWithoutTenantId().includeJobs(true).suspend();

            assertThat(query.active().count(), @is(2L));
            assertThat(query.suspended().count(), @is(1L));
            assertThat(query.suspended().withoutTenantId().count(), @is(1L));
        }
示例#3
0
        public virtual void testActivationByProcessDefinitionIdUsingBuilder()
        {
            // given

            // a running process instance with a failed job
            runtimeService.startProcessInstanceByKey("suspensionProcess", Variables.createVariables().putValue("fail", true));

            // suspended job definitions and corresponding jobs
            managementService.suspendJobDefinitionByProcessDefinitionKey("suspensionProcess", true);

            // the failed job
            JobQuery jobQuery = managementService.createJobQuery();

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

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

            // when
            // the job will be activated
            managementService.updateJobSuspensionState().byProcessDefinitionId(processDefinition.Id).activate();

            // then
            // the job should be active
            assertEquals(1, jobQuery.active().count());
            assertEquals(0, jobQuery.suspended().count());
        }
示例#4
0
        public virtual void testMultipleSuspensionByProcessDefinitionKey_shouldSuspendJob()
        {
            // given
            string key = "suspensionProcess";

            // Deploy three processes and start for each deployment a process instance
            // with a failed job
            int nrOfProcessDefinitions = 3;

            for (int i = 0; i < nrOfProcessDefinitions; i++)
            {
                repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn").deploy();
                IDictionary <string, object> @params = new Dictionary <string, object>();
                @params["fail"] = true;
                runtimeService.startProcessInstanceByKey(key, @params);
            }

            // when
            // the job will be suspended
            managementService.suspendJobByProcessDefinitionKey(key);

            // then
            // the job should be suspended
            JobQuery jobQuery = managementService.createJobQuery();

            assertEquals(0, jobQuery.active().count());
            assertEquals(3, jobQuery.suspended().count());

            // Clean DB
            foreach (org.camunda.bpm.engine.repository.Deployment deployment in repositoryService.createDeploymentQuery().list())
            {
                repositoryService.deleteDeployment(deployment.Id, true);
            }
        }
示例#5
0
        public virtual void testSuspensionByProcessDefinitionKey_shouldSuspendJob()
        {
            // given
            // a deployed process definition
            ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();

            // a running process instance with a failed job
            IDictionary <string, object> @params = new Dictionary <string, object>();

            @params["fail"] = true;
            runtimeService.startProcessInstanceByKey("suspensionProcess", @params);

            // the failed job
            JobQuery jobQuery = managementService.createJobQuery();
            Job      job      = jobQuery.singleResult();

            assertFalse(job.Suspended);

            // when
            // the job will be suspended
            managementService.suspendJobByProcessDefinitionKey(processDefinition.Key);

            // then
            // the job should be suspended
            assertEquals(0, jobQuery.active().count());
            assertEquals(1, jobQuery.suspended().count());

            Job suspendedJob = jobQuery.suspended().singleResult();

            assertEquals(job.Id, suspendedJob.Id);
            assertTrue(suspendedJob.Suspended);
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void suspendAndActivateJobDefinitionsIncludingJobsForAllTenants()
        public virtual void suspendAndActivateJobDefinitionsIncludingJobsForAllTenants()
        {
            // given activated job definitions
            JobQuery query = engineRule.ManagementService.createJobQuery();

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

            // first suspend
            engineRule.ManagementService.updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).includeJobs(true).suspend();

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

            // then activate
            engineRule.ManagementService.updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).includeJobs(true).activate();

            assertThat(query.active().count(), @is(3L));
            assertThat(query.suspended().count(), @is(0L));
        }
示例#7
0
        public virtual void testSuspensionByProcessDefinitionKeyUsingBuilder()
        {
            // given

            // a running process instance with a failed job
            runtimeService.startProcessInstanceByKey("suspensionProcess", Variables.createVariables().putValue("fail", true));

            // the failed job
            JobQuery jobQuery = managementService.createJobQuery();

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

            // when
            // the job will be suspended
            managementService.updateJobSuspensionState().byProcessDefinitionKey("suspensionProcess").suspend();

            // then
            // the job should be suspended
            assertEquals(0, jobQuery.active().count());
            assertEquals(1, jobQuery.suspended().count());
        }