Esempio n. 1
0
        public virtual void testRecalculateTimeCycleExpressionCreationDateBased()
        {
            // given
            IDictionary <string, object> variables = new Dictionary <string, object>();

            variables["cycle"] = "R/PT15M";
            string processInstanceId = runtimeService.startProcessInstanceByKey("process", variables).Id;

            JobQuery query = managementService.createJobQuery();

            assertEquals(1, query.count());
            Job      job        = query.singleResult();
            DateTime oldDuedate = job.Duedate;
            string   jobId      = job.Id;

            // when
            runtimeService.setVariable(processInstanceId, "cycle", "R/PT10M");
            managementService.recalculateJobDuedate(jobId, true);

            // then
            assertEquals(1, query.count());
            DateTime newDuedate = query.singleResult().Duedate;

            assertTrue(oldDuedate > newDuedate);
            DateTime expectedDate = LocalDateTime.fromDateFields(job.CreateTime).plusMinutes(10).toDate();

            assertEquals(expectedDate, newDuedate);

            managementService.executeJob(jobId);
            string taskId = taskService.createTaskQuery().singleResult().Id;

            taskService.complete(taskId);

            assertProcessEnded(processInstanceId);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testTimeCycle()
        public virtual void testTimeCycle()
        {
            string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id;

            EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery();

            assertEquals(0, eventSubscriptionQuery.count());

            TaskQuery taskQuery = taskService.createTaskQuery();

            assertEquals(1, taskQuery.count());
            Task task = taskQuery.singleResult();

            assertEquals("task", task.TaskDefinitionKey);

            JobQuery jobQuery = managementService.createJobQuery().timers();

            assertEquals(1, jobQuery.count());

            string jobId = jobQuery.singleResult().Id;

            managementService.executeJob(jobId);

            assertEquals(0, jobQuery.count());

            assertEquals(1, taskQuery.count());
            task = taskQuery.singleResult();
            assertEquals("eventSubProcessTask", task.TaskDefinitionKey);

            taskService.complete(task.Id);

            assertProcessEnded(processInstanceId);
        }
Esempio n. 3
0
        public virtual void testExpressionRecalculateCreationDateBased()
        {
            // Set the clock fixed
            Dictionary <string, object> variables = new Dictionary <string, object>();

            variables["duration"] = "PT1H";

            // After process start, there should be timer created
            ProcessInstanceWithVariables pi1 = (ProcessInstanceWithVariables)runtimeService.startProcessInstanceByKey("intermediateTimerEventExample", variables);
            JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi1.Id);

            assertEquals(1, jobQuery.count());
            Job      job       = jobQuery.singleResult();
            DateTime firstDate = job.Duedate;

            // After variable change and recalculation, there should still be one timer only, with a changed due date
            moveByMinutes(65);     // move past first due date
            runtimeService.setVariable(pi1.ProcessInstanceId, "duration", "PT15M");
            processEngine.ManagementService.recalculateJobDuedate(job.Id, true);

            assertEquals(1, jobQuery.count());
            job = jobQuery.singleResult();
            assertNotEquals(firstDate, job.Duedate);
            assertTrue(firstDate > job.Duedate);
            DateTime expectedDate = LocalDateTime.fromDateFields(job.CreateTime).plusMinutes(15).toDate();

            assertEquals(expectedDate, job.Duedate);

            // After waiting for sixteen minutes the timer should fire
            ClockUtil.CurrentTime = new DateTime(firstDate.Ticks + TimeUnit.MINUTES.toMillis(16L));
            waitForJobExecutorToProcessAllJobs(5000L);

            assertEquals(0, managementService.createJobQuery().processInstanceId(pi1.Id).count());
            assertProcessEnded(pi1.ProcessInstanceId);
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testFailingTimeCycle()
        public virtual void testFailingTimeCycle()
        {
            // given
            runtimeService.startProcessInstanceByKey("process");

            JobQuery failedJobQuery = managementService.createJobQuery();
            JobQuery jobQuery       = managementService.createJobQuery();

            assertEquals(1, jobQuery.count());

            string jobId = jobQuery.singleResult().Id;

            failedJobQuery.jobId(jobId);

            // when (1)
            try
            {
                managementService.executeJob(jobId);
                fail();
            }
            catch (Exception)
            {
                // expected
            }

            // then (1)
            Job failedJob = failedJobQuery.singleResult();

            assertEquals(2, failedJob.Retries);

            // a new timer job has been created
            assertEquals(2, jobQuery.count());

            assertEquals(1, managementService.createJobQuery().withException().count());
            assertEquals(0, managementService.createJobQuery().noRetriesLeft().count());
            assertEquals(2, managementService.createJobQuery().withRetriesLeft().count());

            // when (2)
            try
            {
                managementService.executeJob(jobId);
            }
            catch (Exception)
            {
                // expected
            }

            // then (2)
            failedJob = failedJobQuery.singleResult();
            assertEquals(1, failedJob.Retries);

            // there are still two jobs
            assertEquals(2, jobQuery.count());

            assertEquals(1, managementService.createJobQuery().withException().count());
            assertEquals(0, managementService.createJobQuery().noRetriesLeft().count());
            assertEquals(2, managementService.createJobQuery().withRetriesLeft().count());
        }
Esempio n. 5
0
        public virtual void testQueryByTenantId()
        {
            JobQuery query = managementService.createJobQuery().tenantIdIn(TENANT_ONE);

            assertThat(query.count(), @is(1L));

            query = managementService.createJobQuery().tenantIdIn(TENANT_TWO);

            assertThat(query.count(), @is(1L));
        }
Esempio n. 6
0
        public virtual void testQueryByTenantIdsIncludeJobsWithoutTenantId()
        {
            JobQuery query = managementService.createJobQuery().tenantIdIn(TENANT_ONE).includeJobsWithoutTenantId();

            assertThat(query.count(), @is(2L));

            query = managementService.createJobQuery().tenantIdIn(TENANT_TWO).includeJobsWithoutTenantId();

            assertThat(query.count(), @is(2L));

            query = managementService.createJobQuery().tenantIdIn(TENANT_ONE, TENANT_TWO).includeJobsWithoutTenantId();

            assertThat(query.count(), @is(3L));
        }
Esempio n. 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testExpressionOnTimer()
        public virtual void testExpressionOnTimer()
        {
            // Set the clock fixed
            DateTime startTime = DateTime.Now;

            Dictionary <string, object> variables = new Dictionary <string, object>();

            variables["duration"] = "PT1H";

            // After process start, there should be a timer created
            ProcessInstance pi = runtimeService.startProcessInstanceByKey("testExpressionOnTimer", variables);

            JobQuery    jobQuery = managementService.createJobQuery().processInstanceId(pi.Id);
            IList <Job> jobs     = jobQuery.list();

            assertEquals(1, jobs.Count);

            // After setting the clock to time '1 hour and 5 seconds', the second timer should fire
            ClockUtil.CurrentTime = new DateTime(startTime.Ticks + ((60 * 60 * 1000) + 5000));
            waitForJobExecutorToProcessAllJobs(5000L);
            assertEquals(0L, jobQuery.count());

            // which means the process has ended
            assertProcessEnded(pi.Id);
        }
Esempio n. 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testCancelTimer()
        public virtual void testCancelTimer()
        {
            ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");

            TaskQuery taskQuery = taskService.createTaskQuery();
            JobQuery  jobQuery  = managementService.createJobQuery().timers();

            Task task = taskQuery.singleResult();

            assertNotNull(task);
            assertEquals("taskBeforeInterruptingEventSuprocess", task.TaskDefinitionKey);

            Job timer = jobQuery.singleResult();

            assertNotNull(timer);

            runtimeService.messageEventReceived("newMessage", pi.Id);

            task = taskQuery.singleResult();
            assertNotNull(task);
            assertEquals("taskAfterMessageStartEvent", task.TaskDefinitionKey);

            assertEquals(0, jobQuery.count());

            taskService.complete(task.Id);

            assertProcessEnded(pi.Id);
        }
Esempio n. 9
0
        public virtual void testQueryNoAuthenticatedTenants()
        {
            identityService.setAuthentication("user", null, null);

            JobQuery query = managementService.createJobQuery();

            assertThat(query.count(), @is(1L));
        }
Esempio n. 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testCatchingTimerEvent() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testCatchingTimerEvent()
        {
            // Set the clock fixed
            DateTime startTime = DateTime.Now;

            // After process start, there should be timer created
            ProcessInstance pi       = runtimeService.startProcessInstanceByKey("intermediateTimerEventExample");
            JobQuery        jobQuery = managementService.createJobQuery().processInstanceId(pi.Id);

            assertEquals(1, jobQuery.count());

            // After setting the clock to time '50minutes and 5 seconds', the second timer should fire
            ClockUtil.CurrentTime = new DateTime(startTime.Ticks + ((50 * 60 * 1000) + 5000));
            waitForJobExecutorToProcessAllJobs(5000L);

            assertEquals(0, jobQuery.count());
            assertProcessEnded(pi.ProcessInstanceId);
        }
Esempio n. 11
0
        public virtual void testQueryDisabledTenantCheck()
        {
            processEngineConfiguration.TenantCheckEnabled = false;
            identityService.setAuthentication("user", null, null);

            JobQuery query = managementService.createJobQuery();

            assertThat(query.count(), @is(3L));
        }
Esempio n. 12
0
        public virtual void testTimeCycle()
        {
            // given
            runtimeService.startProcessInstanceByKey("nonInterruptingCycle");

            JobQuery jobQuery = managementService.createJobQuery();

            assertEquals(1, jobQuery.count());
            string jobId = jobQuery.singleResult().Id;

            // when
            managementService.executeJob(jobId);

            // then
            assertEquals(1, jobQuery.count());

            string anotherJobId = jobQuery.singleResult().Id;

            assertFalse(jobId.Equals(anotherJobId));
        }
Esempio n. 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testTimeCycle()
        public virtual void testTimeCycle()
        {
            string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id;

            JobQuery query = managementService.createJobQuery();

            assertEquals(1, query.count());

            string jobId = query.singleResult().Id;

            managementService.executeJob(jobId);

            assertEquals(0, query.count());

            string taskId = taskService.createTaskQuery().singleResult().Id;

            taskService.complete(taskId);

            assertProcessEnded(processInstanceId);
        }
Esempio n. 14
0
        private JobQuery setUpMockJobQuery(IList <Job> mockedJobs)
        {
            JobQuery sampleJobQuery = mock(typeof(JobQuery));

            when(sampleJobQuery.list()).thenReturn(mockedJobs);
            when(sampleJobQuery.count()).thenReturn((long)mockedJobs.Count);

            when(processEngine.ManagementService.createJobQuery()).thenReturn(sampleJobQuery);

            return(sampleJobQuery);
        }
Esempio n. 15
0
        public virtual void testQueryAuthenticatedTenants()
        {
            identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO));

            JobQuery query = managementService.createJobQuery();

            assertThat(query.count(), @is(3L));
            assertThat(query.tenantIdIn(TENANT_ONE).count(), @is(1L));
            assertThat(query.tenantIdIn(TENANT_TWO).count(), @is(1L));
            assertThat(query.withoutTenantId().count(), @is(1L));
        }
