diff --git a/src/test/java/org/kiwiproject/test/logback/InMemoryAppender.java b/src/test/java/org/kiwiproject/test/logback/InMemoryAppender.java index 1953158..3c65b4c 100644 --- a/src/test/java/org/kiwiproject/test/logback/InMemoryAppender.java +++ b/src/test/java/org/kiwiproject/test/logback/InMemoryAppender.java @@ -1,7 +1,6 @@ package org.kiwiproject.test.logback; import static java.util.Comparator.comparing; -import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; import ch.qos.logback.classic.spi.ILoggingEvent; @@ -9,6 +8,7 @@ import lombok.Synchronized; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; @@ -62,13 +62,25 @@ public void clearEvents() { eventMap.clear(); } + /** + * Return a copy of the internal event map. + *

+ * The keys are the message order starting at one, and the values are the corresponding logging events. + * + * @return an unmodifiable copy of the event map + */ + @SuppressWarnings("unused") + public Map eventMap() { + return Map.copyOf(eventMap); + } + /** * Retrieves a list of logging events ordered by ascending timestamp. * * @return the ordered list of logging events */ public List orderedEvents() { - return orderedEventStream().collect(toList()); + return orderedEventStream().toList(); } /** @@ -80,7 +92,7 @@ public List orderedEvents() { public List orderedEventMessages() { return orderedEventStream() .map(ILoggingEvent::getFormattedMessage) - .collect(toList()); + .toList(); } /**