aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorKlaudio Sinani <klaudio.sinani@sonarsource.com>2022-11-29 18:14:35 +0100
committersonartech <sonartech@sonarsource.com>2022-11-30 09:22:30 +0000
commit8fc6fc39c6389ab661d5443ecbcb37a069fc4993 (patch)
tree1d90b6cebef034aecbdc49ab40d43d5894e83c7e /sonar-scanner-engine
parentc7b457dfdff0f8bc7004ad44f3380326e76a6ca8 (diff)
downloadsonarqube-8fc6fc39c6389ab661d5443ecbcb37a069fc4993.tar.gz
sonarqube-8fc6fc39c6389ab661d5443ecbcb37a069fc4993.zip
SONAR-17560 Minor improvements on `RulesSeverityDetectorTest` test class
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RulesSeverityDetectorTest.java29
1 files changed, 8 insertions, 21 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RulesSeverityDetectorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RulesSeverityDetectorTest.java
index e3c5722abd7..7f35d2d553f 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RulesSeverityDetectorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RulesSeverityDetectorTest.java
@@ -51,6 +51,14 @@ public class RulesSeverityDetectorTest {
@org.junit.Rule
public LogTester logTester = new LogTester().setLevel(LoggerLevel.TRACE);
+ private final Run run = mock(Run.class);
+ private final Rule rule = mock(Rule.class);
+ private final Tool tool = mock(Tool.class);
+ private final Result result = mock(Result.class);
+ private final Driver driver = mock(Driver.class);
+ private final Extension extension = mock(Extension.class);
+ private final DefaultConfiguration defaultConfiguration = mock(DefaultConfiguration.class);
+
@Test
public void detectRulesSeverities_detectsCorrectlyResultDefinedRuleSeverities() {
Run run = mockResultDefinedRuleSeverities();
@@ -92,9 +100,6 @@ public class RulesSeverityDetectorTest {
}
private Run mockResultDefinedRuleSeverities() {
- Run run = mock(Run.class);
- Result result = mock(Result.class);
-
when(run.getResults()).thenReturn(Set.of(result));
when(result.getLevel()).thenReturn(WARNING);
when(result.getRuleId()).thenReturn(RULE_ID);
@@ -103,12 +108,6 @@ public class RulesSeverityDetectorTest {
}
private Run mockDriverDefinedRuleSeverities() {
- Run run = mock(Run.class);
- Tool tool = mock(Tool.class);
- Driver driver = mock(Driver.class);
- Rule rule = mock(Rule.class);
- DefaultConfiguration defaultConfiguration = mock(DefaultConfiguration.class);
-
when(run.getTool()).thenReturn(tool);
when(tool.getDriver()).thenReturn(driver);
when(driver.getRules()).thenReturn(Set.of(rule));
@@ -120,13 +119,6 @@ public class RulesSeverityDetectorTest {
}
private Run mockExtensionsDefinedRuleSeverities() {
- Run run = mock(Run.class);
- Tool tool = mock(Tool.class);
- Driver driver = mock(Driver.class);
- Extension extension = mock(Extension.class);
- Rule rule = mock(Rule.class);
- DefaultConfiguration defaultConfiguration = mock(DefaultConfiguration.class);
-
when(run.getTool()).thenReturn(tool);
when(tool.getDriver()).thenReturn(driver);
when(driver.getRules()).thenReturn(Set.of());
@@ -140,11 +132,6 @@ public class RulesSeverityDetectorTest {
}
private Run mockUnsupportedRuleSeveritiesDefinition() {
- Run run = mock(Run.class);
- Tool tool = mock(Tool.class);
- Driver driver = mock(Driver.class);
- Extension extension = mock(Extension.class);
-
when(run.getTool()).thenReturn(tool);
when(tool.getDriver()).thenReturn(driver);
when(driver.getRules()).thenReturn(Set.of());