From a7e89a359288462eed1bff906f5203b0d8e59de9 Mon Sep 17 00:00:00 2001 From: Matteo Mara Date: Fri, 23 Feb 2024 15:26:37 +0100 Subject: [PATCH] SGB-6 improve assertion in order to check only the entries for relevant logger --- .../org/sonar/server/app/WebServerProcessLoggingTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/app/WebServerProcessLoggingTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/app/WebServerProcessLoggingTest.java index 1b79e31203f..dedaffe6fd7 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/app/WebServerProcessLoggingTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/app/WebServerProcessLoggingTest.java @@ -42,6 +42,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.stream.Stream; +import org.assertj.core.groups.Tuple; import org.junit.AfterClass; import org.junit.Before; import org.junit.Rule; @@ -104,7 +105,10 @@ public class WebServerProcessLoggingTest { java.util.logging.Logger logger = java.util.logging.Logger.getLogger("com.ms.sqlserver.jdbc.DTV"); logger.finest("Test"); memoryAppender.stop(); - assertThat(memoryAppender.getLogs()).hasSize(1); + assertThat(memoryAppender.getLogs()) + .filteredOn(ILoggingEvent::getLoggerName, "com.ms.sqlserver.jdbc.DTV") + .extracting(ILoggingEvent::getLevel, ILoggingEvent::getMessage) + .containsOnly(new Tuple(Level.TRACE, "Test")); } @Test -- 2.39.5