aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKlaudio Sinani <klaudio.sinani@sonarsource.com>2021-11-17 22:54:06 +0100
committersonartech <sonartech@sonarsource.com>2021-11-19 20:03:27 +0000
commita3d88ea27c35921647d7602755828ca73e15e865 (patch)
tree5626c38afab1ea00ab9897da431476c17b478bbe /plugins
parent92f482f2aa43e4aa36e0fda377d13b9dc3282ff9 (diff)
downloadsonarqube-a3d88ea27c35921647d7602755828ca73e15e865.tar.gz
sonarqube-a3d88ea27c35921647d7602755828ca73e15e865.zip
SONAR-15631 - Refactor UTs to stop using ExpectedException
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/ItCoverageSensorTest.java4
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/OverallCoverageSensorTest.java4
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/UtCoverageSensorTest.java4
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java4
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java12
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SignificantCodeSensorTest.java4
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java2
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooBuiltInQualityProfilesDefinitionTest.java5
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java10
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooIgnoreCommandTest.java4
10 files changed, 8 insertions, 45 deletions
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/ItCoverageSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/ItCoverageSensorTest.java
index 8343607715e..b02f4c0cb22 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/ItCoverageSensorTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/ItCoverageSensorTest.java
@@ -25,7 +25,6 @@ import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
@@ -42,9 +41,6 @@ public class ItCoverageSensorTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
private File baseDir;
@Before
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/OverallCoverageSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/OverallCoverageSensorTest.java
index 6c92197f1a5..6c2d354f42b 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/OverallCoverageSensorTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/OverallCoverageSensorTest.java
@@ -25,7 +25,6 @@ import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
@@ -42,9 +41,6 @@ public class OverallCoverageSensorTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
private File baseDir;
@Before
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/UtCoverageSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/UtCoverageSensorTest.java
index 566e0bb538c..b3630c7ec18 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/UtCoverageSensorTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/UtCoverageSensorTest.java
@@ -25,7 +25,6 @@ import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
@@ -42,9 +41,6 @@ public class UtCoverageSensorTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
private File baseDir;
@Before
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java
index 30140780e39..e6a776c4470 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java
@@ -25,7 +25,6 @@ import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
@@ -43,9 +42,6 @@ public class CpdTokenizerSensorTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
private File baseDir;
@Before
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java
index 1a45e34b678..af815b66dc9 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java
@@ -26,17 +26,17 @@ import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.measure.MetricFinder;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
+import org.sonar.api.batch.measure.MetricFinder;
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
import org.sonar.api.batch.sensor.internal.SensorContextTester;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Metric;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -48,9 +48,6 @@ public class MeasureSensorTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
private File baseDir;
private MetricFinder metricFinder;
@@ -124,8 +121,7 @@ public class MeasureSensorTest {
InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build();
context.fileSystem().add(inputFile);
- thrown.expect(IllegalStateException.class);
-
- sensor.execute(context);
+ assertThatThrownBy(() -> sensor.execute(context))
+ .isInstanceOf(IllegalStateException.class);
}
}
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SignificantCodeSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SignificantCodeSensorTest.java
index ba322ce09fd..d263ce5b55c 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SignificantCodeSensorTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SignificantCodeSensorTest.java
@@ -25,7 +25,6 @@ import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.TextRange;
@@ -44,9 +43,6 @@ public class SignificantCodeSensorTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
private File baseDir;
private InputFile inputFile;
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java
index 3f4cd46a781..7e488b9c516 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java
@@ -26,9 +26,9 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.sonar.api.batch.sensor.highlighting.TypeOfText;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
+import org.sonar.api.batch.sensor.highlighting.TypeOfText;
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
import org.sonar.api.batch.sensor.internal.SensorContextTester;
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooBuiltInQualityProfilesDefinitionTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooBuiltInQualityProfilesDefinitionTest.java
index 3fc4d423ef3..3cb207ae016 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooBuiltInQualityProfilesDefinitionTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooBuiltInQualityProfilesDefinitionTest.java
@@ -19,9 +19,7 @@
*/
package org.sonar.xoo.rule;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition;
import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.BuiltInQualityProfile;
@@ -30,9 +28,6 @@ import static org.assertj.core.api.Assertions.assertThat;
public class XooBuiltInQualityProfilesDefinitionTest {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
private XooBuiltInQualityProfilesDefinition underTest = new XooBuiltInQualityProfilesDefinition();
@Test
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java
index 599574f3e56..6b414833462 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java
@@ -26,14 +26,13 @@ import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
-import org.sonar.api.batch.scm.BlameCommand.BlameInput;
-import org.sonar.api.batch.scm.BlameCommand.BlameOutput;
-import org.sonar.api.batch.scm.BlameLine;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
+import org.sonar.api.batch.scm.BlameCommand.BlameInput;
+import org.sonar.api.batch.scm.BlameCommand.BlameOutput;
+import org.sonar.api.batch.scm.BlameLine;
import org.sonar.api.utils.DateUtils;
import org.sonar.xoo.Xoo;
@@ -47,9 +46,6 @@ public class XooBlameCommandTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
private DefaultFileSystem fs;
private File baseDir;
private BlameInput input;
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooIgnoreCommandTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooIgnoreCommandTest.java
index 7e1c2937ef1..7b85a276f0d 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooIgnoreCommandTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooIgnoreCommandTest.java
@@ -24,7 +24,6 @@ import java.io.IOException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,9 +34,6 @@ public class XooIgnoreCommandTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
private File baseDir;
@Before