CollectStatTask implements Runnable { StatMessage message(Stats stats) { var message = new StatMessage(); var now = Instant.now(); message.date = now; message.id = LogManager.ID_GENERATOR.next(now); message.result = stats.result(); message.app = LogManager.APP_NAME; message.host = Network.LOCAL_HOST_NAME; message.errorCode = stats.errorCode; message.errorMessage = stats.errorMessage; message.stats = stats.stats; message.info = stats.info; return message; } CollectStatTask(LogAppender appender, StatCollector collector); @Override void run();  }
@Test void message() { var stats = new Stats(); stats.put("sys_load_avg", 1d); StatMessage message = task.message(stats); assertThat(message.id).isNotNull(); assertThat(message.stats).containsOnly(entry("sys_load_avg", 1d)); }