Search in sources :

Example 6 with DurationReportResult

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

Example 7 with DurationReportResult

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

Example 8 with DurationReportResult

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

Example 9 with DurationReportResult

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

Example 10 with DurationReportResult

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