Esempio n. 16
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());
        }
Esempio n. 17
0
        public virtual void testJobCommandsWith2Exceptions()
        {
            // create a job
            createJob(TweetExceptionHandler.TYPE);

            // execute the existing job
            executeAvailableJobs();

            // the job was successfully executed
            JobQuery query = managementService.createJobQuery().noRetriesLeft();

            assertEquals(0, query.count());
        }
Esempio n. 18
0
        public virtual CountResultDto queryJobsCount(JobQueryDto queryDto)
        {
            ProcessEngine engine = ProcessEngine;

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

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

            result.Count = count;

            return(result);
        }
Esempio n. 19
0
        public virtual void testFailedTimerStartEvent()
        {
            // After process start, there should be timer created
            JobQuery jobQuery = managementService.createJobQuery();

            assertEquals(1, jobQuery.count());

            Job job = managementService.createJobQuery().list().get(0);

            assertNotNull(job);
            string jobId = job.Id;

            waitForExecutedJobWithRetriesLeft(4, jobId);
            stillOneJobWithExceptionAndRetriesLeft(jobId);

            job = refreshJob(jobId);
            assertNotNull(job);

            assertEquals(4, job.Retries);

            waitForExecutedJobWithRetriesLeft(3, jobId);

            job = refreshJob(jobId);
            assertEquals(3, job.Retries);
            stillOneJobWithExceptionAndRetriesLeft(jobId);

            waitForExecutedJobWithRetriesLeft(2, jobId);

            job = refreshJob(jobId);
            assertEquals(2, job.Retries);
            stillOneJobWithExceptionAndRetriesLeft(jobId);

            waitForExecutedJobWithRetriesLeft(1, jobId);

            job = refreshJob(jobId);
            assertEquals(1, job.Retries);
            stillOneJobWithExceptionAndRetriesLeft(jobId);

            waitForExecutedJobWithRetriesLeft(0, jobId);

            job = refreshJob(jobId);
            assertEquals(0, job.Retries);
            assertEquals(1, managementService.createJobQuery().withException().count());
            assertEquals(0, managementService.createJobQuery().jobId(jobId).withRetriesLeft().count());
            assertEquals(1, managementService.createJobQuery().noRetriesLeft().count());
        }
