aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/sonarsource/scanner/cli/MainTest.java
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2019-03-15 14:24:15 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2019-03-15 21:19:59 +0100
commitfe6edeb839d98c4c8a5b4bf66fb92349fc9e58fa (patch)
tree7f6b2ea08c7d32d2ae463b3d8ed1b44f58262c9f /src/test/java/org/sonarsource/scanner/cli/MainTest.java
parent0d7d7083ff1c64e210b316b5fbc63152e0aae52c (diff)
downloadsonar-scanner-cli-fe6edeb839d98c4c8a5b4bf66fb92349fc9e58fa.tar.gz
sonar-scanner-cli-fe6edeb839d98c4c8a5b4bf66fb92349fc9e58fa.zip
Fix Quality flaws in tests
Diffstat (limited to 'src/test/java/org/sonarsource/scanner/cli/MainTest.java')
-rw-r--r--src/test/java/org/sonarsource/scanner/cli/MainTest.java24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/test/java/org/sonarsource/scanner/cli/MainTest.java b/src/test/java/org/sonarsource/scanner/cli/MainTest.java
index 2c88157..e8f19a6 100644
--- a/src/test/java/org/sonarsource/scanner/cli/MainTest.java
+++ b/src/test/java/org/sonarsource/scanner/cli/MainTest.java
@@ -19,7 +19,6 @@
*/
package org.sonarsource.scanner.cli;
-import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import org.junit.Before;
@@ -60,7 +59,7 @@ public class MainTest {
private Logs logs;
@Before
- public void setUp() throws IOException {
+ public void setUp() {
MockitoAnnotations.initMocks(this);
when(scannerFactory.create(any(Properties.class))).thenReturn(scanner);
when(conf.properties()).thenReturn(properties);
@@ -83,7 +82,7 @@ public class MainTest {
EmbeddedScanner runner = mock(EmbeddedScanner.class);
Exception e = new NullPointerException("NPE");
e = new IllegalStateException("Error", e);
- doThrow(e).when(runner).execute(any(Map.class));
+ doThrow(e).when(runner).execute(any());
when(scannerFactory.create(any(Properties.class))).thenReturn(runner);
when(cli.isDebugEnabled()).thenReturn(true);
Main main = new Main(exit, cli, conf, scannerFactory, logs);
@@ -106,7 +105,7 @@ public class MainTest {
main.execute();
verify(runner).start();
- verify(runner, never()).execute(any(Map.class));
+ verify(runner, never()).execute(any());
verify(exit).exit(Exit.ERROR);
verify(logs).error("Error during SonarQube Scanner execution", e);
}
@@ -164,7 +163,7 @@ public class MainTest {
when(cli.isEmbedded()).thenReturn(isEmbedded);
EmbeddedScanner runner = mock(EmbeddedScanner.class);
- doThrow(e).when(runner).execute(any(Map.class));
+ doThrow(e).when(runner).execute(any());
when(scannerFactory.create(any(Properties.class))).thenReturn(runner);
Main main = new Main(exit, cli, conf, scannerFactory, logs);
@@ -185,8 +184,7 @@ public class MainTest {
}
@Test
- public void should_only_display_version() throws IOException {
-
+ public void should_only_display_version() {
Properties p = new Properties();
when(cli.isDisplayVersionOnly()).thenReturn(true);
when(conf.properties()).thenReturn(p);
@@ -202,7 +200,7 @@ public class MainTest {
}
@Test
- public void should_skip() throws IOException {
+ public void should_skip() {
Properties p = new Properties();
p.setProperty(ScanProperties.SKIP, "true");
when(conf.properties()).thenReturn(p);
@@ -219,7 +217,7 @@ public class MainTest {
}
@Test
- public void shouldLogServerVersion() throws IOException {
+ public void shouldLogServerVersion() {
when(scanner.serverVersion()).thenReturn("5.5");
Properties p = new Properties();
when(cli.isDisplayVersionOnly()).thenReturn(true);
@@ -231,24 +229,24 @@ public class MainTest {
}
@Test
- public void should_configure_logging() throws IOException {
+ public void should_configure_logging() {
Properties analysisProps = testLogging("sonar.verbose", "true");
assertThat(analysisProps.getProperty("sonar.verbose")).isEqualTo("true");
}
@Test
- public void should_configure_logging_trace() throws IOException {
+ public void should_configure_logging_trace() {
Properties analysisProps = testLogging("sonar.log.level", "TRACE");
assertThat(analysisProps.getProperty("sonar.log.level")).isEqualTo("TRACE");
}
@Test
- public void should_configure_logging_debug() throws IOException {
+ public void should_configure_logging_debug() {
Properties analysisProps = testLogging("sonar.log.level", "DEBUG");
assertThat(analysisProps.getProperty("sonar.log.level")).isEqualTo("DEBUG");
}
- private Properties testLogging(String propKey, String propValue) throws IOException {
+ private Properties testLogging(String propKey, String propValue) {
Properties p = new Properties();
p.put(propKey, propValue);
when(conf.properties()).thenReturn(p);