@Test @Deployment(resources = "org/camunda/bpm/engine/test/jobexecutor/simpleAsyncProcess.bpmn20.xml") public void testJobDueDateValue() { // when runtimeService.startProcessInstanceByKey("simpleAsyncProcess"); List<JobEntity> jobList = findAcquirableJobs(); // then assertEquals(1, jobList.size()); assertEquals(currentTime, jobList.get(0).getDuedate()); } }
@Test public void testLessThanThresholdWithinBatchWindow() { //given prepareData(5); //we're within batch window Date now = new Date(); ClockUtil.setCurrentTime(now); processEngineConfiguration.setHistoryCleanupBatchWindowStartTime(new SimpleDateFormat("HH:mm").format(now)); processEngineConfiguration.setHistoryCleanupBatchWindowEndTime(new SimpleDateFormat("HH:mm").format(DateUtils.addHours(now, HISTORY_TIME_TO_LIVE))); processEngineConfiguration.initHistoryCleanup(); //when runHistoryCleanup(); //then final List<Job> historyCleanupJobs = historyService.findHistoryCleanupJobs(); for (Job job : historyCleanupJobs) { JobEntity jobEntity = (JobEntity) job; HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity); //job rescheduled till current time + delay Date nextRun = getNextRunWithDelay(ClockUtil.getCurrentTime(), 0); assertTrue(jobEntity.getDuedate().equals(nextRun) || jobEntity.getDuedate().after(nextRun)); Date nextRunMax = DateUtils.addSeconds(ClockUtil.getCurrentTime(), HistoryCleanupJobHandlerConfiguration.MAX_DELAY); assertTrue(jobEntity.getDuedate().before(nextRunMax)); //countEmptyRuns incremented assertEquals(1, configuration.getCountEmptyRuns()); } //data is still removed assertResult(0); }
assertTrue(jobEntity.getDuedate().equals(nextRun) || jobEntity.getDuedate().after(nextRun)); assertTrue(jobEntity.getDuedate().before(getNextRunWithinBatchWindow(now)));
assertTrue(jobEntity.getDuedate().equals(nextRun) || jobEntity.getDuedate().after(nextRun)); Date nextRunMax = DateUtils.addSeconds(ClockUtil.getCurrentTime(), HistoryCleanupJobHandlerConfiguration.MAX_DELAY); assertTrue(jobEntity.getDuedate().before(nextRunMax));
@Test public void testLessThanThresholdWithinBatchWindowAfterMidnight() { //given prepareData(5); //we're within batch window, but batch window passes midnight Date date = new Date(); ClockUtil.setCurrentTime(DateUtils.setMinutes(DateUtils.setHours(date, 0), 10)); //00:10 processEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00"); processEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00"); processEngineConfiguration.initHistoryCleanup(); //when runHistoryCleanup(false); //then final List<Job> historyCleanupJobs = historyService.findHistoryCleanupJobs(); for (Job job : historyCleanupJobs) { JobEntity jobEntity = (JobEntity) job; HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity); //job rescheduled till current time + delay Date nextRun = getNextRunWithDelay(ClockUtil.getCurrentTime(), 0); assertTrue(jobEntity.getDuedate().equals(nextRun) || jobEntity.getDuedate().after(nextRun)); Date nextRunMax = DateUtils.addSeconds(ClockUtil.getCurrentTime(), HistoryCleanupJobHandlerConfiguration.MAX_DELAY); assertTrue(jobEntity.getDuedate().before(nextRunMax)); //countEmptyRuns incremented assertEquals(1, configuration.getCountEmptyRuns()); } //data is still removed assertResult(0); }
@Test public void testLessThanThresholdWithinBatchWindowBeforeMidnight() { //given prepareData(5); //we're within batch window, but batch window passes midnight Date date = new Date(); ClockUtil.setCurrentTime(DateUtils.setMinutes(DateUtils.setHours(date, 23), 10)); //23:10 processEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00"); processEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00"); processEngineConfiguration.initHistoryCleanup(); //when runHistoryCleanup(); //then final List<Job> historyCleanupJobs = historyService.findHistoryCleanupJobs(); for (Job job : historyCleanupJobs) { JobEntity jobEntity = (JobEntity) job; HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity); //job rescheduled till current time + delay Date nextRun = getNextRunWithDelay(ClockUtil.getCurrentTime(), 0); assertTrue(jobEntity.getDuedate().equals(nextRun) || jobEntity.getDuedate().after(nextRun)); Date nextRunMax = DateUtils.addSeconds(ClockUtil.getCurrentTime(), HistoryCleanupJobHandlerConfiguration.MAX_DELAY); assertTrue(jobEntity.getDuedate().before(nextRunMax)); //countEmptyRuns incremented assertEquals(1, configuration.getCountEmptyRuns()); } //data is still removed assertResult(0); }
@Test public void testLessThanThresholdOutsideBatchWindow() { //given prepareData(5); //we're outside batch window Date twoHoursAgo = new Date(); processEngineConfiguration.setHistoryCleanupBatchWindowStartTime(new SimpleDateFormat("HH:mm").format(twoHoursAgo)); processEngineConfiguration.setHistoryCleanupBatchWindowEndTime(new SimpleDateFormat("HH:mm").format(DateUtils.addHours(twoHoursAgo, 1))); processEngineConfiguration.initHistoryCleanup(); ClockUtil.setCurrentTime(DateUtils.addHours(twoHoursAgo, 2)); //when for (int i = 1; i <= 3; i++) { runHistoryCleanup(); } //then final List<Job> historyCleanupJobs = historyService.findHistoryCleanupJobs(); for (Job job : historyCleanupJobs) { JobEntity jobEntity = (JobEntity) job; HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity); //job rescheduled till next batch window start Date nextRun = getNextRunWithinBatchWindow(ClockUtil.getCurrentTime()); assertTrue(jobEntity.getDuedate().equals(nextRun)); //countEmptyRuns canceled assertEquals(0, configuration.getCountEmptyRuns()); } //nothing was removed assertResult(5); }
assertTrue(jobEntity.getDuedate().equals(nextRun));
@Test public void testLessThanThresholdOutsideBatchWindowAfterMidnight() { //given prepareData(5); //we're outside batch window, batch window passes midnight Date date = new Date(); ClockUtil.setCurrentTime(DateUtils.setMinutes(DateUtils.setHours(date, 1), 10)); //01:10 processEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00"); processEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00"); processEngineConfiguration.initHistoryCleanup(); //when String jobId = historyService.cleanUpHistoryAsync().getId(); managementService.executeJob(jobId); //then JobEntity jobEntity = getJobEntity(jobId); HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity); //job rescheduled till next batch window start Date nextRun = getNextRunWithinBatchWindow(ClockUtil.getCurrentTime()); assertTrue(jobEntity.getDuedate().equals(nextRun)); assertTrue(nextRun.after(ClockUtil.getCurrentTime())); //countEmptyRuns canceled assertEquals(0, configuration.getCountEmptyRuns()); //nothing was removed assertResult(5); }
@Test public void testLessThanThresholdOutsideBatchWindowBeforeMidnight() { //given prepareData(5); //we're outside batch window, batch window passes midnight Date date = new Date(); ClockUtil.setCurrentTime(DateUtils.setMinutes(DateUtils.setHours(date, 22), 10)); //22:10 processEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00"); processEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00"); processEngineConfiguration.initHistoryCleanup(); //when String jobId = historyService.cleanUpHistoryAsync().getId(); managementService.executeJob(jobId); //then JobEntity jobEntity = getJobEntity(jobId); HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity); //job rescheduled till next batch window start Date nextRun = getNextRunWithinBatchWindow(ClockUtil.getCurrentTime()); assertTrue(jobEntity.getDuedate().equals(nextRun)); assertTrue(nextRun.after(ClockUtil.getCurrentTime())); //countEmptyRuns cancelled assertEquals(0, configuration.getCountEmptyRuns()); //nothing was removed assertResult(5); }
evt.setJobDueDate(jobEntity.getDuedate()); evt.setJobRetries(jobEntity.getRetries()); evt.setJobPriority(jobEntity.getPriority());
evt.setJobDueDate(jobEntity.getDuedate()); evt.setJobRetries(jobEntity.getRetries()); evt.setJobPriority(jobEntity.getPriority());
@Test public void testLessThanThresholdWithinBatchWindow() { //given prepareData(5); //we're within batch window Date now = new Date(); ClockUtil.setCurrentTime(now); processEngineConfiguration.setHistoryCleanupBatchWindowStartTime(new SimpleDateFormat("HH:mm").format(now)); processEngineConfiguration.setHistoryCleanupBatchWindowEndTime(new SimpleDateFormat("HH:mm").format(DateUtils.addHours(now, HISTORY_TIME_TO_LIVE))); processEngineConfiguration.initHistoryCleanup(); //when runHistoryCleanup(); //then final List<Job> historyCleanupJobs = historyService.findHistoryCleanupJobs(); for (Job job : historyCleanupJobs) { JobEntity jobEntity = (JobEntity) job; HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity); //job rescheduled till current time + delay Date nextRun = getNextRunWithDelay(ClockUtil.getCurrentTime(), 0); assertTrue(jobEntity.getDuedate().equals(nextRun) || jobEntity.getDuedate().after(nextRun)); Date nextRunMax = DateUtils.addSeconds(ClockUtil.getCurrentTime(), HistoryCleanupJobHandlerConfiguration.MAX_DELAY); assertTrue(jobEntity.getDuedate().before(nextRunMax)); //countEmptyRuns incremented assertEquals(1, configuration.getCountEmptyRuns()); } //data is still removed assertResult(0); }
assertTrue(jobEntity.getDuedate().equals(nextRun) || jobEntity.getDuedate().after(nextRun)); assertTrue(jobEntity.getDuedate().before(getNextRunWithinBatchWindow(now)));
@Test public void testLessThanThresholdWithinBatchWindowBeforeMidnight() { //given prepareData(5); //we're within batch window, but batch window passes midnight Date date = new Date(); ClockUtil.setCurrentTime(DateUtils.setMinutes(DateUtils.setHours(date, 23), 10)); //23:10 processEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00"); processEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00"); processEngineConfiguration.initHistoryCleanup(); //when runHistoryCleanup(); //then final List<Job> historyCleanupJobs = historyService.findHistoryCleanupJobs(); for (Job job : historyCleanupJobs) { JobEntity jobEntity = (JobEntity) job; HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity); //job rescheduled till current time + delay Date nextRun = getNextRunWithDelay(ClockUtil.getCurrentTime(), 0); assertTrue(jobEntity.getDuedate().equals(nextRun) || jobEntity.getDuedate().after(nextRun)); Date nextRunMax = DateUtils.addSeconds(ClockUtil.getCurrentTime(), HistoryCleanupJobHandlerConfiguration.MAX_DELAY); assertTrue(jobEntity.getDuedate().before(nextRunMax)); //countEmptyRuns incremented assertEquals(1, configuration.getCountEmptyRuns()); } //data is still removed assertResult(0); }
@Test public void testLessThanThresholdWithinBatchWindowAfterMidnight() { //given prepareData(5); //we're within batch window, but batch window passes midnight Date date = new Date(); ClockUtil.setCurrentTime(DateUtils.setMinutes(DateUtils.setHours(date, 0), 10)); //00:10 processEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00"); processEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00"); processEngineConfiguration.initHistoryCleanup(); //when runHistoryCleanup(false); //then final List<Job> historyCleanupJobs = historyService.findHistoryCleanupJobs(); for (Job job : historyCleanupJobs) { JobEntity jobEntity = (JobEntity) job; HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity); //job rescheduled till current time + delay Date nextRun = getNextRunWithDelay(ClockUtil.getCurrentTime(), 0); assertTrue(jobEntity.getDuedate().equals(nextRun) || jobEntity.getDuedate().after(nextRun)); Date nextRunMax = DateUtils.addSeconds(ClockUtil.getCurrentTime(), HistoryCleanupJobHandlerConfiguration.MAX_DELAY); assertTrue(jobEntity.getDuedate().before(nextRunMax)); //countEmptyRuns incremented assertEquals(1, configuration.getCountEmptyRuns()); } //data is still removed assertResult(0); }
@Test public void testLessThanThresholdOutsideBatchWindow() { //given prepareData(5); //we're outside batch window Date twoHoursAgo = new Date(); processEngineConfiguration.setHistoryCleanupBatchWindowStartTime(new SimpleDateFormat("HH:mm").format(twoHoursAgo)); processEngineConfiguration.setHistoryCleanupBatchWindowEndTime(new SimpleDateFormat("HH:mm").format(DateUtils.addHours(twoHoursAgo, 1))); processEngineConfiguration.initHistoryCleanup(); ClockUtil.setCurrentTime(DateUtils.addHours(twoHoursAgo, 2)); //when for (int i = 1; i <= 3; i++) { runHistoryCleanup(); } //then final List<Job> historyCleanupJobs = historyService.findHistoryCleanupJobs(); for (Job job : historyCleanupJobs) { JobEntity jobEntity = (JobEntity) job; HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity); //job rescheduled till next batch window start Date nextRun = getNextRunWithinBatchWindow(ClockUtil.getCurrentTime()); assertTrue(jobEntity.getDuedate().equals(nextRun)); //countEmptyRuns canceled assertEquals(0, configuration.getCountEmptyRuns()); } //nothing was removed assertResult(5); }
assertTrue(jobEntity.getDuedate().equals(nextRun));
@Test public void testLessThanThresholdOutsideBatchWindowAfterMidnight() { //given prepareData(5); //we're outside batch window, batch window passes midnight Date date = new Date(); ClockUtil.setCurrentTime(DateUtils.setMinutes(DateUtils.setHours(date, 1), 10)); //01:10 processEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00"); processEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00"); processEngineConfiguration.initHistoryCleanup(); //when String jobId = historyService.cleanUpHistoryAsync().getId(); managementService.executeJob(jobId); //then JobEntity jobEntity = getJobEntity(jobId); HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity); //job rescheduled till next batch window start Date nextRun = getNextRunWithinBatchWindow(ClockUtil.getCurrentTime()); assertTrue(jobEntity.getDuedate().equals(nextRun)); assertTrue(nextRun.after(ClockUtil.getCurrentTime())); //countEmptyRuns canceled assertEquals(0, configuration.getCountEmptyRuns()); //nothing was removed assertResult(5); }
@Test public void testLessThanThresholdOutsideBatchWindowBeforeMidnight() { //given prepareData(5); //we're outside batch window, batch window passes midnight Date date = new Date(); ClockUtil.setCurrentTime(DateUtils.setMinutes(DateUtils.setHours(date, 22), 10)); //22:10 processEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00"); processEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00"); processEngineConfiguration.initHistoryCleanup(); //when String jobId = historyService.cleanUpHistoryAsync().getId(); managementService.executeJob(jobId); //then JobEntity jobEntity = getJobEntity(jobId); HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity); //job rescheduled till next batch window start Date nextRun = getNextRunWithinBatchWindow(ClockUtil.getCurrentTime()); assertTrue(jobEntity.getDuedate().equals(nextRun)); assertTrue(nextRun.after(ClockUtil.getCurrentTime())); //countEmptyRuns cancelled assertEquals(0, configuration.getCountEmptyRuns()); //nothing was removed assertResult(5); }