Esempio n. 20
0
        private void verifyQueryResults(JobQuery query, int countExpected)
        {
            assertEquals(countExpected, query.list().size());
            assertEquals(countExpected, query.count());

            if (countExpected == 1)
            {
                assertNotNull(query.singleResult());
            }
            else if (countExpected > 1)
            {
                verifySingleResultFails(query);
            }
            else if (countExpected == 0)
            {
                assertNull(query.singleResult());
            }
        }
Esempio n. 21
0
        protected internal virtual void cycleAcquisitionAndAssertAfterJobExecution(JobQuery jobQuery)
        {
            // another cycle of job acquisition after acuqisition idle was reseted
            // => 1 jobs are acquired
            triggerReconfigurationAndNextCycle();
            assertJobExecutorWaitEvent(0);

            // we have no timer to fire
            assertEquals(0, jobQuery.count());

            // and we are in the second state
            assertEquals(1L, engineRule.TaskService.createTaskQuery().count());
            Task task = engineRule.TaskService.createTaskQuery().orderByTaskName().desc().singleResult();

            assertEquals("Next Task", task.Name);
            // complete the task and end the execution
            engineRule.TaskService.complete(task.Id);
        }
Esempio n. 22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testRecalculateUnchangedExpressionOnTimerCurrentDateBased()
        public virtual void testRecalculateUnchangedExpressionOnTimerCurrentDateBased()
        {
            // Set the clock fixed
            DateTime startTime = DateTime.Now;

            Dictionary <string, object> variables = new Dictionary <string, object>();

            variables["duedate"] = "PT1H";

            // After process start, there should be a timer created
            ProcessInstance pi = runtimeService.startProcessInstanceByKey("testExpressionOnTimer", variables);

            JobQuery    jobQuery = managementService.createJobQuery().processInstanceId(pi.Id);
            IList <Job> jobs     = jobQuery.list();

            assertEquals(1, jobs.Count);
            Job      job     = jobs[0];
            DateTime oldDate = job.Duedate;

            // After recalculation of the timer, the job's duedate should be changed
            DateTime currentTime = new DateTime(startTime.Ticks + TimeUnit.MINUTES.toMillis(5));

            ClockUtil.CurrentTime = currentTime;
            managementService.recalculateJobDuedate(job.Id, false);
            Job jobUpdated = jobQuery.singleResult();

            assertEquals(job.Id, jobUpdated.Id);
            assertNotEquals(oldDate, jobUpdated.Duedate);
            assertTrue(oldDate < jobUpdated.Duedate);
            DateTime expectedDate = LocalDateTime.fromDateFields(currentTime).plusHours(1).toDate();

            assertThat(jobUpdated.Duedate).isCloseTo(expectedDate, 1000l);

            // After setting the clock to time '1 hour and 6 min', the second timer should fire
            ClockUtil.CurrentTime = new DateTime(startTime.Ticks + TimeUnit.HOURS.toMillis(1L) + TimeUnit.MINUTES.toMillis(6L));
            waitForJobExecutorToProcessAllJobs(5000L);
            assertEquals(0L, jobQuery.count());

            // which means the process has ended
            assertProcessEnded(pi.Id);
        }
