From bea26747a40593d0d5865a3aca40863cb66ffcaf Mon Sep 17 00:00:00 2001 From: Scott Leberknight <174812+sleberknight@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:31:55 -0500 Subject: [PATCH] Add eventMap() method to InMemoryAppender (#445) * This method is copied from kiwi-beta, which has its own InMemoryAppender class. Eventually, this class can be made public and supersede that one. * Change from collect(toList()) in orderedEvents and orderedEventMessages to toList() as the terminal method. The returned lists should not be modifiable. --- .../test/logback/InMemoryAppender.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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