Search in sources :

Example 11 with DurationReportResult

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());
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) DurationReportResult(org.camunda.bpm.engine.history.DurationReportResult)

Example 12 with DurationReportResult

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());
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) DurationReportResult(org.camunda.bpm.engine.history.DurationReportResult)

Example 13 with DurationReportResult

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);
}
Also used : HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) DurationReportResult(org.camunda.bpm.engine.history.DurationReportResult) Test(org.junit.Test)

Example 14 with DurationReportResult

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);
}
Also used : Calendar(java.util.Calendar) DurationReportResult(org.camunda.bpm.engine.history.DurationReportResult)

Example 15 with DurationReportResult

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());
}
Also used : Calendar(java.util.Calendar) 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