use of org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReportResult in project camunda-bpm-platform by camunda.
the class HistoricProcessDefinitionRestServiceImpl method getCleanableHistoricProcessInstanceReport.
@Override
public List<CleanableHistoricProcessInstanceReportResultDto> getCleanableHistoricProcessInstanceReport(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
CleanableHistoricProcessInstanceReportDto queryDto = new CleanableHistoricProcessInstanceReportDto(objectMapper, uriInfo.getQueryParameters());
CleanableHistoricProcessInstanceReport query = queryDto.toQuery(processEngine);
List<CleanableHistoricProcessInstanceReportResult> reportResult;
if (firstResult != null || maxResults != null) {
reportResult = executePaginatedQuery(query, firstResult, maxResults);
} else {
reportResult = query.list();
}
return CleanableHistoricProcessInstanceReportResultDto.convert(reportResult);
}
use of org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReportResult in project camunda-bpm-platform by camunda.
the class CleanableHistoricProcessInstanceReportTest method testReportComplex.
@Test
public void testReportComplex() {
testRule.deploy(createProcessWithUserTask(SECOND_PROCESS_DEFINITION_KEY));
testRule.deploy(createProcessWithUserTask(THIRD_PROCESS_DEFINITION_KEY));
testRule.deploy(createProcessWithUserTask(FOURTH_PROCESS_DEFINITION_KEY));
// given
prepareProcessInstances(PROCESS_DEFINITION_KEY, 0, 5, 10);
prepareProcessInstances(PROCESS_DEFINITION_KEY, -6, 5, 10);
prepareProcessInstances(SECOND_PROCESS_DEFINITION_KEY, -6, 5, 10);
prepareProcessInstances(THIRD_PROCESS_DEFINITION_KEY, -6, null, 10);
prepareProcessInstances(FOURTH_PROCESS_DEFINITION_KEY, -6, 0, 10);
repositoryService.deleteProcessDefinition(repositoryService.createProcessDefinitionQuery().processDefinitionKey(SECOND_PROCESS_DEFINITION_KEY).singleResult().getId(), false);
// when
List<CleanableHistoricProcessInstanceReportResult> reportResults = historyService.createCleanableHistoricProcessInstanceReport().list();
CleanableHistoricProcessInstanceReportResult secondReportResult = historyService.createCleanableHistoricProcessInstanceReport().processDefinitionIdIn(repositoryService.createProcessDefinitionQuery().processDefinitionKey(THIRD_PROCESS_DEFINITION_KEY).singleResult().getId()).singleResult();
CleanableHistoricProcessInstanceReportResult thirdReportResult = historyService.createCleanableHistoricProcessInstanceReport().processDefinitionKeyIn(FOURTH_PROCESS_DEFINITION_KEY).singleResult();
// then
assertEquals(3, reportResults.size());
for (CleanableHistoricProcessInstanceReportResult result : reportResults) {
if (result.getProcessDefinitionKey().equals(PROCESS_DEFINITION_KEY)) {
checkResultNumbers(result, 10, 20);
} else if (result.getProcessDefinitionKey().equals(THIRD_PROCESS_DEFINITION_KEY)) {
checkResultNumbers(result, 0, 10);
} else if (result.getProcessDefinitionKey().equals(FOURTH_PROCESS_DEFINITION_KEY)) {
checkResultNumbers(result, 10, 10);
}
}
checkResultNumbers(secondReportResult, 0, 10);
checkResultNumbers(thirdReportResult, 10, 10);
}
use of org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReportResult in project camunda-bpm-platform by camunda.
the class CleanableHistoricProcessInstanceReportServiceTest method setupHistoryReportMock.
private void setupHistoryReportMock() {
CleanableHistoricProcessInstanceReport report = mock(CleanableHistoricProcessInstanceReport.class);
when(report.processDefinitionIdIn(anyString())).thenReturn(report);
when(report.processDefinitionKeyIn(anyString())).thenReturn(report);
CleanableHistoricProcessInstanceReportResult reportResult = mock(CleanableHistoricProcessInstanceReportResult.class);
when(reportResult.getProcessDefinitionId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID);
when(reportResult.getProcessDefinitionKey()).thenReturn(EXAMPLE_PD_KEY);
when(reportResult.getProcessDefinitionName()).thenReturn(EXAMPLE_PD_NAME);
when(reportResult.getProcessDefinitionVersion()).thenReturn(EXAMPLE_PD_VERSION);
when(reportResult.getHistoryTimeToLive()).thenReturn(EXAMPLE_TTL);
when(reportResult.getFinishedProcessInstanceCount()).thenReturn(EXAMPLE_FINISHED_PI_COUNT);
when(reportResult.getCleanableProcessInstanceCount()).thenReturn(EXAMPLE_CLEANABLE_PI_COUNT);
when(reportResult.getTenantId()).thenReturn(EXAMPLE_TENANT_ID);
CleanableHistoricProcessInstanceReportResult anotherReportResult = mock(CleanableHistoricProcessInstanceReportResult.class);
when(anotherReportResult.getProcessDefinitionId()).thenReturn(ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID);
when(anotherReportResult.getProcessDefinitionKey()).thenReturn(ANOTHER_EXAMPLE_PD_KEY);
when(anotherReportResult.getProcessDefinitionName()).thenReturn("pdName");
when(anotherReportResult.getProcessDefinitionVersion()).thenReturn(33);
when(anotherReportResult.getHistoryTimeToLive()).thenReturn(null);
when(anotherReportResult.getFinishedProcessInstanceCount()).thenReturn(13l);
when(anotherReportResult.getCleanableProcessInstanceCount()).thenReturn(0l);
when(anotherReportResult.getTenantId()).thenReturn(ANOTHER_EXAMPLE_TENANT_ID);
List<CleanableHistoricProcessInstanceReportResult> mocks = new ArrayList<CleanableHistoricProcessInstanceReportResult>();
mocks.add(reportResult);
mocks.add(anotherReportResult);
when(report.list()).thenReturn(mocks);
when(report.count()).thenReturn((long) mocks.size());
historicProcessInstanceReport = report;
when(processEngine.getHistoryService().createCleanableHistoricProcessInstanceReport()).thenReturn(historicProcessInstanceReport);
}
use of org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReportResult in project camunda-bpm-platform by camunda.
the class CleanableHistoricProcessInstanceReportTest method testReportWithZeroHistoryTTL.
@Test
public void testReportWithZeroHistoryTTL() {
// given
prepareProcessInstances(PROCESS_DEFINITION_KEY, -6, 0, 5);
prepareProcessInstances(PROCESS_DEFINITION_KEY, 0, 0, 5);
// when
CleanableHistoricProcessInstanceReportResult result = historyService.createCleanableHistoricProcessInstanceReport().singleResult();
// then
checkResultNumbers(result, 10, 10);
}
use of org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReportResult in project camunda-bpm-platform by camunda.
the class CleanableHistoricProcessInstanceReportResultDto method convert.
public static List<CleanableHistoricProcessInstanceReportResultDto> convert(List<CleanableHistoricProcessInstanceReportResult> reportResult) {
List<CleanableHistoricProcessInstanceReportResultDto> dtos = new ArrayList<CleanableHistoricProcessInstanceReportResultDto>();
for (CleanableHistoricProcessInstanceReportResult current : reportResult) {
CleanableHistoricProcessInstanceReportResultDto dto = new CleanableHistoricProcessInstanceReportResultDto();
dto.setProcessDefinitionId(current.getProcessDefinitionId());
dto.setProcessDefinitionKey(current.getProcessDefinitionKey());
dto.setProcessDefinitionName(current.getProcessDefinitionName());
dto.setProcessDefinitionVersion(current.getProcessDefinitionVersion());
dto.setHistoryTimeToLive(current.getHistoryTimeToLive());
dto.setFinishedProcessInstanceCount(current.getFinishedProcessInstanceCount());
dto.setCleanableProcessInstanceCount(current.getCleanableProcessInstanceCount());
dto.setTenantId(current.getTenantId());
dtos.add(dto);
}
return dtos;
}
Aggregations