Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testHistoricTaskInstanceDurationReportResults()
        public virtual 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)[0];

            IList <HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).list();

            long min = 0;
            long max = 0;
            long sum = 0;

            for (int i = 0; i < historicTaskInstances.Count; i++)
            {
                HistoricTaskInstance historicProcessInstance = historicTaskInstances[i];
                long?duration = historicProcessInstance.DurationInMillis;
                sum = sum + duration;
                max = i > 0 ? Math.Max(max, duration) : duration.Value;
                min = i > 0 ? Math.Min(min, duration) : duration.Value;
            }

            long avg = sum / historicTaskInstances.Count;

            assertEquals("maximum", max, taskReportResult.Maximum);
            assertEquals("minimum", min, taskReportResult.Minimum);
            assertEquals("average", avg, taskReportResult.Average, 0);
        }
Пример #2
0
        protected internal static string convertDurationReportResult(IList <ReportResult> reports)
        {
            StringBuilder buffer = new StringBuilder();

            buffer.Append(DURATION_HEADER);

            foreach (ReportResult report in reports)
            {
                DurationReportResult durationReport = (DurationReportResult)report;
                buffer.Append(NEW_LINE_SEPARATOR);
                buffer.Append(durationReport.Period);
                buffer.Append(DELIMITER);
                buffer.Append(durationReport.PeriodUnit.ToString());
                buffer.Append(DELIMITER);
                buffer.Append(durationReport.Minimum);
                buffer.Append(DELIMITER);
                buffer.Append(durationReport.Maximum);
                buffer.Append(DELIMITER);
                buffer.Append(durationReport.Average);
            }

            return(buffer.ToString());
        }