diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-07-24 10:08:50 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-07-28 08:02:43 +0200 |
commit | b9fbae13635f53c5a6cc8bb50130a3a3bf42ee84 (patch) | |
tree | 2e477e2ffa0481c119311b4177baef85a93c557c /it | |
parent | aa19dea88d89470eb1ae59220ed38c7194636bdd (diff) | |
download | sonarqube-b9fbae13635f53c5a6cc8bb50130a3a3bf42ee84.tar.gz sonarqube-b9fbae13635f53c5a6cc8bb50130a3a3bf42ee84.zip |
Compute engine must not load ActiveRules with status REMOVED
Diffstat (limited to 'it')
6 files changed, 85 insertions, 1 deletions
diff --git a/it/it-projects/issue/workflow/sonar-project.properties b/it/it-projects/issue/workflow/sonar-project.properties new file mode 100644 index 00000000000..fbfcc6930d0 --- /dev/null +++ b/it/it-projects/issue/workflow/sonar-project.properties @@ -0,0 +1,4 @@ +sonar.projectKey=workflow +sonar.projectName=Workflow +sonar.projectVersion=1.0-SNAPSHOT +sonar.sources=src diff --git a/it/it-projects/issue/workflow/src/Sample.xoo b/it/it-projects/issue/workflow/src/Sample.xoo new file mode 100644 index 00000000000..e2ae9e37278 --- /dev/null +++ b/it/it-projects/issue/workflow/src/Sample.xoo @@ -0,0 +1,3 @@ +this is some +xoo +code diff --git a/it/it-projects/issue/workflow/src/Sample.xoo.measures b/it/it-projects/issue/workflow/src/Sample.xoo.measures new file mode 100644 index 00000000000..16cc5ac1540 --- /dev/null +++ b/it/it-projects/issue/workflow/src/Sample.xoo.measures @@ -0,0 +1,10 @@ +lines:120 +ncloc:100 +complexity:7 +comment_lines:3 +public_api:5 +public_undocumented_api:2 +lines_to_cover:80 +uncovered_lines:70 +conditions_to_cover:10 +uncovered_conditions:9 diff --git a/it/it-tests/src/test/java/issue/suite/IssueTestSuite.java b/it/it-tests/src/test/java/issue/suite/IssueTestSuite.java index 4f61aa5edc4..b0f83bec168 100644 --- a/it/it-tests/src/test/java/issue/suite/IssueTestSuite.java +++ b/it/it-tests/src/test/java/issue/suite/IssueTestSuite.java @@ -13,7 +13,7 @@ import util.ItUtils; @RunWith(Suite.class) @Suite.SuiteClasses({ - ManualRulesTest.class, CommonRulesTest.class + CommonRulesTest.class, IssueWorkflowTest.class, ManualRulesTest.class, }) public class IssueTestSuite { diff --git a/it/it-tests/src/test/java/issue/suite/IssueWorkflowTest.java b/it/it-tests/src/test/java/issue/suite/IssueWorkflowTest.java new file mode 100644 index 00000000000..4e8b67e2c3c --- /dev/null +++ b/it/it-tests/src/test/java/issue/suite/IssueWorkflowTest.java @@ -0,0 +1,55 @@ +package issue.suite; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarRunner; +import com.sonar.orchestrator.locator.FileLocation; +import java.util.List; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import org.sonar.wsclient.issue.Issue; +import org.sonar.wsclient.issue.IssueClient; +import org.sonar.wsclient.issue.IssueQuery; + +import static org.assertj.core.api.Assertions.assertThat; +import static util.ItUtils.projectDir; + +public class IssueWorkflowTest { + + @ClassRule + public static Orchestrator orchestrator = IssueTestSuite.ORCHESTRATOR; + + @Before + public void setUp() { + orchestrator.resetData(); + } + + /** + * Issue on a disabled rule (uninstalled plugin or rule deactivated from quality profile) must + * be CLOSED with resolution REMOVED + */ + @Test + public void issue_is_closed_as_removed_when_rule_is_disabled() throws Exception { + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/issue/suite/IssueWorkflowTest/xoo-one-issue-per-line-profile.xml")); + orchestrator.getServer().provisionProject("workflow", "Workflow"); + orchestrator.getServer().associateProjectToQualityProfile("workflow", "xoo", "xoo-one-issue-per-line-profile"); + + SonarRunner analysis = SonarRunner.create(projectDir("issue/workflow")); + orchestrator.executeBuild(analysis); + + IssueClient issueClient = orchestrator.getServer().wsClient().issueClient(); + List<Issue> issues = issueClient.find(IssueQuery.create().rules("xoo:OneIssuePerLine")).list(); + assertThat(issues).isNotEmpty(); + + // re-analyze with profile "empty". The rule is disabled so the issues must be closed + orchestrator.getServer().associateProjectToQualityProfile("workflow", "xoo", "empty"); + analysis = SonarRunner.create(projectDir("issue/workflow")); + orchestrator.executeBuild(analysis); + issues = issueClient.find(IssueQuery.create().rules("xoo:OneIssuePerLine").componentRoots("workflow")).list(); + assertThat(issues).isNotEmpty(); + for (Issue issue : issues) { + assertThat(issue.status()).isEqualTo("CLOSED"); + assertThat(issue.resolution()).isEqualTo("REMOVED"); + } + } +} diff --git a/it/it-tests/src/test/resources/issue/suite/IssueWorkflowTest/xoo-one-issue-per-line-profile.xml b/it/it-tests/src/test/resources/issue/suite/IssueWorkflowTest/xoo-one-issue-per-line-profile.xml new file mode 100644 index 00000000000..608f80cae96 --- /dev/null +++ b/it/it-tests/src/test/resources/issue/suite/IssueWorkflowTest/xoo-one-issue-per-line-profile.xml @@ -0,0 +1,12 @@ +<?xml version="1.0"?><!-- Generated by Sonar --> +<profile> + <name>xoo-one-issue-per-line-profile</name> + <language>xoo</language> + <rules> + <rule> + <repositoryKey>xoo</repositoryKey> + <key>OneIssuePerLine</key> + <priority>CRITICAL</priority> + </rule> + </rules> +</profile> |