use of com.endava.cats.model.TimeExecutionDetails in project cats by Endava.
the class TestCaseExporter method writeExecutionTimesForPathAndHttpMethod.
private void writeExecutionTimesForPathAndHttpMethod(String key, List<CatsTestCase> value) {
double average = value.stream().mapToLong(testCase -> testCase.getResponse().getResponseTimeInMs()).average().orElse(0);
List<CatsTestCase> sortedRuns = value.stream().sorted(Comparator.comparingLong(testCase -> testCase.getResponse().getResponseTimeInMs())).collect(Collectors.toList());
CatsTestCase bestCase = sortedRuns.get(0);
CatsTestCase worstCase = sortedRuns.get(sortedRuns.size() - 1);
List<String> executions = sortedRuns.stream().map(CatsTestCase::executionTimeString).collect(Collectors.toList());
TimeExecutionDetails timeExecutionDetails = TimeExecutionDetails.builder().average(average).path(key).bestCase(bestCase.executionTimeString()).worstCase(worstCase.executionTimeString()).executions(executions).build();
LOGGER.info("Details for path {} ", ansi().fg(Ansi.Color.GREEN).a(timeExecutionDetails.getPath()).reset());
LOGGER.note(ansi().fgYellow().a("Average response time: {}ms").reset().toString(), ansi().bold().a(NumberFormat.getInstance().format(timeExecutionDetails.getAverage())));
LOGGER.note(ansi().fgRed().a("Worst case response time: {}").reset().toString(), ansi().bold().a(timeExecutionDetails.getWorstCase()));
LOGGER.note(ansi().fgGreen().a("Best case response time: {}").reset().toString(), ansi().bold().a(timeExecutionDetails.getBestCase()));
if (reportingArguments.isPrintDetailedExecutionStatistics()) {
LOGGER.note("{} executed tests (sorted by response time): {}", timeExecutionDetails.getExecutions().size(), timeExecutionDetails.getExecutions());
LOGGER.info(" ");
}
}
Aggregations