diff --git a/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/MemoryAppender.java b/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/MemoryAppender.java index 31c5c69766..95b41e02a5 100644 --- a/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/MemoryAppender.java +++ b/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/MemoryAppender.java @@ -19,7 +19,7 @@ public class MemoryAppender extends ListAppender { public boolean contains(String string, Level level) { return this.list.stream() - .anyMatch(event -> event.getMessage().toString().contains(string) + .anyMatch(event -> event.toString().contains(string) && event.getLevel().equals(level)); } @@ -30,13 +30,13 @@ public class MemoryAppender extends ListAppender { public List search(String string) { return this.list.stream() - .filter(event -> event.getMessage().toString().contains(string)) + .filter(event -> event.toString().contains(string)) .collect(Collectors.toList()); } public List search(String string, Level level) { return this.list.stream() - .filter(event -> event.getMessage().toString().contains(string) + .filter(event -> event.toString().contains(string) && event.getLevel().equals(level)) .collect(Collectors.toList()); }