public virtual void testMonitorJobPollingForCompletion()
        {
            var processDefinition = testRule.DeployAndGetDefinition(instance);
            var batch             = helper.StartAfterAsync("process1", 3, "user1", processDefinition.Id);

            // when the seed job creates the monitor job
            var createDate = ClockTestUtil.SetClockToDateWithoutMilliseconds();

            helper.ExecuteSeedJob(batch);

            // then the monitor job has a no due date set
            var monitorJob = helper.GetMonitorJob(batch);

            Assert.NotNull(monitorJob);
            Assert.IsNull(monitorJob.Duedate);

            // when the monitor job is executed
            helper.ExecuteMonitorJob(batch);

            // then the monitor job has a due date of the default batch poll time
            monitorJob = helper.GetMonitorJob(batch);
            var dueDate = helper.AddSeconds(createDate, 30);

            Assert.AreEqual(dueDate, monitorJob.Duedate);
        }
        public virtual void testHistoricBatchCompletion()
        {
            var processDefinition = testRule.DeployAndGetDefinition(instance);
            var batch             = helper.StartAfterAsync("process1", 1, "user1", processDefinition.Id);

            helper.ExecuteSeedJob(batch);
            helper.ExecuteJobs(batch);

            var endDate = helper.AddSecondsToClock(12);

            // when
            helper.ExecuteMonitorJob(batch);

            // then the historic batch has an end time set
            var historicBatch = helper.GetHistoricBatch(batch);

            Assert.NotNull(historicBatch);
            Assert.AreEqual(endDate, historicBatch.EndTime);
        }