Esempio n. 23
0
        /*
         * Test for when multiple boundary timer events are defined on the same user
         * task
         *
         * Configuration: - timer 1 -> 2 hours -> secondTask - timer 2 -> 1 hour ->
         * thirdTask - timer 3 -> 3 hours -> fourthTask
         *
         * See process image next to the process xml resource
         */
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testMultipleTimersOnUserTask()
        public virtual void testMultipleTimersOnUserTask()
        {
            // Set the clock fixed
            DateTime startTime = DateTime.Now;

            // After process start, there should be 3 timers created
            ProcessInstance pi       = runtimeService.startProcessInstanceByKey("multipleTimersOnUserTask");
            JobQuery        jobQuery = managementService.createJobQuery().processInstanceId(pi.Id);
            IList <Job>     jobs     = jobQuery.list();

            assertEquals(3, jobs.Count);

            // After setting the clock to time '1 hour and 5 seconds', the second timer should fire
            ClockUtil.CurrentTime = new DateTime(startTime.Ticks + ((60 * 60 * 1000) + 5000));
            waitForJobExecutorToProcessAllJobs(5000L);
            assertEquals(0L, jobQuery.count());

            // which means that the third task is reached
            Task task = taskService.createTaskQuery().singleResult();

            assertEquals("Third Task", task.Name);
        }
