diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-03-24 16:23:28 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-03-29 19:11:55 +0200 |
commit | 9fc9cbd7ed08be84e9f16dc0cdacc41dff63acad (patch) | |
tree | 1ee75718214eda42fbd86209d8ccb5ca3a5a7794 /sonar-scanner-engine/src/test/java/org/sonar/batch | |
parent | 73de53243b93e598098fc7a68a7cbf6128c2f88c (diff) | |
download | sonarqube-9fc9cbd7ed08be84e9f16dc0cdacc41dff63acad.tar.gz sonarqube-9fc9cbd7ed08be84e9f16dc0cdacc41dff63acad.zip |
SONAR-7470 Drop ability to manage manual rules from backend
Diffstat (limited to 'sonar-scanner-engine/src/test/java/org/sonar/batch')
2 files changed, 28 insertions, 63 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/issuesmode/IssueModeAndReportsMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/issuesmode/IssueModeAndReportsMediumTest.java index e02c84ec71a..c3ba10d7abc 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/issuesmode/IssueModeAndReportsMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/issuesmode/IssueModeAndReportsMediumTest.java @@ -19,13 +19,7 @@ */ package org.sonar.batch.mediumtest.issuesmode; -import org.apache.commons.lang.StringUtils; - -import org.sonar.api.utils.log.LoggerLevel; -import org.assertj.core.api.Condition; -import org.sonar.batch.issue.tracking.TrackedIssue; import com.google.common.collect.ImmutableMap; - import java.io.File; import java.io.IOException; import java.text.ParseException; @@ -33,17 +27,20 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.LinkedList; import java.util.List; - import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; +import org.apache.commons.lang.StringUtils; +import org.assertj.core.api.Condition; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.CoreProperties; import org.sonar.api.utils.log.LogTester; +import org.sonar.api.utils.log.LoggerLevel; import org.sonar.batch.bootstrapper.IssueListener; +import org.sonar.batch.issue.tracking.TrackedIssue; import org.sonar.batch.mediumtest.BatchMediumTester; import org.sonar.batch.mediumtest.TaskResult; import org.sonar.batch.scan.report.ConsoleReport; @@ -51,6 +48,7 @@ import org.sonar.scanner.protocol.Constants.Severity; import org.sonar.scanner.protocol.input.ScannerInput.ServerIssue; import org.sonar.xoo.XooPlugin; import org.sonar.xoo.rule.XooRulesDefinition; + import static org.assertj.core.api.Assertions.assertThat; public class IssueModeAndReportsMediumTest { @@ -76,12 +74,9 @@ public class IssueModeAndReportsMediumTest { .registerPlugin("xoo", new XooPlugin()) .addDefaultQProfile("xoo", "Sonar Way") .addRules(new XooRulesDefinition()) - .addRule("manual:MyManualIssue", "manual", "MyManualIssue", "My manual issue") - .addRule("manual:MyManualIssueDup", "manual", "MyManualIssue", "My manual issue") .addActiveRule("xoo", "OneIssuePerLine", null, "One issue per line", "MAJOR", null, "xoo") .addActiveRule("xoo", "OneIssueOnDirPerFile", null, "OneIssueOnDirPerFile", "MAJOR", null, "xoo") .addActiveRule("xoo", "OneIssuePerModule", null, "OneIssuePerModule", "MAJOR", null, "xoo") - .addActiveRule("manual", "MyManualIssue", null, "My manual issue", "MAJOR", null, null) .setPreviousAnalysisDate(new Date()) // Existing issue that is still detected .mockServerIssue(ServerIssue.newBuilder().setKey("xyz") @@ -116,18 +111,6 @@ public class IssueModeAndReportsMediumTest { .setCreationDate(date("14/03/2004")) .setStatus("OPEN") .build()) - // Manual issue - .mockServerIssue(ServerIssue.newBuilder().setKey("manual") - .setModuleKey("sample") - .setPath("xources/hello/HelloJava.xoo") - .setRuleRepository("manual") - .setRuleKey("MyManualIssue") - .setLine(1) - .setSeverity(Severity.MAJOR) - .setCreationDate(date("14/03/2004")) - .setChecksum(DigestUtils.md5Hex("packagehello;")) - .setStatus("OPEN") - .build()) .build(); @Before @@ -172,7 +155,7 @@ public class IssueModeAndReportsMediumTest { } System.out.println("new: " + newIssues + " open: " + openIssues + " resolved " + resolvedIssue); assertThat(newIssues).isEqualTo(16); - assertThat(openIssues).isEqualTo(3); + assertThat(openIssues).isEqualTo(2); assertThat(resolvedIssue).isEqualTo(1); // progress report @@ -214,7 +197,7 @@ public class IssueModeAndReportsMediumTest { .property("sonar.xoo.enablePostJob", "true") .start(); - assertThat(logTester.logs()).contains("Resolved issues: 1", "Open issues: 19"); + assertThat(logTester.logs()).contains("Resolved issues: 1", "Open issues: 18"); } private String getReportLog() { @@ -272,8 +255,8 @@ public class IssueModeAndReportsMediumTest { .setIssueListener(issueListener) .start(); - assertThat(result.trackedIssues()).hasSize(20); - assertThat(issueListener.issueList).hasSize(20); + assertThat(result.trackedIssues()).hasSize(19); + assertThat(issueListener.issueList).hasSize(19); } private class IssueRecorder implements IssueListener { diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/issuesmode/ScanOnlyChangedTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/issuesmode/ScanOnlyChangedTest.java index eb5850b0809..26d1c3653cc 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/issuesmode/ScanOnlyChangedTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/issuesmode/ScanOnlyChangedTest.java @@ -19,33 +19,31 @@ */ package org.sonar.batch.mediumtest.issuesmode; -import org.sonar.batch.issue.tracking.TrackedIssue; - -import org.assertj.core.api.Condition; -import com.google.common.io.Resources; -import org.sonar.batch.repository.FileData; -import org.sonar.scanner.protocol.Constants.Severity; -import org.sonar.scanner.protocol.input.ScannerInput.ServerIssue; import com.google.common.collect.ImmutableMap; +import com.google.common.io.Resources; +import java.io.File; +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; +import org.assertj.core.api.Condition; import org.junit.After; import org.junit.Before; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.sonar.api.CoreProperties; +import org.sonar.api.utils.log.LogTester; +import org.sonar.batch.issue.tracking.TrackedIssue; import org.sonar.batch.mediumtest.BatchMediumTester; +import org.sonar.batch.mediumtest.TaskResult; +import org.sonar.batch.repository.FileData; +import org.sonar.scanner.protocol.Constants.Severity; +import org.sonar.scanner.protocol.input.ScannerInput.ServerIssue; import org.sonar.xoo.XooPlugin; import org.sonar.xoo.rule.XooRulesDefinition; -import org.junit.rules.TemporaryFolder; -import org.sonar.api.utils.log.LogTester; -import org.junit.Test; -import org.sonar.batch.mediumtest.TaskResult; - -import java.io.File; -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; import static org.assertj.core.api.Assertions.assertThat; @@ -79,12 +77,9 @@ public class ScanOnlyChangedTest { .registerPlugin("xoo", new XooPlugin()) .addDefaultQProfile("xoo", "Sonar Way") .addRules(new XooRulesDefinition()) - .addRule("manual:MyManualIssue", "manual", "MyManualIssue", "My manual issue") - .addRule("manual:MyManualIssueDup", "manual", "MyManualIssue", "My manual issue") .addActiveRule("xoo", "OneIssuePerLine", null, "One issue per line", "MAJOR", null, "xoo") .addActiveRule("xoo", "OneIssueOnDirPerFile", null, "OneIssueOnDirPerFile", "MAJOR", null, "xoo") .addActiveRule("xoo", "OneIssuePerModule", null, "OneIssuePerModule", "MAJOR", null, "xoo") - .addActiveRule("manual", "MyManualIssue", null, "My manual issue", "MAJOR", null, null) // this will cause the file to have status==SAME .addFileData("sample", filePath, new FileData(md5sum, null)) .setPreviousAnalysisDate(new Date()) @@ -110,18 +105,6 @@ public class ScanOnlyChangedTest { .setCreationDate(date("14/03/2004")) .setStatus("OPEN") .build()) - // Manual issue - .mockServerIssue(ServerIssue.newBuilder().setKey("manual") - .setModuleKey("sample") - .setPath("xources/hello/HelloJava.xoo") - .setRuleRepository("manual") - .setRuleKey("MyManualIssue") - .setLine(1) - .setSeverity(Severity.MAJOR) - .setCreationDate(date("14/03/2004")) - .setChecksum(DigestUtils.md5Hex("packagehello;")) - .setStatus("OPEN") - .build()) .build(); tester.start(); } @@ -147,13 +130,12 @@ public class ScanOnlyChangedTest { .property("sonar.scanAllFiles", "true") .start(); - assertNumberIssues(result, 16, 3, 0); + assertNumberIssues(result, 16, 2, 0); /* * 8 new per line - * 1 manual */ - assertNumberIssuesOnFile(result, "HelloJava.xoo", 9); + assertNumberIssuesOnFile(result, "HelloJava.xoo", 8); } @Test @@ -172,10 +154,10 @@ public class ScanOnlyChangedTest { * 1 manual issue (open, not new) in HelloJava.xoo * 1 existing issue on the project (open, not new) */ - assertNumberIssues(result, 8, 3, 0); + assertNumberIssues(result, 8, 2, 0); // should only have server issues (HelloJava.xoo should not have been analyzed) - assertNumberIssuesOnFile(result, "HelloJava.xoo", 2); + assertNumberIssuesOnFile(result, "HelloJava.xoo", 1); } private static void assertNumberIssuesOnFile(TaskResult result, final String fileNameEndsWith, int issues) { |