]> source.dussan.org Git - sonarqube.git/commitdiff
SGB-6 improve assertion in order to check only the entries for relevant logger
authorMatteo Mara <matteo.mara@sonarsource.com>
Fri, 23 Feb 2024 14:26:37 +0000 (15:26 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 23 Feb 2024 20:02:36 +0000 (20:02 +0000)
server/sonar-webserver-core/src/test/java/org/sonar/server/app/WebServerProcessLoggingTest.java

index 1b79e31203f7805df28c7ac28803227bd7c216ca..dedaffe6fd7f743c010a079909312481baf1f3b5 100644 (file)
@@ -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