Search in sources :

Example 1 with DurationReportResult

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

the class ReportResultToCsvConverter method convertDurationReportResult.

protected static String convertDurationReportResult(List<ReportResult> reports) {
    StringBuffer buffer = new StringBuffer();
    buffer.append(DURATION_HEADER);
    for (ReportResult report : reports) {
        DurationReportResult durationReport = (DurationReportResult) report;
        buffer.append(NEW_LINE_SEPARATOR);
        buffer.append(durationReport.getPeriod());
        buffer.append(DELIMITER);
        buffer.append(durationReport.getPeriodUnit().toString());
        buffer.append(DELIMITER);
        buffer.append(durationReport.getMinimum());
        buffer.append(DELIMITER);
        buffer.append(durationReport.getMaximum());
        buffer.append(DELIMITER);
        buffer.append(durationReport.getAverage());
    }
    return buffer.toString();
}
Also used : DurationReportResult(org.camunda.bpm.engine.history.DurationReportResult) ReportResult(org.camunda.bpm.engine.history.ReportResult) DurationReportResult(org.camunda.bpm.engine.history.DurationReportResult)

Example 2 with DurationReportResult

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

the class HistoricTaskReportRestServiceTest method setUpMockReportQuery.

private HistoricTaskInstanceReport setUpMockReportQuery() {
    HistoricTaskInstanceReport mockedReportQuery = mock(HistoricTaskInstanceReport.class);
    List<HistoricTaskInstanceReportResult> taskReportResults = createMockHistoricTaskInstanceReport();
    List<HistoricTaskInstanceReportResult> taskReportResultsWithProcDef = createMockHistoricTaskInstanceReportWithProcDef();
    when(mockedReportQuery.completedAfter(any(Date.class))).thenReturn(mockedReportQuery);
    when(mockedReportQuery.completedBefore(any(Date.class))).thenReturn(mockedReportQuery);
    when(mockedReportQuery.countByTaskName()).thenReturn(taskReportResults);
    when(mockedReportQuery.countByProcessDefinitionKey()).thenReturn(taskReportResultsWithProcDef);
    List<DurationReportResult> durationReportByMonth = createMockHistoricTaskInstanceDurationReport(MONTH);
    when(mockedReportQuery.duration(MONTH)).thenReturn(durationReportByMonth);
    List<DurationReportResult> durationReportByQuarter = createMockHistoricTaskInstanceDurationReport(QUARTER);
    when(mockedReportQuery.duration(QUARTER)).thenReturn(durationReportByQuarter);
    when(processEngine.getHistoryService().createHistoricTaskInstanceReport()).thenReturn(mockedReportQuery);
    return mockedReportQuery;
}
Also used : MockProvider.createMockHistoricTaskInstanceReport(org.camunda.bpm.engine.rest.helper.MockProvider.createMockHistoricTaskInstanceReport) HistoricTaskInstanceReport(org.camunda.bpm.engine.history.HistoricTaskInstanceReport) HistoricTaskInstanceReportResult(org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult) DurationReportResult(org.camunda.bpm.engine.history.DurationReportResult) Date(java.util.Date)

Example 3 with DurationReportResult

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

the class HistoricProcessInstanceRestServiceReportTest method setUpMockHistoricProcessInstanceReportQuery.

