### Question:
DurationStatistics { void log() { if (recordStat) { StringBuilder out = new StringBuilder(); DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.ROOT); symbols.setGroupingSeparator('\''); NumberFormat format = new DecimalFormat("#,###", symbols); out.append("Duration Statistics"); stats.entrySet().stream() .sorted((a, b) -> Long.compare(b.getValue().get(), a.getValue().get())) .forEach(e -> out.append(", ") .append(e.getKey()) .append(" ") .append(format.format(e.getValue().get() / 1_000_000L)) .append(" ms")); LOG.info(out.toString()); } } DurationStatistics(Configuration config);   }### Answer:
@Test public void statistics_disabled() { DurationStatistics statistics = new DurationStatistics(sensorContext.config()); fillStatistics(statistics); statistics.log(); assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty(); }
@Test public void statistics_activated() { sensorContext.settings().setProperty("sonar.slang.duration.statistics", "true"); DurationStatistics statistics = new DurationStatistics(sensorContext.config()); fillStatistics(statistics); statistics.log(); assertThat(logTester.logs(LoggerLevel.INFO)).hasSize(1); assertThat(logTester.logs(LoggerLevel.INFO).get(0)).startsWith("Duration Statistics, "); }