Search in sources :

Example 1 with HistoricTaskInstanceReportResult

use of org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult in project camunda-bpm-platform by camunda.

the class MockProvider method createMockHistoricTaskInstanceReportWithProcDef.

public static List<HistoricTaskInstanceReportResult> createMockHistoricTaskInstanceReportWithProcDef() {
    HistoricTaskInstanceReportResult mock = mock(HistoricTaskInstanceReportResult.class);
    when(mock.getCount()).thenReturn(EXAMPLE_HISTORIC_TASK_REPORT_COUNT);
    when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_HISTORIC_TASK_REPORT_PROC_DEF_ID);
    when(mock.getProcessDefinitionKey()).thenReturn(EXAMPLE_HISTORIC_TASK_REPORT_PROC_DEFINITION);
    when(mock.getProcessDefinitionName()).thenReturn(EXAMPLE_HISTORIC_TASK_REPORT_PROC_DEF_NAME);
    when(mock.getTenantId()).thenReturn(EXAMPLE_TENANT_ID);
    when(mock.getTaskName()).thenReturn(null);
    return Collections.singletonList(mock);
}
Also used : HistoricTaskInstanceReportResult(org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult)

Example 2 with HistoricTaskInstanceReportResult

use of org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult 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;
}
Also used : MockProvider.createMockHistoricTaskInstanceReport(org.camunda.bpm.engine.rest.helper.MockProvider.createMockHistoricTaskInstanceReport) HistoricTaskInstanceReport(org.camunda.bpm.engine.history.HistoricTaskInstanceReport) HistoricTaskInstanceReportResult(org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult) DurationReportResult(org.camunda.bpm.engine.history.DurationReportResult) Date(java.util.Date)

Example 3 with HistoricTaskInstanceReportResult

use of org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult in project camunda-bpm-platform by camunda.

the class HistoricTaskReportTest method testReportWithNullTaskName.

@Test
public void testReportWithNullTaskName() {
    // given
    startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 7, 14, 12, 1);
    // when
    BpmnModelInstance instance = Bpmn.createExecutableProcess(ANOTHER_PROCESS_DEFINITION_KEY).name("name_" + ANOTHER_PROCESS_DEFINITION_KEY).startEvent().userTask("task1_" + ANOTHER_PROCESS_DEFINITION_KEY).name(null).endEvent().done();
    processEngineTestRule.deploy(instance);
    startAndCompleteProcessInstance(ANOTHER_PROCESS_DEFINITION_KEY, 2016, 7, 14, 12, 1);
    Calendar calendar = Calendar.getInstance();
    calendar.set(2016, 11, 14, 12, 5);
    List<HistoricTaskInstanceReportResult> historicTaskInstanceReportResults = historyService.createHistoricTaskInstanceReport().completedBefore(calendar.getTime()).countByTaskName();
    assertEquals(1, historicTaskInstanceReportResults.size());
    assertEquals(1, historicTaskInstanceReportResults.get(0).getCount(), 0);
}
Also used : Calendar(java.util.Calendar) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) HistoricTaskInstanceReportResult(org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult) Test(org.junit.Test)

Example 4 with HistoricTaskInstanceReportResult

use of org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult in project camunda-bpm-platform by camunda.

the class HistoricTaskReportTest method testHistoricTaskInstanceReportWithCompletedBeforeDate.

@Test
public void testHistoricTaskInstanceReportWithCompletedBeforeDate() {
    // given
    startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 7, 14, 12, 1);
    startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 8, 14, 12, 1);
    startAndCompleteProcessInstance(ANOTHER_PROCESS_DEFINITION_KEY, 2016, 7, 14, 12, 1);
    // when
    Calendar calendar = Calendar.getInstance();
    calendar.set(2016, 11, 14, 12, 5);
    List<HistoricTaskInstanceReportResult> historicTaskInstanceReportResults = historyService.createHistoricTaskInstanceReport().completedBefore(calendar.getTime()).countByProcessDefinitionKey();
    // then
    assertEquals(2, historicTaskInstanceReportResults.size());
    assertEquals(1, historicTaskInstanceReportResults.get(0).getCount(), 0);
}
Also used : Calendar(java.util.Calendar) HistoricTaskInstanceReportResult(org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult) Test(org.junit.Test)

Example 5 with HistoricTaskInstanceReportResult

use of org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult in project camunda-bpm-platform by camunda.

the class MockProvider method createMockHistoricTaskInstanceReport.

public static List<HistoricTaskInstanceReportResult> createMockHistoricTaskInstanceReport() {
    HistoricTaskInstanceReportResult mock = mock(HistoricTaskInstanceReportResult.class);
    when(mock.getCount()).thenReturn(EXAMPLE_HISTORIC_TASK_REPORT_COUNT);
    when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_HISTORIC_TASK_REPORT_PROC_DEF_ID);
    when(mock.getProcessDefinitionKey()).thenReturn(EXAMPLE_HISTORIC_TASK_REPORT_PROC_DEFINITION);
    when(mock.getProcessDefinitionName()).thenReturn(EXAMPLE_HISTORIC_TASK_REPORT_PROC_DEF_NAME);
    when(mock.getTenantId()).thenReturn(EXAMPLE_TENANT_ID);
    when(mock.getTaskName()).thenReturn(EXAMPLE_HISTORIC_TASK_REPORT_TASK_NAME);
    return Collections.singletonList(mock);
}
Also used : HistoricTaskInstanceReportResult(org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult)

Aggregations

HistoricTaskInstanceReportResult (org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult)7 Calendar (java.util.Calendar)4 Test (org.junit.Test)4 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 Date (java.util.Date)1 DurationReportResult (org.camunda.bpm.engine.history.DurationReportResult)1 HistoricTaskInstanceReport (org.camunda.bpm.engine.history.HistoricTaskInstanceReport)1 MockProvider.createMockHistoricTaskInstanceReport (org.camunda.bpm.engine.rest.helper.MockProvider.createMockHistoricTaskInstanceReport)1