private HistoricProcessInstanceReport setUpMockHistoricProcessInstanceReportQuery() {
    HistoricProcessInstanceReport mockedReportQuery = mock(HistoricProcessInstanceReport.class);
    when(mockedReportQuery.processDefinitionIdIn(anyString())).thenReturn(mockedReportQuery);
    when(mockedReportQuery.processDefinitionKeyIn(anyString())).thenReturn(mockedReportQuery);
    when(mockedReportQuery.startedAfter(any(Date.class))).thenReturn(mockedReportQuery);
    when(mockedReportQuery.startedBefore(any(Date.class))).thenReturn(mockedReportQuery);
    List<DurationReportResult> durationReportByMonth = createMockHistoricProcessInstanceDurationReportByMonth();
    when(mockedReportQuery.duration(MONTH)).thenReturn(durationReportByMonth);
    List<DurationReportResult> durationReportByQuarter = createMockHistoricProcessInstanceDurationReportByQuarter();
    when(mockedReportQuery.duration(QUARTER)).thenReturn(durationReportByQuarter);
    when(mockedReportQuery.duration(null)).thenThrow(new NotValidException("periodUnit is null"));
    when(processEngine.getHistoryService().createHistoricProcessInstanceReport()).thenReturn(mockedReportQuery);
    return mockedReportQuery;
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) HistoricProcessInstanceReport(org.camunda.bpm.engine.history.HistoricProcessInstanceReport) DurationReportResult(org.camunda.bpm.engine.history.DurationReportResult) Date(java.util.Date)

Example 4 with DurationReportResult

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

the class MockProvider method createMockHistoricProcessInstanceDurationReportByQuarter.

public static List<DurationReportResult> createMockHistoricProcessInstanceDurationReportByQuarter() {
    DurationReportResult mock = mock(DurationReportResult.class);
    when(mock.getAverage()).thenReturn(EXAMPLE_HISTORIC_PROC_INST_DURATION_REPORT_AVG);
    when(mock.getMinimum()).thenReturn(EXAMPLE_HISTORIC_PROC_INST_DURATION_REPORT_MIN);
    when(mock.getMaximum()).thenReturn(EXAMPLE_HISTORIC_PROC_INST_DURATION_REPORT_MAX);
    when(mock.getPeriod()).thenReturn(EXAMPLE_HISTORIC_PROC_INST_DURATION_REPORT_PERIOD);
    when(mock.getPeriodUnit()).thenReturn(PeriodUnit.QUARTER);
    List<DurationReportResult> mockList = new ArrayList<DurationReportResult>();
    mockList.add(mock);
    return mockList;
}
Also used : ArrayList(java.util.ArrayList) DurationReportResult(org.camunda.bpm.engine.history.DurationReportResult)

Example 5 with DurationReportResult

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

the class HistoricProcessInstanceAuthorizationTest method testReportWithoutQueryCriteriaAndAnyReadHistoryPermission.

public void testReportWithoutQueryCriteriaAndAnyReadHistoryPermission() {
    // given
    ProcessInstance processInstance1 = startProcessInstanceByKey(PROCESS_KEY);
    ProcessInstance processInstance2 = startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    disableAuthorization();
    runtimeService.deleteProcessInstance(processInstance1.getProcessInstanceId(), "");
    runtimeService.deleteProcessInstance(processInstance2.getProcessInstanceId(), "");
    enableAuthorization();
    createGrantAuthorization(PROCESS_DEFINITION, "*", userId, READ_HISTORY);
    // when
    List<DurationReportResult> result = historyService.createHistoricProcessInstanceReport().duration(PeriodUnit.MONTH);
    // then
    assertEquals(1, result.size());
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) DurationReportResult(org.camunda.bpm.engine.history.DurationReportResult)

Aggregations

DurationReportResult (org.camunda.bpm.engine.history.DurationReportResult)21 Calendar (java.util.Calendar)9 Date (java.util.Date)4 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)4 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 NotValidException (org.camunda.bpm.engine.exception.NotValidException)1 HistoricProcessInstanceReport (org.camunda.bpm.engine.history.HistoricProcessInstanceReport)1 HistoricTaskInstance (org.camunda.bpm.engine.history.HistoricTaskInstance)1 HistoricTaskInstanceReport (org.camunda.bpm.engine.history.HistoricTaskInstanceReport)1 HistoricTaskInstanceReportResult (org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult)1 ReportResult (org.camunda.bpm.engine.history.ReportResult)1 MockProvider.createMockHistoricTaskInstanceReport (org.camunda.bpm.engine.rest.helper.MockProvider.createMockHistoricTaskInstanceReport)1