use of org.camunda.bpm.engine.history.DurationReportResult in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceAuthorizationTest method testReportWithMixedQueryCriteriaAndReadHistoryPermission.
public void testReportWithMixedQueryCriteriaAndReadHistoryPermission() {
// 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().processDefinitionKeyIn(PROCESS_KEY).processDefinitionIdIn(processInstance2.getProcessDefinitionId()).duration(PeriodUnit.MONTH);
// then
assertEquals(0, result.size());
}
use of org.camunda.bpm.engine.history.DurationReportResult in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceAuthorizationTest method testReportWithQueryCriterionProcessDefinitionKeyInAndReadHistoryPermission.
public void testReportWithQueryCriterionProcessDefinitionKeyInAndReadHistoryPermission() {
// 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().processDefinitionKeyIn(PROCESS_KEY, MESSAGE_START_PROCESS_KEY).duration(PeriodUnit.MONTH);
// then
assertEquals(1, result.size());
}
use of org.camunda.bpm.engine.history.DurationReportResult in project camunda-bpm-platform by camunda.
the class HistoricTaskDurationReportTest method testHistoricTaskInstanceDurationReportResults.
@Test
public void testHistoricTaskInstanceDurationReportResults() {
startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 7, 14, 11, 43);
startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 7, 14, 11, 43);
DurationReportResult taskReportResult = historyService.createHistoricTaskInstanceReport().duration(PeriodUnit.MONTH).get(0);
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).list();
long min = 0;
long max = 0;
long sum = 0;
for (int i = 0; i < historicTaskInstances.size(); i++) {
HistoricTaskInstance historicProcessInstance = historicTaskInstances.get(i);
Long duration = historicProcessInstance.getDurationInMillis();
sum = sum + duration;
max = i > 0 ? Math.max(max, duration) : duration;
min = i > 0 ? Math.min(min, duration) : duration;
}
long avg = sum / historicTaskInstances.size();
assertEquals("maximum", max, taskReportResult.getMaximum());
assertEquals("minimum", min, taskReportResult.getMinimum());
assertEquals("average", avg, taskReportResult.getAverage(), 0);
}
use of org.camunda.bpm.engine.history.DurationReportResult in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceDurationReportTest method testReportByStartedBeforeByMonth.
public void testReportByStartedBeforeByMonth() {
// given
deployment(createProcessWithUserTask("process"));
DurationReportResultAssertion assertion = createReportScenario().periodUnit(MONTH).startAndCompleteProcessInstance("process", 2016, 0, 15, 10, // 15.01.2016 10:00
0).done();
// start a second process instance
createReportScenario().startAndCompleteProcessInstance("process", 2016, 3, 1, 10, // 01.04.2016 10:00
0).done();
Calendar calendar = Calendar.getInstance();
calendar.set(2016, 0, 16, 0, 0, 0);
// when
List<DurationReportResult> result = historyService.createHistoricProcessInstanceReport().startedBefore(calendar.getTime()).duration(MONTH);
// then
assertThat(result).matches(assertion);
}
use of org.camunda.bpm.engine.history.DurationReportResult in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceDurationReportTest method testReportWithExcludingConditions.
public void testReportWithExcludingConditions() {
// given
deployment(createProcessWithUserTask("process"));
runtimeService.startProcessInstanceByKey("process");
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.complete(taskId);
Calendar hourAgo = Calendar.getInstance();
hourAgo.add(Calendar.HOUR_OF_DAY, -1);
Calendar hourFromNow = Calendar.getInstance();
hourFromNow.add(Calendar.HOUR_OF_DAY, 1);
// when
List<DurationReportResult> result = historyService.createHistoricProcessInstanceReport().startedAfter(hourFromNow.getTime()).startedBefore(hourAgo.getTime()).duration(MONTH);
// then
assertEquals(0, result.size());
}
Aggregations