Search in sources :

Example 1 with CleanableHistoricDecisionInstanceReportResult

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

the class CleanableHistoricDecisionInstanceReportResultDto method convert.

public static List<CleanableHistoricDecisionInstanceReportResultDto> convert(List<CleanableHistoricDecisionInstanceReportResult> reportResult) {
    List<CleanableHistoricDecisionInstanceReportResultDto> dtos = new ArrayList<CleanableHistoricDecisionInstanceReportResultDto>();
    for (CleanableHistoricDecisionInstanceReportResult current : reportResult) {
        CleanableHistoricDecisionInstanceReportResultDto dto = new CleanableHistoricDecisionInstanceReportResultDto();
        dto.setDecisionDefinitionId(current.getDecisionDefinitionId());
        dto.setDecisionDefinitionKey(current.getDecisionDefinitionKey());
        dto.setDecisionDefinitionName(current.getDecisionDefinitionName());
        dto.setDecisionDefinitionVersion(current.getDecisionDefinitionVersion());
        dto.setHistoryTimeToLive(current.getHistoryTimeToLive());
        dto.setFinishedDecisionInstanceCount(current.getFinishedDecisionInstanceCount());
        dto.setCleanableDecisionInstanceCount(current.getCleanableDecisionInstanceCount());
        dto.setTenantId(current.getTenantId());
        dtos.add(dto);
    }
    return dtos;
}
Also used : ArrayList(java.util.ArrayList) CleanableHistoricDecisionInstanceReportResult(org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReportResult)

Example 2 with CleanableHistoricDecisionInstanceReportResult

use of org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReportResult 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 3 with CleanableHistoricDecisionInstanceReportResult

use of org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReportResult 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 CleanableHistoricDecisionInstanceReportResult

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

the class CleanableHistoricDecisionInstanceReportTest method testReportComplex.

@Test
public void testReportComplex() {
    // given
    testRule.deploy("org/camunda/bpm/engine/test/repository/two.dmn", "org/camunda/bpm/engine/test/api/dmn/Another_Example.dmn", "org/camunda/bpm/engine/test/api/dmn/Example.dmn");
    prepareDecisionInstances(DECISION_DEFINITION_KEY, 0, 5, 10);
    prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 5, 10);
    prepareDecisionInstances(SECOND_DECISION_DEFINITION_KEY, -6, null, 10);
    prepareDecisionInstances(THIRD_DECISION_DEFINITION_KEY, -6, 5, 10);
    // when
    List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list();
    String secondDecisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(SECOND_DECISION_DEFINITION_KEY).singleResult().getId();
    CleanableHistoricDecisionInstanceReportResult secondReportResult = historyService.createCleanableHistoricDecisionInstanceReport().decisionDefinitionIdIn(secondDecisionDefinitionId).singleResult();
    CleanableHistoricDecisionInstanceReportResult thirdReportResult = historyService.createCleanableHistoricDecisionInstanceReport().decisionDefinitionKeyIn(THIRD_DECISION_DEFINITION_KEY).singleResult();
    // then
    assertEquals(4, reportResults.size());
    for (CleanableHistoricDecisionInstanceReportResult result : reportResults) {
        if (result.getDecisionDefinitionKey().equals(DECISION_DEFINITION_KEY)) {
            checkResultNumbers(result, 10, 20);
        } else if (result.getDecisionDefinitionKey().equals(SECOND_DECISION_DEFINITION_KEY)) {
            checkResultNumbers(result, 0, 10);
        } else if (result.getDecisionDefinitionKey().equals(THIRD_DECISION_DEFINITION_KEY)) {
            checkResultNumbers(result, 10, 10);
        } else if (result.getDecisionDefinitionKey().equals(FOURTH_DECISION_DEFINITION_KEY)) {
            checkResultNumbers(result, 0, 0);
        }
    }
    checkResultNumbers(secondReportResult, 0, 10);
    checkResultNumbers(thirdReportResult, 10, 10);
}
Also used : CleanableHistoricDecisionInstanceReportResult(org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReportResult) Test(org.junit.Test)

Aggregations

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