Search in sources :

Example 1 with CleanableHistoricCaseInstanceReport

use of org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport 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);
}
Also used : CleanableHistoricCaseInstanceReportDto(org.camunda.bpm.engine.rest.dto.history.CleanableHistoricCaseInstanceReportDto) CleanableHistoricCaseInstanceReportResult(org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReportResult) CleanableHistoricCaseInstanceReport(org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport)

Example 2 with CleanableHistoricCaseInstanceReport

use of org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport in project camunda-bpm-platform by camunda.

the class CleanableHistoricCaseInstanceReportTest method testReportByInvalidCaseDefinitionKey.

@Test
public void testReportByInvalidCaseDefinitionKey() {
    CleanableHistoricCaseInstanceReport report = historyService.createCleanableHistoricCaseInstanceReport();
    try {
        report.caseDefinitionKeyIn(null);
        fail("Expected NotValidException");
    } catch (NotValidException e) {
    // expected
    }
    try {
        report.caseDefinitionKeyIn("abc", null, "def");
        fail("Expected NotValidException");
    } catch (NotValidException e) {
    // expected
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) CleanableHistoricCaseInstanceReport(org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport) Test(org.junit.Test)

Example 3 with CleanableHistoricCaseInstanceReport

use of org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport in project camunda-bpm-platform by camunda.

the class CleanableHistoricCaseInstanceReportTest method testReportByInvalidCaseDefinitionId.

@Test
public void testReportByInvalidCaseDefinitionId() {
    CleanableHistoricCaseInstanceReport report = historyService.createCleanableHistoricCaseInstanceReport();
    try {
        report.caseDefinitionIdIn(null);
        fail("Expected NotValidException");
    } catch (NotValidException e) {
    // expected
    }
    try {
        report.caseDefinitionIdIn("abc", null, "def");
        fail("Expected NotValidException");
    } catch (NotValidException e) {
    // expected
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) CleanableHistoricCaseInstanceReport(org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport) Test(org.junit.Test)

Example 4 with CleanableHistoricCaseInstanceReport

use of org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport 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);
}
Also used : ArrayList(java.util.ArrayList) CleanableHistoricCaseInstanceReportResult(org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReportResult) CleanableHistoricCaseInstanceReport(org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport)

Example 5 with CleanableHistoricCaseInstanceReport

use of org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport in project camunda-bpm-platform by camunda.

the class HistoricCaseDefinitionRestServiceImpl method getCleanableHistoricCaseInstanceReportCount.

@Override
public CountResultDto getCleanableHistoricCaseInstanceReportCount(UriInfo uriInfo) {
    CleanableHistoricCaseInstanceReportDto queryDto = new CleanableHistoricCaseInstanceReportDto(objectMapper, uriInfo.getQueryParameters());
    queryDto.setObjectMapper(objectMapper);
    CleanableHistoricCaseInstanceReport query = queryDto.toQuery(processEngine);
    long count = query.count();
    CountResultDto result = new CountResultDto();
    result.setCount(count);
    return result;
}
Also used : CleanableHistoricCaseInstanceReportDto(org.camunda.bpm.engine.rest.dto.history.CleanableHistoricCaseInstanceReportDto) CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) CleanableHistoricCaseInstanceReport(org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport)

Aggregations

CleanableHistoricCaseInstanceReport (org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport)5 NotValidException (org.camunda.bpm.engine.exception.NotValidException)2 CleanableHistoricCaseInstanceReportResult (org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReportResult)2 CleanableHistoricCaseInstanceReportDto (org.camunda.bpm.engine.rest.dto.history.CleanableHistoricCaseInstanceReportDto)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1