Esempio n. 24
0
        public virtual void testRecalculateChangedExpressionOnTimerCreationDateBased()
        {
            // Set the clock fixed
            DateTime startTime = DateTime.Now;

            Dictionary <string, object> variables = new Dictionary <string, object>();

            variables["duedate"] = "PT1H";

            // After process start, there should be a timer created
            ProcessInstance pi = runtimeService.startProcessInstanceByKey("testExpressionOnTimer", variables);

            JobQuery    jobQuery = managementService.createJobQuery().processInstanceId(pi.Id);
            IList <Job> jobs     = jobQuery.list();

            assertEquals(1, jobs.Count);
            Job      job     = jobs[0];
            DateTime oldDate = job.Duedate;

            // After recalculation of the timer, the job's duedate should be the same
            runtimeService.setVariable(pi.Id, "duedate", "PT15M");
            managementService.recalculateJobDuedate(job.Id, true);
            Job jobUpdated = jobQuery.singleResult();

            assertEquals(job.Id, jobUpdated.Id);
            assertNotEquals(oldDate, jobUpdated.Duedate);
            assertEquals(LocalDateTime.fromDateFields(jobUpdated.CreateTime).plusMinutes(15).toDate(), jobUpdated.Duedate);

            // After setting the clock to time '16 minutes', the timer should fire
            ClockUtil.CurrentTime = new DateTime(startTime.Ticks + TimeUnit.MINUTES.toMillis(16L));
            waitForJobExecutorToProcessAllJobs(5000L);
            assertEquals(0L, jobQuery.count());

            // which means the process has ended
            assertProcessEnded(pi.Id);
        }
