aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/test/java/org/sonar/scanner/DefaultFileLinesContextTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-scanner-engine/src/test/java/org/sonar/scanner/DefaultFileLinesContextTest.java')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/DefaultFileLinesContextTest.java18
1 files changed, 7 insertions, 11 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/DefaultFileLinesContextTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/DefaultFileLinesContextTest.java
index b9a4b4d0c1e..5d12e1eafd0 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/DefaultFileLinesContextTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/DefaultFileLinesContextTest.java
@@ -21,18 +21,17 @@ package org.sonar.scanner;
import java.util.List;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.mockito.ArgumentCaptor;
-import org.sonar.api.batch.measure.MetricFinder;
-import org.sonar.api.batch.sensor.internal.SensorStorage;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
+import org.sonar.api.batch.measure.MetricFinder;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
import org.sonar.api.measures.CoreMetrics;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.tuple;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -47,9 +46,6 @@ public class DefaultFileLinesContextTest {
private static final String AUTHOR_METRIC_KEY = "author";
private static final String BRANCHES_METRIC_KEY = "branches";
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
private DefaultFileLinesContext fileLineMeasures;
private SensorStorage sensorStorage;
@@ -96,14 +92,14 @@ public class DefaultFileLinesContextTest {
@Test
public void validateLineGreaterThanZero() {
- thrown.expectMessage("Line number should be positive for file src/foo.php.");
- fileLineMeasures.setIntValue(HITS_METRIC_KEY, 0, 2);
+ assertThatThrownBy(() -> fileLineMeasures.setIntValue(HITS_METRIC_KEY, 0, 2))
+ .hasMessage("Line number should be positive for file src/foo.php.");
}
@Test
public void validateLineLowerThanLineCount() {
- thrown.expectMessage("Line 4 is out of range for file src/foo.php. File has 3 lines");
- fileLineMeasures.setIntValue(HITS_METRIC_KEY, 4, 2);
+ assertThatThrownBy(() -> fileLineMeasures.setIntValue(HITS_METRIC_KEY, 4, 2))
+ .hasMessageContaining("Line 4 is out of range for file src/foo.php. File has 3 lines");
}
@Test