use of org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReportResult in project camunda-bpm-platform by camunda.
the class CleanableHistoricCaseInstanceReportResultDto method convert.
public static List<CleanableHistoricCaseInstanceReportResultDto> convert(List<CleanableHistoricCaseInstanceReportResult> reportResult) {
List<CleanableHistoricCaseInstanceReportResultDto> dtos = new ArrayList<CleanableHistoricCaseInstanceReportResultDto>();
for (CleanableHistoricCaseInstanceReportResult current : reportResult) {
CleanableHistoricCaseInstanceReportResultDto dto = new CleanableHistoricCaseInstanceReportResultDto();
dto.setCaseDefinitionId(current.getCaseDefinitionId());
dto.setCaseDefinitionKey(current.getCaseDefinitionKey());
dto.setCaseDefinitionName(current.getCaseDefinitionName());
dto.setCaseDefinitionVersion(current.getCaseDefinitionVersion());
dto.setHistoryTimeToLive(current.getHistoryTimeToLive());
dto.setFinishedCaseInstanceCount(current.getFinishedCaseInstanceCount());
dto.setCleanableCaseInstanceCount(current.getCleanableCaseInstanceCount());
dto.setTenantId(current.getTenantId());
dtos.add(dto);
}
return dtos;
}
use of org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReportResult in project camunda-bpm-platform by camunda.
the class HistoricCaseDefinitionRestServiceImpl method getCleanableHistoricCaseInstanceReport.
@Override
public List<CleanableHistoricCaseInstanceReportResultDto> getCleanableHistoricCaseInstanceReport(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
CleanableHistoricCaseInstanceReportDto queryDto = new CleanableHistoricCaseInstanceReportDto(objectMapper, uriInfo.getQueryParameters());
CleanableHistoricCaseInstanceReport query = queryDto.toQuery(processEngine);
List<CleanableHistoricCaseInstanceReportResult> reportResult;
if (firstResult != null || maxResults != null) {
reportResult = executePaginatedQuery(query, firstResult, maxResults);
} else {
reportResult = query.list();
}
return CleanableHistoricCaseInstanceReportResultDto.convert(reportResult);
}
use of org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReportResult in project camunda-bpm-platform by camunda.
the class CleanableHistoricCaseInstanceReportTest method testReportComplex.
@Test
public void testReportComplex() {
// given
testRule.deploy("org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithHistoryTimeToLive.cmmn");
prepareCaseInstances(CASE_DEFINITION_KEY, 0, 5, 10);
prepareCaseInstances(CASE_DEFINITION_KEY, -6, 5, 10);
prepareCaseInstances(SECOND_CASE_DEFINITION_KEY, -6, null, 10);
prepareCaseInstances(THIRD_CASE_DEFINITION_KEY, -6, 5, 10);
// when
List<CleanableHistoricCaseInstanceReportResult> reportResults = historyService.createCleanableHistoricCaseInstanceReport().list();
String id = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(SECOND_CASE_DEFINITION_KEY).singleResult().getId();
CleanableHistoricCaseInstanceReportResult secondReportResult = historyService.createCleanableHistoricCaseInstanceReport().caseDefinitionIdIn(id).singleResult();
CleanableHistoricCaseInstanceReportResult thirdReportResult = historyService.createCleanableHistoricCaseInstanceReport().caseDefinitionKeyIn(THIRD_CASE_DEFINITION_KEY).singleResult();
// then
assertEquals(4, reportResults.size());
for (CleanableHistoricCaseInstanceReportResult result : reportResults) {
if (result.getCaseDefinitionKey().equals(CASE_DEFINITION_KEY)) {
checkResultNumbers(result, 10, 20);
} else if (result.getCaseDefinitionKey().equals(SECOND_CASE_DEFINITION_KEY)) {
checkResultNumbers(result, 0, 10);
} else if (result.getCaseDefinitionKey().equals(THIRD_CASE_DEFINITION_KEY)) {
checkResultNumbers(result, 10, 10);
} else if (result.getCaseDefinitionKey().equals(FORTH_CASE_DEFINITION_KEY)) {
checkResultNumbers(result, 0, 0);
}
}
checkResultNumbers(secondReportResult, 0, 10);
checkResultNumbers(thirdReportResult, 10, 10);
}
use of org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReportResult in project camunda-bpm-platform by camunda.
the class CleanableHistoricCaseInstanceReportServiceTest method setupHistoryReportMock.
private void setupHistoryReportMock() {
CleanableHistoricCaseInstanceReport report = mock(CleanableHistoricCaseInstanceReport.class);
when(report.caseDefinitionIdIn(anyString())).thenReturn(report);
when(report.caseDefinitionKeyIn(anyString())).thenReturn(report);
CleanableHistoricCaseInstanceReportResult reportResult = mock(CleanableHistoricCaseInstanceReportResult.class);
when(reportResult.getCaseDefinitionId()).thenReturn(EXAMPLE_CD_ID);
when(reportResult.getCaseDefinitionKey()).thenReturn(EXAMPLE_CD_KEY);
when(reportResult.getCaseDefinitionName()).thenReturn(EXAMPLE_CD_NAME);
when(reportResult.getCaseDefinitionVersion()).thenReturn(EXAMPLE_CD_VERSION);
when(reportResult.getHistoryTimeToLive()).thenReturn(EXAMPLE_TTL);
when(reportResult.getFinishedCaseInstanceCount()).thenReturn(EXAMPLE_FINISHED_CI_COUNT);
when(reportResult.getCleanableCaseInstanceCount()).thenReturn(EXAMPLE_CLEANABLE_CI_COUNT);
when(reportResult.getTenantId()).thenReturn(EXAMPLE_TENANT_ID);
CleanableHistoricCaseInstanceReportResult anotherReportResult = mock(CleanableHistoricCaseInstanceReportResult.class);
when(anotherReportResult.getCaseDefinitionId()).thenReturn(ANOTHER_EXAMPLE_CD_ID);
when(anotherReportResult.getCaseDefinitionKey()).thenReturn(ANOTHER_EXAMPLE_CD_KEY);
when(anotherReportResult.getCaseDefinitionName()).thenReturn("cdName");
when(anotherReportResult.getCaseDefinitionVersion()).thenReturn(33);
when(anotherReportResult.getHistoryTimeToLive()).thenReturn(null);
when(anotherReportResult.getFinishedCaseInstanceCount()).thenReturn(13l);
when(anotherReportResult.getCleanableCaseInstanceCount()).thenReturn(0l);
when(anotherReportResult.getTenantId()).thenReturn(ANOTHER_EXAMPLE_TENANT_ID);
List<CleanableHistoricCaseInstanceReportResult> mocks = new ArrayList<CleanableHistoricCaseInstanceReportResult>();
mocks.add(reportResult);
mocks.add(anotherReportResult);
when(report.list()).thenReturn(mocks);
when(report.count()).thenReturn((long) mocks.size());
historicCaseInstanceReport = report;
when(processEngine.getHistoryService().createCleanableHistoricCaseInstanceReport()).thenReturn(historicCaseInstanceReport);
}
Aggregations