use of org.camunda.bpm.engine.history.DurationReportResult in project camunda-bpm-platform by camunda.
the class HistoricTaskDurationReportTest method testHistoricTaskInstanceDurationReportWithCompletedAfterDate.
@Test
public void testHistoricTaskInstanceDurationReportWithCompletedAfterDate() {
// given
startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 7, 14, 11, 43);
startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 8, 14, 11, 43);
startAndCompleteProcessInstance(ANOTHER_PROCESS_DEFINITION_KEY, 2016, 7, 14, 11, 43);
// when
Calendar calendar = Calendar.getInstance();
calendar.set(2016, 11, 14, 12, 5);
List<DurationReportResult> taskReportResults = historyService.createHistoricTaskInstanceReport().completedAfter(calendar.getTime()).duration(PeriodUnit.MONTH);
// then
assertEquals(1, taskReportResults.size());
}
use of org.camunda.bpm.engine.history.DurationReportResult in project camunda-bpm-platform by camunda.
the class HistoricTaskDurationReportTest method testHistoricTaskInstanceDurationReportWithCompletedBeforeDate.
@Test
public void testHistoricTaskInstanceDurationReportWithCompletedBeforeDate() {
// given
startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 7, 14, 11, 43);
startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 8, 14, 11, 43);
startAndCompleteProcessInstance(ANOTHER_PROCESS_DEFINITION_KEY, 2016, 6, 14, 11, 43);
// when
Calendar calendar = Calendar.getInstance();
calendar.set(2016, 11, 14, 12, 5);
List<DurationReportResult> taskReportResults = historyService.createHistoricTaskInstanceReport().completedBefore(calendar.getTime()).duration(PeriodUnit.MONTH);
// then
assertEquals(2, taskReportResults.size());
}
use of org.camunda.bpm.engine.history.DurationReportResult in project camunda-bpm-platform by camunda.
the class MockProvider method createMockHistoricProcessInstanceDurationReportByMonth.
public static List<DurationReportResult> createMockHistoricProcessInstanceDurationReportByMonth() {
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.MONTH);
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 MockProvider method createMockHistoricTaskInstanceDurationReport.
public static List<DurationReportResult> createMockHistoricTaskInstanceDurationReport(PeriodUnit periodUnit) {
DurationReportResult mock = mock(DurationReportResult.class);
when(mock.getAverage()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_DURATION_REPORT_AVG);
when(mock.getMinimum()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_DURATION_REPORT_MIN);
when(mock.getMaximum()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_DURATION_REPORT_MAX);
when(mock.getPeriod()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_DURATION_REPORT_PERIOD);
when(mock.getPeriodUnit()).thenReturn(periodUnit);
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 testReportWithQueryCriterionProcessDefinitionIdInAndReadHistoryPermission.
public void testReportWithQueryCriterionProcessDefinitionIdInAndReadHistoryPermission() {
// 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, PROCESS_KEY, userId, READ_HISTORY);
createGrantAuthorization(PROCESS_DEFINITION, MESSAGE_START_PROCESS_KEY, userId, READ_HISTORY);
// when
List<DurationReportResult> result = historyService.createHistoricProcessInstanceReport().processDefinitionIdIn(processInstance1.getProcessDefinitionId(), processInstance2.getProcessDefinitionId()).duration(PeriodUnit.MONTH);
// then
assertEquals(1, result.size());
}
Aggregations