Search in sources :

Example 1 with HistoricCaseActivityStatistics

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

the class HistoricCaseDefinitionRestServiceImpl method getHistoricCaseActivityStatistics.

public List<HistoricCaseActivityStatisticsDto> getHistoricCaseActivityStatistics(String caseDefinitionId) {
    HistoryService historyService = processEngine.getHistoryService();
    List<HistoricCaseActivityStatistics> statistics = historyService.createHistoricCaseActivityStatisticsQuery(caseDefinitionId).list();
    List<HistoricCaseActivityStatisticsDto> result = new ArrayList<HistoricCaseActivityStatisticsDto>();
    for (HistoricCaseActivityStatistics currentStatistics : statistics) {
        result.add(HistoricCaseActivityStatisticsDto.fromHistoricCaseActivityStatistics(currentStatistics));
    }
    return result;
}
Also used : HistoricCaseActivityStatistics(org.camunda.bpm.engine.history.HistoricCaseActivityStatistics) ArrayList(java.util.ArrayList) HistoryService(org.camunda.bpm.engine.HistoryService) HistoricCaseActivityStatisticsDto(org.camunda.bpm.engine.rest.dto.history.HistoricCaseActivityStatisticsDto)

Example 2 with HistoricCaseActivityStatistics

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

the class MockProvider method createMockHistoricCaseActivityStatistics.

public static List<HistoricCaseActivityStatistics> createMockHistoricCaseActivityStatistics() {
    HistoricCaseActivityStatistics statistics = mock(HistoricCaseActivityStatistics.class);
    when(statistics.getId()).thenReturn(EXAMPLE_ACTIVITY_ID);
    when(statistics.getActive()).thenReturn(EXAMPLE_ACTIVE_LONG);
    when(statistics.getAvailable()).thenReturn(EXAMPLE_AVAILABLE_LONG);
    when(statistics.getCompleted()).thenReturn(EXAMPLE_COMPLETED_LONG);
    when(statistics.getDisabled()).thenReturn(EXAMPLE_DISABLED_LONG);
    when(statistics.getEnabled()).thenReturn(EXAMPLE_ENABLED_LONG);
    when(statistics.getTerminated()).thenReturn(EXAMPLE_TERMINATED_LONG);
    HistoricCaseActivityStatistics anotherStatistics = mock(HistoricCaseActivityStatistics.class);
    when(anotherStatistics.getId()).thenReturn(ANOTHER_EXAMPLE_ACTIVITY_ID);
    when(anotherStatistics.getActive()).thenReturn(ANOTHER_EXAMPLE_ACTIVE_LONG);
    when(anotherStatistics.getAvailable()).thenReturn(ANOTHER_EXAMPLE_AVAILABLE_LONG);
    when(anotherStatistics.getCompleted()).thenReturn(ANOTHER_EXAMPLE_COMPLETED_LONG);
    when(anotherStatistics.getDisabled()).thenReturn(ANOTHER_EXAMPLE_DISABLED_LONG);
    when(anotherStatistics.getEnabled()).thenReturn(ANOTHER_EXAMPLE_ENABLED_LONG);
    when(anotherStatistics.getTerminated()).thenReturn(ANOTHER_EXAMPLE_TERMINATED_LONG);
    List<HistoricCaseActivityStatistics> activityResults = new ArrayList<HistoricCaseActivityStatistics>();
    activityResults.add(statistics);
    activityResults.add(anotherStatistics);
    return activityResults;
}
Also used : HistoricCaseActivityStatistics(org.camunda.bpm.engine.history.HistoricCaseActivityStatistics) ArrayList(java.util.ArrayList)

Example 3 with HistoricCaseActivityStatistics

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

the class HistoricCaseActivityStatisticsQueryTest method testMultipleTasks.

