use of org.camunda.bpm.engine.history.CleanableHistoricBatchReportResult in project camunda-bpm-platform by camunda.
the class CleanableHistoricBatchReportResultDto method convert.
public static List<CleanableHistoricBatchReportResultDto> convert(List<CleanableHistoricBatchReportResult> reportResult) {
List<CleanableHistoricBatchReportResultDto> dtos = new ArrayList<CleanableHistoricBatchReportResultDto>();
for (CleanableHistoricBatchReportResult current : reportResult) {
CleanableHistoricBatchReportResultDto dto = new CleanableHistoricBatchReportResultDto();
dto.setBatchType(current.getBatchType());
dto.setHistoryTimeToLive(current.getHistoryTimeToLive());
dto.setFinishedBatchesCount(current.getFinishedBatchesCount());
dto.setCleanableBatchesCount(current.getCleanableBatchesCount());
dtos.add(dto);
}
return dtos;
}
use of org.camunda.bpm.engine.history.CleanableHistoricBatchReportResult in project camunda-bpm-platform by camunda.
the class HistoricBatchQueryAuthorizationTest method testHistoryCleanupReportQueryWithPermissions.
@Test
public void testHistoryCleanupReportQueryWithPermissions() {
// given
authRule.createGrantAuthorization(Resources.BATCH, "*", "user", Permissions.READ_HISTORY);
String migrationOperationsTTL = "P0D";
prepareBatch(migrationOperationsTTL);
authRule.enableAuthorization("user");
CleanableHistoricBatchReportResult result = engineRule.getHistoryService().createCleanableHistoricBatchReport().singleResult();
authRule.disableAuthorization();
assertNotNull(result);
checkResultNumbers(result, 1, 1, 0);
}
use of org.camunda.bpm.engine.history.CleanableHistoricBatchReportResult in project camunda-bpm-platform by camunda.
the class CleanableHistoricBatchReportTest method testReportMixedConfiguration.
@Test
public void testReportMixedConfiguration() {
Map<String, String> map = new HashMap<String, String>();
int modOperationsTTL = 20;
map.put("instance-modification", "P20D");
int defaultTTL = 5;
processEngineConfiguration.setBatchOperationHistoryTimeToLive("P5D");
processEngineConfiguration.setBatchOperationsForHistoryCleanup(map);
processEngineConfiguration.initHistoryCleanup();
Date startDate = new Date();
int daysInThePast = -11;
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, daysInThePast));
Batch modificationBatch = createModificationBatch();
List<String> batchIds = new ArrayList<String>();
batchIds.add(modificationBatch.getId());
int migrationCountBatch = 10;
List<String> batchIds1 = new ArrayList<String>();
batchIds1.addAll(createMigrationBatchList(migrationCountBatch));
int cancelationCountBatch = 20;
List<String> batchIds2 = new ArrayList<String>();
batchIds2.addAll(createCancelationBatchList(cancelationCountBatch));
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -8));
for (String batchId : batchIds) {
managementService.deleteBatch(batchId, false);
}
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -2));
for (int i = 0; i < 4; i++) {
managementService.deleteBatch(batchIds1.get(i), false);
}
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -7));
for (int i = 6; i < batchIds1.size(); i++) {
managementService.deleteBatch(batchIds1.get(i), false);
}
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -10));
for (int i = 0; i < 7; i++) {
managementService.deleteBatch(batchIds2.get(i), false);
}
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -5));
for (int i = 7; i < 11; i++) {
managementService.deleteBatch(batchIds2.get(i), false);
}
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -1));
for (int i = 13; i < batchIds2.size(); i++) {
managementService.deleteBatch(batchIds2.get(i), false);
}
ClockUtil.setCurrentTime(DateUtils.addSeconds(startDate, 1));
// when
List<HistoricBatch> historicList = historyService.createHistoricBatchQuery().list();
assertEquals(31, historicList.size());
List<CleanableHistoricBatchReportResult> list = historyService.createCleanableHistoricBatchReport().list();
assertEquals(3, list.size());
for (CleanableHistoricBatchReportResult result : list) {
if (result.getBatchType().equals("instance-migration")) {
checkResultNumbers(result, 4, 8, defaultTTL);
} else if (result.getBatchType().equals("instance-modification")) {
checkResultNumbers(result, 0, 1, modOperationsTTL);
} else if (result.getBatchType().equals("instance-deletion")) {
checkResultNumbers(result, 11, 18, defaultTTL);
}
}
}
use of org.camunda.bpm.engine.history.CleanableHistoricBatchReportResult in project camunda-bpm-platform by camunda.
the class CleanableHistoricBatchReportTest method testReportOrderByFinishedProcessInstance.
@Test
public void testReportOrderByFinishedProcessInstance() {
processEngineConfiguration.setBatchOperationHistoryTimeToLive("P5D");
processEngineConfiguration.initHistoryCleanup();
assertNotNull(processEngineConfiguration.getBatchOperationHistoryTimeToLive());
Date startDate = new Date();
int daysInThePast = -11;
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, daysInThePast));
List<String> batchIds = new ArrayList<String>();
Batch modificationBatch = createModificationBatch();
batchIds.add(modificationBatch.getId());
int migrationCountBatch = 10;
batchIds.addAll(createMigrationBatchList(migrationCountBatch));
int cancelationCountBatch = 20;
batchIds.addAll(createCancelationBatchList(cancelationCountBatch));
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -8));
for (String batchId : batchIds) {
managementService.deleteBatch(batchId, false);
}
ClockUtil.setCurrentTime(DateUtils.addSeconds(startDate, 1));
// assume
List<HistoricBatch> historicList = historyService.createHistoricBatchQuery().list();
assertEquals(31, historicList.size());
// then
List<CleanableHistoricBatchReportResult> reportResultAsc = historyService.createCleanableHistoricBatchReport().orderByFinishedBatchOperation().asc().list();
assertEquals(3, reportResultAsc.size());
assertEquals("instance-modification", reportResultAsc.get(0).getBatchType());
assertEquals("instance-migration", reportResultAsc.get(1).getBatchType());
assertEquals("instance-deletion", reportResultAsc.get(2).getBatchType());
List<CleanableHistoricBatchReportResult> reportResultDesc = historyService.createCleanableHistoricBatchReport().orderByFinishedBatchOperation().desc().list();
assertEquals(3, reportResultDesc.size());
assertEquals("instance-deletion", reportResultDesc.get(0).getBatchType());
assertEquals("instance-migration", reportResultDesc.get(1).getBatchType());
assertEquals("instance-modification", reportResultDesc.get(2).getBatchType());
}
use of org.camunda.bpm.engine.history.CleanableHistoricBatchReportResult in project camunda-bpm-platform by camunda.
the class CleanableHistoricBatchReportTest method testReportZeroTTL.
@Test
public void testReportZeroTTL() {
Map<String, String> map = new HashMap<String, String>();
int modOperationsTTL = 0;
map.put("instance-modification", "P0D");
processEngineConfiguration.setBatchOperationsForHistoryCleanup(map);
processEngineConfiguration.initHistoryCleanup();
Date startDate = ClockUtil.getCurrentTime();
int daysInThePast = -11;
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, daysInThePast));
Batch modificationBatch = createModificationBatch();
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -7));
managementService.deleteBatch(modificationBatch.getId(), false);
CleanableHistoricBatchReportResult result = historyService.createCleanableHistoricBatchReport().singleResult();
assertNotNull(result);
checkResultNumbers(result, 1, 1, modOperationsTTL);
}
Aggregations