private BatchWindow getBatchWindowForDate(Date date, ProcessEngineConfigurationImpl configuration) { //get configuration for given day of week BatchWindowConfiguration batchWindowConfiguration = configuration.getHistoryCleanupBatchWindows().get(dayOfWeek(date)); if (batchWindowConfiguration == null && configuration.getHistoryCleanupBatchWindowStartTime() != null) { batchWindowConfiguration = new BatchWindowConfiguration(configuration.getHistoryCleanupBatchWindowStartTime(), configuration.getHistoryCleanupBatchWindowEndTime()); } if (batchWindowConfiguration == null) { return null; } Date startTime = updateTime(date, batchWindowConfiguration.getStartTimeAsDate()); Date endTime = updateTime(date, batchWindowConfiguration.getEndTimeAsDate()); if (!endTime.after(startTime)) { endTime = addDays(endTime, 1); } return new BatchWindow(startTime, endTime); }
private BatchWindow getBatchWindowForDate(Date date, ProcessEngineConfigurationImpl configuration) { //get configuration for given day of week BatchWindowConfiguration batchWindowConfiguration = configuration.getHistoryCleanupBatchWindows().get(dayOfWeek(date)); if (batchWindowConfiguration == null && configuration.getHistoryCleanupBatchWindowStartTime() != null) { batchWindowConfiguration = new BatchWindowConfiguration(configuration.getHistoryCleanupBatchWindowStartTime(), configuration.getHistoryCleanupBatchWindowEndTime()); } if (batchWindowConfiguration == null) { return null; } Date startTime = updateTime(date, batchWindowConfiguration.getStartTimeAsDate()); Date endTime = updateTime(date, batchWindowConfiguration.getEndTimeAsDate()); if (!endTime.after(startTime)) { endTime = addDays(endTime, 1); } return new BatchWindow(startTime, endTime); }
@Test public void testHistoryConfigurationWhenBatchNotDefined() { ProcessEngineConfigurationImpl processEngineConfigurationImplMock = mock(ProcessEngineConfigurationImpl.class); when(processEngine.getProcessEngineConfiguration()).thenReturn(processEngineConfigurationImplMock); when(processEngineConfigurationImplMock.getHistoryCleanupBatchWindowStartTime()).thenReturn(null); when(processEngineConfigurationImplMock.getHistoryCleanupBatchWindowEndTime()).thenReturn(null); when(processEngineConfigurationImplMock.getBatchWindowManager()).thenReturn(new DefaultBatchWindowManager()); given() .contentType(ContentType.JSON) .then().expect() .statusCode(Status.OK.getStatusCode()) .body("batchWindowStartTime", equalTo(null)) .body("batchWindowEndTime", equalTo(null)) .when() .get(CONFIGURATION_URL); }
@Test public void testHistoryConfigurationOutsideBatchWindow() throws ParseException { ProcessEngineConfigurationImpl processEngineConfigurationImplMock = mock(ProcessEngineConfigurationImpl.class); Date startDate = HistoryCleanupHelper.parseTimeConfiguration("23:59+0200"); Date endDate = HistoryCleanupHelper.parseTimeConfiguration("00:00+0200"); when(processEngine.getProcessEngineConfiguration()).thenReturn(processEngineConfigurationImplMock); when(processEngineConfigurationImplMock.getHistoryCleanupBatchWindowStartTime()).thenReturn("23:59+0200"); when(processEngineConfigurationImplMock.getHistoryCleanupBatchWindowEndTime()).thenReturn("00:00+0200"); when(processEngineConfigurationImplMock.getBatchWindowManager()).thenReturn(new DefaultBatchWindowManager()); SimpleDateFormat sdf = new SimpleDateFormat(JacksonConfigurator.dateFormatString); Date now = sdf.parse("2017-09-01T22:00:00.000+0200"); ClockUtil.setCurrentTime(now); Calendar today = Calendar.getInstance(); today.setTime(now); Calendar tomorrow = Calendar.getInstance(); tomorrow.setTime(DateTimeUtils.addDays(now, 1)); Date dateToday = DateTimeUtils.updateTime(today.getTime(), startDate); Date dateTomorrow = DateTimeUtils.updateTime(tomorrow.getTime(), endDate); given() .contentType(ContentType.JSON) .then().expect() .statusCode(Status.OK.getStatusCode()) .body("batchWindowStartTime", containsString(sdf.format(dateToday))) .body("batchWindowEndTime", containsString(sdf.format(dateTomorrow))) .when() .get(CONFIGURATION_URL); }
@Test public void testHistoryConfigurationWithinBatchWindow() throws ParseException { ProcessEngineConfigurationImpl processEngineConfigurationImplMock = mock(ProcessEngineConfigurationImpl.class); Date startDate = HistoryCleanupHelper.parseTimeConfiguration("22:00+0200"); Date endDate = HistoryCleanupHelper.parseTimeConfiguration("23:00+0200"); when(processEngine.getProcessEngineConfiguration()).thenReturn(processEngineConfigurationImplMock); when(processEngineConfigurationImplMock.getHistoryCleanupBatchWindowStartTime()).thenReturn("22:00+0200"); when(processEngineConfigurationImplMock.getHistoryCleanupBatchWindowEndTime()).thenReturn("23:00+0200"); when(processEngineConfigurationImplMock.getBatchWindowManager()).thenReturn(new DefaultBatchWindowManager()); SimpleDateFormat sdf = new SimpleDateFormat(JacksonConfigurator.dateFormatString); Date now = sdf.parse("2017-09-01T22:00:00.000+0200"); ClockUtil.setCurrentTime(now); Calendar today = Calendar.getInstance(); today.setTime(now); Date dateToday = DateTimeUtils.updateTime(today.getTime(), startDate); Date dateTomorrow = DateTimeUtils.updateTime(today.getTime(), endDate); given() .contentType(ContentType.JSON) .then().expect() .statusCode(Status.OK.getStatusCode()) .body("batchWindowStartTime", containsString(sdf.format(dateToday))) .body("batchWindowEndTime", containsString(sdf.format(dateTomorrow))) .when() .get(CONFIGURATION_URL); }
@Before public void init() { historyService = engineRule.getHistoryService(); processEngineConfiguration = engineRule.getProcessEngineConfiguration(); managementService = engineRule.getManagementService(); defaultStartTime = processEngineConfiguration.getHistoryCleanupBatchWindowStartTime(); defaultEndTime = processEngineConfiguration.getHistoryCleanupBatchWindowEndTime(); defaultBatchSize = processEngineConfiguration.getHistoryCleanupBatchSize(); }
@Before public void init() { historyService = engineRule.getHistoryService(); processEngineConfiguration = engineRule.getProcessEngineConfiguration(); managementService = engineRule.getManagementService(); defaultStartTime = processEngineConfiguration.getHistoryCleanupBatchWindowStartTime(); defaultEndTime = processEngineConfiguration.getHistoryCleanupBatchWindowEndTime(); defaultBatchSize = processEngineConfiguration.getHistoryCleanupBatchSize(); }
@Before public void init() { runtimeService = engineRule.getRuntimeService(); historyService = engineRule.getHistoryService(); managementService = engineRule.getManagementService(); caseService = engineRule.getCaseService(); repositoryService = engineRule.getRepositoryService(); processEngineConfiguration = engineRule.getProcessEngineConfiguration(); testRule.deploy("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/dmn/Example.dmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithHistoryTimeToLive.cmmn"); defaultStartTime = processEngineConfiguration.getHistoryCleanupBatchWindowStartTime(); defaultEndTime = processEngineConfiguration.getHistoryCleanupBatchWindowEndTime(); defaultBatchSize = processEngineConfiguration.getHistoryCleanupBatchSize(); processEngineConfiguration.setHistoryCleanupStrategy(HISTORY_CLEANUP_STRATEGY_END_TIME_BASED); }
protected void clearDatabase() { String defaultEndTime = processEngineConfiguration.getHistoryCleanupBatchWindowEndTime(); int defaultBatchSize = processEngineConfiguration.getHistoryCleanupBatchSize();
private BatchWindow getBatchWindowForDate(Date date, ProcessEngineConfigurationImpl configuration) { //get configuration for given day of week BatchWindowConfiguration batchWindowConfiguration = configuration.getHistoryCleanupBatchWindows().get(dayOfWeek(date)); if (batchWindowConfiguration == null && configuration.getHistoryCleanupBatchWindowStartTime() != null) { batchWindowConfiguration = new BatchWindowConfiguration(configuration.getHistoryCleanupBatchWindowStartTime(), configuration.getHistoryCleanupBatchWindowEndTime()); } if (batchWindowConfiguration == null) { return null; } Date startTime = updateTime(date, batchWindowConfiguration.getStartTimeAsDate()); Date endTime = updateTime(date, batchWindowConfiguration.getEndTimeAsDate()); if (!endTime.after(startTime)) { endTime = addDays(endTime, 1); } return new BatchWindow(startTime, endTime); }
@Before public void init() { historyService = engineRule.getHistoryService(); processEngineConfiguration = engineRule.getProcessEngineConfiguration(); managementService = engineRule.getManagementService(); defaultStartTime = processEngineConfiguration.getHistoryCleanupBatchWindowStartTime(); defaultEndTime = processEngineConfiguration.getHistoryCleanupBatchWindowEndTime(); defaultBatchSize = processEngineConfiguration.getHistoryCleanupBatchSize(); }
@Before public void init() { historyService = engineRule.getHistoryService(); processEngineConfiguration = engineRule.getProcessEngineConfiguration(); managementService = engineRule.getManagementService(); defaultStartTime = processEngineConfiguration.getHistoryCleanupBatchWindowStartTime(); defaultEndTime = processEngineConfiguration.getHistoryCleanupBatchWindowEndTime(); defaultBatchSize = processEngineConfiguration.getHistoryCleanupBatchSize(); }
@Before public void init() { runtimeService = engineRule.getRuntimeService(); historyService = engineRule.getHistoryService(); managementService = engineRule.getManagementService(); caseService = engineRule.getCaseService(); repositoryService = engineRule.getRepositoryService(); processEngineConfiguration = engineRule.getProcessEngineConfiguration(); testRule.deploy("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/dmn/Example.dmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithHistoryTimeToLive.cmmn"); defaultStartTime = processEngineConfiguration.getHistoryCleanupBatchWindowStartTime(); defaultEndTime = processEngineConfiguration.getHistoryCleanupBatchWindowEndTime(); defaultBatchSize = processEngineConfiguration.getHistoryCleanupBatchSize(); processEngineConfiguration.setHistoryCleanupStrategy(HISTORY_CLEANUP_STRATEGY_END_TIME_BASED); }
protected void clearDatabase() { String defaultEndTime = processEngineConfiguration.getHistoryCleanupBatchWindowEndTime(); int defaultBatchSize = processEngineConfiguration.getHistoryCleanupBatchSize();