@Test
@Deployment
public void testMultipleTasks() {
    // given
    String caseDefinitionId = getCaseDefinition().getId();
    createCaseByKey(5, "case");
    disableByActivity("DISABLED");
    completeByActivity("COMPLETED");
    terminateByActivity("TERMINATED");
    // when
    HistoricCaseActivityStatisticsQuery query = historyService.createHistoricCaseActivityStatisticsQuery(caseDefinitionId);
    // then
    List<HistoricCaseActivityStatistics> statistics = query.list();
    assertThat(statistics.size(), is(6));
    assertEquals(query.count(), 6);
    assertStatisitcs(statistics.get(0), "ACTIVE", 5, 0, 0, 0, 0, 0);
    assertStatisitcs(statistics.get(1), "AVAILABLE", 0, 5, 0, 0, 0, 0);
    assertStatisitcs(statistics.get(2), "COMPLETED", 0, 0, 5, 0, 0, 0);
    assertStatisitcs(statistics.get(3), "DISABLED", 0, 0, 0, 5, 0, 0);
    assertStatisitcs(statistics.get(4), "ENABLED", 0, 0, 0, 0, 5, 0);
    assertStatisitcs(statistics.get(5), "TERMINATED", 0, 0, 0, 0, 0, 5);
}
Also used : HistoricCaseActivityStatistics(org.camunda.bpm.engine.history.HistoricCaseActivityStatistics) HistoricCaseActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricCaseActivityStatisticsQuery) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 4 with HistoricCaseActivityStatistics

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

the class HistoricCaseActivityStatisticsQueryTest method testStateCount.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricCaseActivityStatisticsQueryTest.testMultipleTasks.cmmn" })
public void testStateCount() {
    // given
    String caseDefinitionId = getCaseDefinition().getId();
    createCaseByKey(3, "case");
    completeByActivity("ACTIVE");
    manuallyStartByActivity("AVAILABLE");
    completeByActivity("AVAILABLE");
    createCaseByKey(5, "case");
    completeByActivity("ACTIVE");
    disableByActivity("AVAILABLE");
    reenableByActivity("AVAILABLE");
    manuallyStartByActivity("AVAILABLE");
    terminateByActivity("AVAILABLE");
    createCaseByKey(5, "case");
    terminateByActivity("ACTIVE");
    manuallyStartByActivity("ENABLED");
    completeByActivity("ENABLED");
    manuallyStartByActivity("DISABLED");
    terminateByActivity("DISABLED");
    createCaseByKey(2, "case");
    disableByActivity("DISABLED");
    // when
    HistoricCaseActivityStatisticsQuery query = historyService.createHistoricCaseActivityStatisticsQuery(caseDefinitionId);
    // then
    List<HistoricCaseActivityStatistics> statistics = query.list();
    assertThat(statistics.size(), is(6));
    assertEquals(query.count(), 6);
    assertStatisitcs(statistics.get(0), "ACTIVE", 2, 0, 8, 0, 0, 5);
    assertStatisitcs(statistics.get(1), "AVAILABLE", 0, 7, 3, 0, 0, 5);
    assertStatisitcs(statistics.get(2), "COMPLETED", 15, 0, 0, 0, 0, 0);
    assertStatisitcs(statistics.get(3), "DISABLED", 0, 0, 0, 2, 0, 13);
    assertStatisitcs(statistics.get(4), "ENABLED", 0, 0, 13, 0, 2, 0);
    assertStatisitcs(statistics.get(5), "TERMINATED", 15, 0, 0, 0, 0, 0);
}
Also used : HistoricCaseActivityStatistics(org.camunda.bpm.engine.history.HistoricCaseActivityStatistics) HistoricCaseActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricCaseActivityStatisticsQuery) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 5 with HistoricCaseActivityStatistics

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

the class HistoricCaseActivityStatisticsQueryTest method testSingleTask.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn")
public void testSingleTask() {
    // given
    String caseDefinitionId = getCaseDefinition().getId();
    createCaseByKey(5, "oneTaskCase");
    // when
    HistoricCaseActivityStatisticsQuery query = historyService.createHistoricCaseActivityStatisticsQuery(caseDefinitionId);
    // then
    List<HistoricCaseActivityStatistics> statistics = query.list();
    assertEquals(1, query.count());
    assertThat(statistics.size(), is(1));
    assertStatisitcs(statistics.get(0), "PI_HumanTask_1", 5, 0, 0, 0, 0, 0);
}
Also used : HistoricCaseActivityStatistics(org.camunda.bpm.engine.history.HistoricCaseActivityStatistics) HistoricCaseActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricCaseActivityStatisticsQuery) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricCaseActivityStatistics (org.camunda.bpm.engine.history.HistoricCaseActivityStatistics)5 HistoricCaseActivityStatisticsQuery (org.camunda.bpm.engine.history.HistoricCaseActivityStatisticsQuery)3 Deployment (org.camunda.bpm.engine.test.Deployment)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 HistoryService (org.camunda.bpm.engine.HistoryService)1 HistoricCaseActivityStatisticsDto (org.camunda.bpm.engine.rest.dto.history.HistoricCaseActivityStatisticsDto)1