@Test
void serializeExceptionAsString() throws IOException {

    Exception exception = new Exception("foo");
    StringBuilder jsonBuilder = new StringBuilder();
    jsonBuilder.append('{');
    EcsJsonSerializer.serializeException(jsonBuilder, exception, false);
    jsonBuilder.append('}');
    JsonNode jsonNode = new ObjectMapper().readTree(jsonBuilder.toString());
    assertThat(jsonNode.get("error.type").textValue()).isEqualTo(exception.getClass().getName());
    assertThat(jsonNode.get("error.message").textValue()).isEqualTo("foo");
    StringWriter stringWriter = new StringWriter();
    exception.printStackTrace(new PrintWriter(stringWriter));
    assertThat(jsonNode.get("error.stack_trace").textValue()).isEqualTo(stringWriter.toString());
}