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();
}
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;
}
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;
}
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;
}
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());
}
Aggregations