Search in sources :

Example 1 with CleanableHistoricProcessInstanceReport

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

Example 2 with CleanableHistoricProcessInstanceReport

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

the class HistoricProcessDefinitionRestServiceImpl method getCleanableHistoricProcessInstanceReportCount.

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

Example 3 with CleanableHistoricProcessInstanceReport

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

the class CleanableHistoricProcessInstanceReportTest method testReportByInvalidProcessDefinitionId.

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

Example 4 with CleanableHistoricProcessInstanceReport

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

Example 5 with CleanableHistoricProcessInstanceReport

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

the class CleanableHistoricProcessInstanceReportTest method testReportByInvalidProcessDefinitionKey.

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

Aggregations

CleanableHistoricProcessInstanceReport (org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReport)5 NotValidException (org.camunda.bpm.engine.exception.NotValidException)2 CleanableHistoricProcessInstanceReportResult (org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReportResult)2 CleanableHistoricProcessInstanceReportDto (org.camunda.bpm.engine.rest.dto.history.CleanableHistoricProcessInstanceReportDto)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1