public virtual void testDifferentProcessesWithSameActivityId() { string processDefinitionId = ProcessDefinitionId; string anotherProcessDefinitionId = getProcessDefinitionIdByKey("anotherProcess"); startProcesses(5); startProcessesByKey(10, "anotherProcess"); // first processDefinition HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(1, query.count()); assertEquals(1, statistics.Count); HistoricActivityStatistics task = statistics[0]; assertEquals(5, task.Instances); // second processDefinition query = historyService.createHistoricActivityStatisticsQuery(anotherProcessDefinitionId); statistics = query.list(); assertEquals(1, query.count()); assertEquals(1, statistics.Count); task = statistics[0]; assertEquals(10, task.Instances); }
public virtual void testQueryByCanceledAfterCancelingSomeInstances() { string processDefinitionId = ProcessDefinitionId; startProcesses(3); // cancel running process instances IList <ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list(); foreach (ProcessInstance processInstance in processInstances) { runtimeService.deleteProcessInstance(processInstance.Id, "test"); } startProcesses(2); HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled(); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(1, query.count()); assertEquals(1, statistics.Count); // task HistoricActivityStatistics task = statistics[0]; assertEquals("task", task.Id); assertEquals(2, task.Instances); assertEquals(3, task.Canceled); completeProcessInstances(); }
public virtual void testQueryByFinished() { string processDefinitionId = ProcessDefinitionId; startProcesses(5); HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeFinished().orderByActivityId().asc(); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(2, query.count()); assertEquals(2, statistics.Count); // start HistoricActivityStatistics start = statistics[0]; assertEquals("start", start.Id); assertEquals(0, start.Instances); assertEquals(5, start.Finished); // task HistoricActivityStatistics task = statistics[1]; assertEquals("task", task.Id); assertEquals(5, task.Instances); assertEquals(0, task.Finished); }
public virtual void testQueryIncludingCompleteScopeWithReadHistoryPermissionOnAnyProcessDefinition() { // given string processDefinitionId = selectProcessDefinitionByKey(PROCESS_KEY).Id; startProcessInstanceByKey(PROCESS_KEY); startProcessInstanceByKey(PROCESS_KEY); startProcessInstanceByKey(PROCESS_KEY); string taskId = selectAnyTask().Id; disableAuthorization(); taskService.complete(taskId); enableAuthorization(); createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY); // when HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCompleteScope(); // then verifyQueryResults(query, 2); IList <HistoricActivityStatistics> statistics = query.list(); HistoricActivityStatistics task = getStatisticsByKey(statistics, "theTask"); verifyStatisticsResult(task, 2, 0, 0, 0); HistoricActivityStatistics end = getStatisticsByKey(statistics, "theEnd"); verifyStatisticsResult(end, 0, 0, 0, 1); }
public virtual void testQueryIncludingCanceledWithReadHistoryPermissionOnProcessDefinition() { // given string processDefinitionId = selectProcessDefinitionByKey(PROCESS_KEY).Id; startProcessInstanceByKey(PROCESS_KEY); startProcessInstanceByKey(PROCESS_KEY); string processInstanceId = startProcessInstanceByKey(PROCESS_KEY).Id; disableAuthorization(); runtimeService.deleteProcessInstance(processInstanceId, null); enableAuthorization(); createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY); // when HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled(); // then verifyQueryResults(query, 1); IList <HistoricActivityStatistics> statistics = query.list(); HistoricActivityStatistics task = getStatisticsByKey(statistics, "theTask"); verifyStatisticsResult(task, 2, 0, 1, 0); }
public virtual void testQueryByFinishedAndCompleteScopeAndCanceled() { string processDefinitionId = ProcessDefinitionId; startProcesses(2); // cancel running process instances IList <ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list(); foreach (ProcessInstance processInstance in processInstances) { runtimeService.deleteProcessInstance(processInstance.Id, "test"); } startProcesses(2); // complete running tasks IList <Task> tasks = taskService.createTaskQuery().list(); foreach (Task task in tasks) { taskService.complete(task.Id); } startProcesses(2); HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeFinished().includeCompleteScope().includeCanceled().orderByActivityId().asc(); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(3, query.count()); assertEquals(3, statistics.Count); // end HistoricActivityStatistics end = statistics[0]; assertEquals("end", end.Id); assertEquals(0, end.Instances); assertEquals(0, end.Canceled); assertEquals(2, end.Finished); assertEquals(2, end.CompleteScope); // start HistoricActivityStatistics start = statistics[1]; assertEquals("start", start.Id); assertEquals(0, start.Instances); assertEquals(0, start.Canceled); assertEquals(6, start.Finished); assertEquals(0, start.CompleteScope); // task HistoricActivityStatistics task = statistics[2]; assertEquals("task", task.Id); assertEquals(2, task.Instances); assertEquals(2, task.Canceled); assertEquals(4, task.Finished); assertEquals(0, task.CompleteScope); }
private void setupHistoricActivityStatisticsMock() { IList <HistoricActivityStatistics> mocks = MockProvider.createMockHistoricActivityStatistics(); historicActivityStatisticsQuery = mock(typeof(HistoricActivityStatisticsQuery)); when(processEngine.HistoryService.createHistoricActivityStatisticsQuery(eq(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID))).thenReturn(historicActivityStatisticsQuery); when(historicActivityStatisticsQuery.list()).thenReturn(mocks); }
private void createHistoricActivityStatisticsMock() { IList <HistoricActivityStatistics> statistics = MockProvider.createMockHistoricActivityStatistics(); HistoricActivityStatisticsQuery query = mock(typeof(HistoricActivityStatisticsQuery)); when(mockHistoryService.createHistoricActivityStatisticsQuery(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID)).thenReturn(query); when(query.list()).thenReturn(statistics); }
public virtual void testMultipleProcessDefinitions() { string processId = ProcessDefinitionId; string calledProcessId = getProcessDefinitionIdByKey("calledProcess"); startProcesses(5); startProcessesByKey(10, "calledProcess"); HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processId).orderByActivityId().asc(); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(1, query.count()); assertEquals(1, statistics.Count); // callActivity HistoricActivityStatistics calledActivity = statistics[0]; assertEquals("callActivity", calledActivity.Id); assertEquals(5, calledActivity.Instances); query = historyService.createHistoricActivityStatisticsQuery(calledProcessId).orderByActivityId().asc(); statistics = query.list(); assertEquals(2, query.count()); assertEquals(2, statistics.Count); // task1 HistoricActivityStatistics task1 = statistics[0]; assertEquals("task1", task1.Id); assertEquals(15, task1.Instances); // task2 HistoricActivityStatistics task2 = statistics[1]; assertEquals("task2", task2.Id); assertEquals(15, task2.Instances); completeProcessInstances(); }
public virtual void testNoRunningProcessInstances() { string processDefinitionId = ProcessDefinitionId; HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(0, query.count()); assertEquals(0, statistics.Count); }
public virtual void testQueryByCompleteScopeMultipleRunningTasks() { string processDefinitionId = ProcessDefinitionId; startProcesses(5); IList <Task> tasks = taskService.createTaskQuery().taskDefinitionKey("innerTask").list(); foreach (Task task in tasks) { taskService.complete(task.Id); } HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCompleteScope().orderByActivityId().asc(); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(4, query.count()); assertEquals(4, statistics.Count); // end1 HistoricActivityStatistics end1 = statistics[0]; assertEquals("end1", end1.Id); assertEquals(0, end1.Instances); assertEquals(5, end1.CompleteScope); // innerEnd HistoricActivityStatistics innerEnd = statistics[1]; assertEquals("innerEnd", innerEnd.Id); assertEquals(0, innerEnd.Instances); assertEquals(25, innerEnd.CompleteScope); // subprocess (completes the multi-instances body scope, see BPMN spec) HistoricActivityStatistics subprocess = statistics[2]; assertEquals("subprocess", subprocess.Id); assertEquals(0, subprocess.Instances); assertEquals(25, subprocess.CompleteScope); // task HistoricActivityStatistics task = statistics[3]; assertEquals("task", task.Id); assertEquals(5, task.Instances); assertEquals(0, task.CompleteScope); completeProcessInstances(); }
public virtual void testQueryByFinishedAfterFinishingSomeInstances() { string processDefinitionId = ProcessDefinitionId; // start five instances startProcesses(5); // complete two task, so that two process instances are finished IList <Task> tasks = taskService.createTaskQuery().list(); for (int i = 0; i < 2; i++) { taskService.complete(tasks[i].Id); } HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeFinished().orderByActivityId().asc(); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(3, query.count()); assertEquals(3, statistics.Count); // end HistoricActivityStatistics end = statistics[0]; assertEquals("end", end.Id); assertEquals(0, end.Instances); assertEquals(2, end.Finished); // start HistoricActivityStatistics start = statistics[1]; assertEquals("start", start.Id); assertEquals(0, start.Instances); assertEquals(5, start.Finished); // task HistoricActivityStatistics task = statistics[2]; assertEquals("task", task.Id); assertEquals(3, task.Instances); assertEquals(2, task.Finished); completeProcessInstances(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testSingleTask() public virtual void testSingleTask() { string processDefinitionId = ProcessDefinitionId; startProcesses(5); HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(1, query.count()); assertEquals(1, statistics.Count); HistoricActivityStatistics statistic = statistics[0]; assertEquals("task", statistic.Id); assertEquals(5, statistic.Instances); completeProcessInstances(); }
public virtual void testQueryByCompleteScope() { string processDefinitionId = ProcessDefinitionId; startProcesses(5); completeProcessInstances(); HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCompleteScope(); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(1, query.count()); assertEquals(1, statistics.Count); // end HistoricActivityStatistics end = statistics[0]; assertEquals("end", end.Id); assertEquals(0, end.Instances); assertEquals(5, end.CompleteScope); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testMultipleRunningTasks() public virtual void testMultipleRunningTasks() { string processDefinitionId = ProcessDefinitionId; startProcesses(5); HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).orderByActivityId().asc(); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(4, query.count()); assertEquals(4, statistics.Count); // innerTask HistoricActivityStatistics innerTask = statistics[0]; assertEquals("innerTask", innerTask.Id); assertEquals(25, innerTask.Instances); // subprocess HistoricActivityStatistics subProcess = statistics[1]; assertEquals("subprocess", subProcess.Id); assertEquals(25, subProcess.Instances); // subprocess multi instance body HistoricActivityStatistics subProcessMiBody = statistics[2]; assertEquals("subprocess#multiInstanceBody", subProcessMiBody.Id); assertEquals(5, subProcessMiBody.Instances); // task HistoricActivityStatistics task = statistics[3]; assertEquals("task", task.Id); assertEquals(5, task.Instances); completeProcessInstances(); }
public virtual void testQueryByCanceled() { string processDefinitionId = ProcessDefinitionId; startProcesses(5); cancelProcessInstances(); HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled(); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(1, query.count()); assertEquals(1, statistics.Count); // task HistoricActivityStatistics task = statistics[0]; assertEquals("task", task.Id); assertEquals(0, task.Instances); assertEquals(5, task.Canceled); }
public virtual IList <HistoricActivityStatisticsDto> getHistoricActivityStatistics(UriInfo uriInfo, string processDefinitionId, bool?includeCanceled, bool?includeFinished, bool?includeCompleteScope, string sortBy, string sortOrder) { HistoryService historyService = processEngine.HistoryService; HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId); if (includeCanceled != null && includeCanceled) { query.includeCanceled(); } if (includeFinished != null && includeFinished) { query.includeFinished(); } if (includeCompleteScope != null && includeCompleteScope) { query.includeCompleteScope(); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final javax.ws.rs.core.MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters(); MultivaluedMap <string, string> queryParameters = uriInfo.QueryParameters; DateConverter dateConverter = new DateConverter(); dateConverter.ObjectMapper = objectMapper; if (queryParameters.getFirst(QUERY_PARAM_STARTED_AFTER) != null) { DateTime startedAfter = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_STARTED_AFTER)); query.startedAfter(startedAfter); } if (queryParameters.getFirst(QUERY_PARAM_STARTED_BEFORE) != null) { DateTime startedBefore = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_STARTED_BEFORE)); query.startedBefore(startedBefore); } if (queryParameters.getFirst(QUERY_PARAM_FINISHED_AFTER) != null) { DateTime finishedAfter = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_FINISHED_AFTER)); query.finishedAfter(finishedAfter); } if (queryParameters.getFirst(QUERY_PARAM_FINISHED_BEFORE) != null) { DateTime finishedBefore = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_FINISHED_BEFORE)); query.finishedBefore(finishedBefore); } setSortOptions(query, sortOrder, sortBy); IList <HistoricActivityStatisticsDto> result = new List <HistoricActivityStatisticsDto>(); IList <HistoricActivityStatistics> statistics = query.list(); foreach (HistoricActivityStatistics currentStatistics in statistics) { result.Add(HistoricActivityStatisticsDto.fromHistoricActivityStatistics(currentStatistics)); } return(result); }
public virtual void testQueryByFinishedMultipleRunningTasks() { string processDefinitionId = ProcessDefinitionId; startProcesses(5); IList <Task> tasks = taskService.createTaskQuery().taskDefinitionKey("innerTask").list(); foreach (Task task in tasks) { taskService.complete(task.Id); } HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeFinished().orderByActivityId().asc(); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(9, query.count()); assertEquals(9, statistics.Count); // end1 HistoricActivityStatistics end1 = statistics[0]; assertEquals("end1", end1.Id); assertEquals(0, end1.Instances); assertEquals(5, end1.Finished); // gtw HistoricActivityStatistics gtw = statistics[1]; assertEquals("gtw", gtw.Id); assertEquals(0, gtw.Instances); assertEquals(5, gtw.Finished); // innerEnd HistoricActivityStatistics innerEnd = statistics[2]; assertEquals("innerEnd", innerEnd.Id); assertEquals(0, innerEnd.Instances); assertEquals(25, innerEnd.Finished); // innerStart HistoricActivityStatistics innerStart = statistics[3]; assertEquals("innerStart", innerStart.Id); assertEquals(0, innerStart.Instances); assertEquals(25, innerStart.Finished); // innerTask HistoricActivityStatistics innerTask = statistics[4]; assertEquals("innerTask", innerTask.Id); assertEquals(0, innerTask.Instances); assertEquals(25, innerTask.Finished); // innerStart HistoricActivityStatistics start = statistics[5]; assertEquals("start", start.Id); assertEquals(0, start.Instances); assertEquals(5, start.Finished); // subprocess HistoricActivityStatistics subProcess = statistics[6]; assertEquals("subprocess", subProcess.Id); assertEquals(0, subProcess.Instances); assertEquals(25, subProcess.Finished); // subprocess - multi-instance body HistoricActivityStatistics subProcessMiBody = statistics[7]; assertEquals("subprocess#multiInstanceBody", subProcessMiBody.Id); assertEquals(0, subProcessMiBody.Instances); assertEquals(5, subProcessMiBody.Finished); // task HistoricActivityStatistics task = statistics[8]; assertEquals("task", task.Id); assertEquals(5, task.Instances); assertEquals(0, task.Finished); completeProcessInstances(); }
public virtual void testQueryByCanceledAndFinishedByPeriods() { try { //start two process instances ClockUtil.CurrentTime = sdf.parse("15.01.2016 12:00:00"); startProcesses(2); // cancel running process instances ClockUtil.CurrentTime = sdf.parse("15.02.2016 12:00:00"); IList <ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list(); foreach (ProcessInstance processInstance in processInstances) { runtimeService.deleteProcessInstance(processInstance.Id, "test"); } //start two process instances ClockUtil.CurrentTime = sdf.parse("01.02.2016 12:00:00"); startProcesses(2); // complete running tasks ClockUtil.CurrentTime = sdf.parse("25.02.2016 12:00:00"); IList <Task> tasks = taskService.createTaskQuery().list(); foreach (Task task in tasks) { taskService.complete(task.Id); } //starte two more process instances ClockUtil.CurrentTime = sdf.parse("15.03.2016 12:00:00"); startProcesses(2); //NOW ClockUtil.CurrentTime = sdf.parse("25.03.2016 12:00:00"); string processDefinitionId = ProcessDefinitionId; //check January by started dates HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().startedAfter(sdf.parse("01.01.2016 00:00:00")).startedBefore(sdf.parse("31.01.2016 23:59:59")).orderByActivityId().asc(); IList <HistoricActivityStatistics> statistics = query.list(); assertEquals(2, query.count()); assertEquals(2, statistics.Count); // start assertActivityStatistics(statistics[0], "start", 0, 0, 2); // task assertActivityStatistics(statistics[1], "task", 0, 2, 2); //check January by finished dates query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().finishedAfter(sdf.parse("01.01.2016 00:00:00")).finishedBefore(sdf.parse("31.01.2016 23:59:59")).orderByActivityId().asc(); statistics = query.list(); assertEquals(0, query.count()); assertEquals(0, statistics.Count); //check February by started dates query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().startedAfter(sdf.parse("01.02.2016 00:00:00")).startedBefore(sdf.parse("28.02.2016 23:59:59")).orderByActivityId().asc(); statistics = query.list(); assertEquals(3, query.count()); assertEquals(3, statistics.Count); // end assertActivityStatistics(statistics[0], "end", 0, 0, 2); // start assertActivityStatistics(statistics[1], "start", 0, 0, 2); // task assertActivityStatistics(statistics[2], "task", 0, 0, 2); //check February by finished dates query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().finishedAfter(sdf.parse("01.02.2016 00:00:00")).finishedBefore(sdf.parse("28.02.2016 23:59:59")).orderByActivityId().asc(); statistics = query.list(); assertEquals(3, query.count()); assertEquals(3, statistics.Count); // end assertActivityStatistics(statistics[0], "end", 0, 0, 2); // start assertActivityStatistics(statistics[1], "start", 0, 0, 4); // task assertActivityStatistics(statistics[2], "task", 0, 2, 4); //check March by started dates query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().startedAfter(sdf.parse("01.03.2016 00:00:00")).orderByActivityId().asc(); statistics = query.list(); assertEquals(2, query.count()); assertEquals(2, statistics.Count); // start assertActivityStatistics(statistics[0], "start", 0, 0, 2); // task assertActivityStatistics(statistics[1], "task", 2, 0, 0); //check March by finished dates query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().finishedAfter(sdf.parse("01.03.2016 00:00:00")).orderByActivityId().asc(); statistics = query.list(); assertEquals(0, query.count()); assertEquals(0, statistics.Count); //check whole period by started date query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().startedAfter(sdf.parse("01.01.2016 00:00:00")).orderByActivityId().asc(); statistics = query.list(); assertEquals(3, query.count()); assertEquals(3, statistics.Count); // end assertActivityStatistics(statistics[0], "end", 0, 0, 2); // start assertActivityStatistics(statistics[1], "start", 0, 0, 6); // task assertActivityStatistics(statistics[2], "task", 2, 2, 4); } finally { ClockUtil.reset(); } }