Esempio n. 25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testFinishedJob()
        public virtual void testFinishedJob()
        {
            // given
            Dictionary <string, object> variables1 = new Dictionary <string, object>();

            variables1["dueDate"] = DateTime.Now;

            ProcessInstance pi1 = runtimeService.startProcessInstanceByKey("intermediateTimerEventExample", variables1);

            assertEquals(1, managementService.createJobQuery().processInstanceId(pi1.Id).count());

            JobQuery jobQuery = managementService.createJobQuery().executable();

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

            // job duedate can be recalculated, job still exists in runtime
            string jobId = jobQuery.singleResult().Id;

            managementService.recalculateJobDuedate(jobId, false);
            // run the job, finish the process
            managementService.executeJob(jobId);
            assertEquals(0L, managementService.createJobQuery().processInstanceId(pi1.Id).count());
            assertProcessEnded(pi1.ProcessInstanceId);

            try
            {
                // when
                managementService.recalculateJobDuedate(jobId, false);
                fail("The recalculation of a finished job should not be possible");
            }
            catch (ProcessEngineException pe)
            {
                // then
                assertTextPresent("No job found with id '" + jobId, pe.Message);
            }
        }
Esempio n. 26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testMultipleTimersOnUserTask()
        public virtual void testMultipleTimersOnUserTask()
        {
            // Set the clock fixed
            DateTime startTime = DateTime.Now;

            // After process start, there should be 3 timers created
            ProcessInstance pi    = runtimeService.startProcessInstanceByKey("nonInterruptingTimersOnUserTask");
            Task            task1 = taskService.createTaskQuery().singleResult();

            assertEquals("First Task", task1.Name);

            JobQuery    jobQuery = managementService.createJobQuery().processInstanceId(pi.Id);
            IList <Job> jobs     = jobQuery.list();

            assertEquals(2, jobs.Count);

            // After setting the clock to time '1 hour and 5 seconds', the first timer should fire
            ClockUtil.CurrentTime = new DateTime(startTime.Ticks + ((60 * 60 * 1000) + 5000));
            waitForJobExecutorToProcessAllJobs(5000L);

            // we still have one timer more to fire
            assertEquals(1L, jobQuery.count());

            // and we are still in the first state, but in the second state as well!
            assertEquals(2L, taskService.createTaskQuery().count());
            IList <Task> taskList = taskService.createTaskQuery().orderByTaskName().desc().list();

            assertEquals("First Task", taskList[0].Name);
            assertEquals("Escalation Task 1", taskList[1].Name);

            // complete the task and end the forked execution
            taskService.complete(taskList[1].Id);

            // but we still have the original executions
            assertEquals(1L, taskService.createTaskQuery().count());
            assertEquals("First Task", taskService.createTaskQuery().singleResult().Name);

            // After setting the clock to time '2 hour and 5 seconds', the second timer should fire
            ClockUtil.CurrentTime = new DateTime(startTime.Ticks + ((2 * 60 * 60 * 1000) + 5000));
            waitForJobExecutorToProcessAllJobs(5000L);

            // no more timers to fire
            assertEquals(0L, jobQuery.count());

            // and we are still in the first state, but in the next escalation state as well
            assertEquals(2L, taskService.createTaskQuery().count());
            taskList = taskService.createTaskQuery().orderByTaskName().desc().list();
            assertEquals("First Task", taskList[0].Name);
            assertEquals("Escalation Task 2", taskList[1].Name);

            // This time we end the main task
            taskService.complete(taskList[0].Id);

            // but we still have the escalation task
            assertEquals(1L, taskService.createTaskQuery().count());
            Task escalationTask = taskService.createTaskQuery().singleResult();

            assertEquals("Escalation Task 2", escalationTask.Name);

            taskService.complete(escalationTask.Id);

            // now we are really done :-)
            assertProcessEnded(pi.Id);
        }
Esempio n. 27
0
        public virtual void testQueryByNonExistingTenantId()
        {
            JobQuery query = managementService.createJobQuery().tenantIdIn("nonExisting");

            assertThat(query.count(), @is(0L));
        }
Esempio n. 28
0
        public virtual void testQueryByJobsWithoutTenantId()
        {
            JobQuery query = managementService.createJobQuery().withoutTenantId();

            assertThat(query.count(), @is(1L));
        }
Esempio n. 29
0
        public virtual void testQueryNoTenantIdSet()
        {
            JobQuery query = managementService.createJobQuery();

            assertThat(query.count(), @is(3L));
        }