EventController { EventMessage message(SendEventRequest.Event event, String app, Instant now) { var message = new EventMessage(); message.id = LogManager.ID_GENERATOR.next(now); message.date = event.date.toInstant(); message.app = app; message.receivedTime = now; message.result = JSON.toEnumValue(event.result); message.action = event.action; message.errorCode = event.errorCode; message.errorMessage = event.errorMessage; message.context = event.context; message.info = event.info; message.stats = event.stats; message.elapsed = event.elapsedTime; return message; } EventController(List<String> allowedOrigins, List<String> collectCookies); Response options(Request request); Response post(Request request);  }
@Test void message() { var event = new Event(); event.date = ZonedDateTime.now().minusHours(1); event.result = Result.WARN; event.errorCode = "NOT_FOUND"; event.errorMessage = "not found"; event.context.put("path", "/path"); event.info.put("stackTrace", "trace"); event.elapsedTime = 100L; var controller = new EventController(List.of(), null); Instant now = event.date.plusHours(1).toInstant(); EventMessage message = controller.message(event, "test", now); assertThat(message.id).isNotNull(); assertThat(message.date).isEqualTo(event.date.toInstant()); assertThat(message.receivedTime).isEqualTo(now); assertThat(message.result).isEqualTo("WARN"); assertThat(message.errorCode).isEqualTo(event.errorCode); assertThat(message.errorMessage).isEqualTo(event.errorMessage); assertThat(message.action).isNull(); assertThat(message.context).isEqualTo(event.context); assertThat(message.info).isEqualTo(event.info); assertThat(message.elapsed).isEqualTo(event.elapsedTime); assertThat(message.app).isEqualTo("test"); }