diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2024-04-30 14:59:03 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2024-05-03 13:07:43 +0200 |
commit | b04cd6ba08a93a88553c1dfceaa725ced1ba381c (patch) | |
tree | 762512e8d5a70bd6981706c5d779a982c57ad75a /src/test/java/org/sonarsource/scanner/cli/LogsTest.java | |
parent | fd82dd7b5a54d2042da17baff7088329123797ac (diff) | |
download | sonar-scanner-cli-b04cd6ba08a93a88553c1dfceaa725ced1ba381c.tar.gz sonar-scanner-cli-b04cd6ba08a93a88553c1dfceaa725ced1ba381c.zip |
SCANCLI-145 Update to the scanner library 3.0
Diffstat (limited to 'src/test/java/org/sonarsource/scanner/cli/LogsTest.java')
-rw-r--r-- | src/test/java/org/sonarsource/scanner/cli/LogsTest.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/java/org/sonarsource/scanner/cli/LogsTest.java b/src/test/java/org/sonarsource/scanner/cli/LogsTest.java index e664365..82a26ad 100644 --- a/src/test/java/org/sonarsource/scanner/cli/LogsTest.java +++ b/src/test/java/org/sonarsource/scanner/cli/LogsTest.java @@ -25,7 +25,10 @@ import org.junit.Test; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.sonarsource.scanner.lib.LogOutput; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -89,4 +92,37 @@ public class LogsTest { logs.debug("debug"); verifyNoMoreInteractions(stdOut, stdErr); } + + @Test + public void should_forward_logs() { + var mockedLogs = mock(Logs.class); + var logOutput = new Logs.LogOutputAdapter(mockedLogs); + + String msg = "test"; + + logOutput.log(msg, LogOutput.Level.DEBUG); + verify(mockedLogs).debug(msg); + verifyNoMoreInteractions(mockedLogs); + reset(mockedLogs); + + logOutput.log(msg, LogOutput.Level.INFO); + verify(mockedLogs).info(msg); + verifyNoMoreInteractions(mockedLogs); + reset(mockedLogs); + + logOutput.log(msg, LogOutput.Level.ERROR); + verify(mockedLogs).error(msg); + verifyNoMoreInteractions(mockedLogs); + reset(mockedLogs); + + logOutput.log(msg, LogOutput.Level.WARN); + verify(mockedLogs).warn(msg); + verifyNoMoreInteractions(mockedLogs); + reset(mockedLogs); + + logOutput.log(msg, LogOutput.Level.TRACE); + verify(mockedLogs).debug(msg); + verifyNoMoreInteractions(mockedLogs); + reset(mockedLogs); + } } |