Search in sources :

Example 1 with CleanableHistoricDecisionInstanceReport

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

the class CleanableHistoricDecisionInstanceReportServiceTest method setupHistoryReportMock.

private void setupHistoryReportMock() {
    CleanableHistoricDecisionInstanceReport report = mock(CleanableHistoricDecisionInstanceReport.class);
    when(report.decisionDefinitionIdIn(anyString())).thenReturn(report);
    when(report.decisionDefinitionKeyIn(anyString())).thenReturn(report);
    CleanableHistoricDecisionInstanceReportResult reportResult = mock(CleanableHistoricDecisionInstanceReportResult.class);
    when(reportResult.getDecisionDefinitionId()).thenReturn(EXAMPLE_DD_ID);
    when(reportResult.getDecisionDefinitionKey()).thenReturn(EXAMPLE_DD_KEY);
    when(reportResult.getDecisionDefinitionName()).thenReturn(EXAMPLE_DD_NAME);
    when(reportResult.getDecisionDefinitionVersion()).thenReturn(EXAMPLE_DD_VERSION);
    when(reportResult.getHistoryTimeToLive()).thenReturn(EXAMPLE_TTL);
    when(reportResult.getFinishedDecisionInstanceCount()).thenReturn(EXAMPLE_FINISHED_DI_COUNT);
    when(reportResult.getCleanableDecisionInstanceCount()).thenReturn(EXAMPLE_CLEANABLE_DI_COUNT);
    when(reportResult.getTenantId()).thenReturn(EXAMPLE_TENANT_ID);
    CleanableHistoricDecisionInstanceReportResult anotherReportResult = mock(CleanableHistoricDecisionInstanceReportResult.class);
    when(anotherReportResult.getDecisionDefinitionId()).thenReturn(ANOTHER_EXAMPLE_DD_ID);
    when(anotherReportResult.getDecisionDefinitionKey()).thenReturn(ANOTHER_EXAMPLE_DD_KEY);
    when(anotherReportResult.getDecisionDefinitionName()).thenReturn("dpName");
    when(anotherReportResult.getDecisionDefinitionVersion()).thenReturn(33);
    when(anotherReportResult.getHistoryTimeToLive()).thenReturn(5);
    when(anotherReportResult.getFinishedDecisionInstanceCount()).thenReturn(10l);
    when(anotherReportResult.getCleanableDecisionInstanceCount()).thenReturn(0l);
    when(anotherReportResult.getTenantId()).thenReturn(ANOTHER_EXAMPLE_TENANT_ID);
    List<CleanableHistoricDecisionInstanceReportResult> mocks = new ArrayList<CleanableHistoricDecisionInstanceReportResult>();
    mocks.add(reportResult);
    mocks.add(anotherReportResult);
    when(report.list()).thenReturn(mocks);
    when(report.count()).thenReturn((long) mocks.size());
    historicDecisionInstanceReport = report;
    when(processEngine.getHistoryService().createCleanableHistoricDecisionInstanceReport()).thenReturn(historicDecisionInstanceReport);
}
Also used : CleanableHistoricDecisionInstanceReport(org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReport) CleanableHistoricDecisionInstanceReportResult(org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReportResult) ArrayList(java.util.ArrayList)

Example 2 with CleanableHistoricDecisionInstanceReport

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

the class HistoricDecisionDefinitionRestServiceImpl method getCleanableHistoricDecisionInstanceReportCount.

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

Example 3 with CleanableHistoricDecisionInstanceReport

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

the class HistoricDecisionDefinitionRestServiceImpl method getCleanableHistoricDecisionInstanceReport.

@Override
public List<CleanableHistoricDecisionInstanceReportResultDto> getCleanableHistoricDecisionInstanceReport(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
    CleanableHistoricDecisionInstanceReportDto queryDto = new CleanableHistoricDecisionInstanceReportDto(objectMapper, uriInfo.getQueryParameters());
    CleanableHistoricDecisionInstanceReport query = queryDto.toQuery(processEngine);
    List<CleanableHistoricDecisionInstanceReportResult> reportResult;
    if (firstResult != null || maxResults != null) {
        reportResult = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        reportResult = query.list();
    }
    return CleanableHistoricDecisionInstanceReportResultDto.convert(reportResult);
}
Also used : CleanableHistoricDecisionInstanceReport(org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReport) CleanableHistoricDecisionInstanceReportDto(org.camunda.bpm.engine.rest.dto.history.CleanableHistoricDecisionInstanceReportDto) CleanableHistoricDecisionInstanceReportResult(org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReportResult)

Example 4 with CleanableHistoricDecisionInstanceReport

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

the class CleanableHistoricDecisionInstanceReportTest method testReportByInvalidDecisionDefinitionId.

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

Example 5 with CleanableHistoricDecisionInstanceReport

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

the class CleanableHistoricDecisionInstanceReportTest method testReportByInvalidDecisionDefinitionKey.

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

Aggregations

CleanableHistoricDecisionInstanceReport (org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReport)5 NotValidException (org.camunda.bpm.engine.exception.NotValidException)2 CleanableHistoricDecisionInstanceReportResult (org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReportResult)2 CleanableHistoricDecisionInstanceReportDto (org.camunda.bpm.engine.rest.dto.history.CleanableHistoricDecisionInstanceReportDto)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1