aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-05-10 12:32:56 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-05-11 12:26:46 +0200
commit0e6cefb238f064259b13db23a50b0cfa66aa7790 (patch)
tree65c2086e3b31477ba7438cffa5b6659441fe5c34
parent64fa9230e6346dd4bacb1855705630e877fd9f17 (diff)
downloadsonarqube-0e6cefb238f064259b13db23a50b0cfa66aa7790.tar.gz
sonarqube-0e6cefb238f064259b13db23a50b0cfa66aa7790.zip
Add missing ITs execution
-rw-r--r--it/it-tests/src/test/java/it/Category2Suite.java4
-rw-r--r--it/it-tests/src/test/java/it/issue/IssueMeasureTest.java42
-rw-r--r--it/it-tests/src/test/resources/issue/one-issue-per-file-profile.xml12
3 files changed, 25 insertions, 33 deletions
diff --git a/it/it-tests/src/test/java/it/Category2Suite.java b/it/it-tests/src/test/java/it/Category2Suite.java
index 247a001df22..c008a6be085 100644
--- a/it/it-tests/src/test/java/it/Category2Suite.java
+++ b/it/it-tests/src/test/java/it/Category2Suite.java
@@ -26,7 +26,9 @@ import it.issue.CustomRulesTest;
import it.issue.IssueActionTest;
import it.issue.IssueBulkChangeTest;
import it.issue.IssueChangelogTest;
+import it.issue.IssueCreationTest;
import it.issue.IssueFilterExtensionTest;
+import it.issue.IssueMeasureTest;
import it.issue.IssueNotificationsTest;
import it.issue.IssuePurgeTest;
import it.issue.IssueSearchTest;
@@ -67,7 +69,9 @@ import static util.ItUtils.xooPlugin;
IssueActionTest.class,
IssueBulkChangeTest.class,
IssueChangelogTest.class,
+ IssueCreationTest.class,
IssueFilterExtensionTest.class,
+ IssueMeasureTest.class,
IssueNotificationsTest.class,
IssuePurgeTest.class,
IssueSearchTest.class,
diff --git a/it/it-tests/src/test/java/it/issue/IssueMeasureTest.java b/it/it-tests/src/test/java/it/issue/IssueMeasureTest.java
index 963071c2dc8..016e2da5c45 100644
--- a/it/it-tests/src/test/java/it/issue/IssueMeasureTest.java
+++ b/it/it-tests/src/test/java/it/issue/IssueMeasureTest.java
@@ -19,14 +19,13 @@
*/
package it.issue;
-import com.google.common.collect.ImmutableMap;
import com.sonar.orchestrator.locator.FileLocation;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.sonar.wsclient.Sonar;
import org.sonar.wsclient.issue.Issue;
-import org.sonar.wsclient.issue.NewIssue;
+import org.sonar.wsclient.issue.IssueQuery;
import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.ResourceQuery;
@@ -50,16 +49,16 @@ public class IssueMeasureTest extends AbstractIssueTest {
ORCHESTRATOR.getServer().associateProjectToQualityProfile(MULTI_MODULE_SAMPLE_PROJECT_KEY, "xoo", "with-many-rules");
runProjectAnalysis(ORCHESTRATOR, "shared/xoo-multi-modules-sample");
- assertThat(searchIssuesByProject(MULTI_MODULE_SAMPLE_PROJECT_KEY)).hasSize(71);
+ assertThat(search(IssueQuery.create().componentRoots(MULTI_MODULE_SAMPLE_PROJECT_KEY)).paging().total()).isEqualTo(136);
Resource project = ORCHESTRATOR.getServer().getWsClient()
.find(ResourceQuery.createForMetrics(MULTI_MODULE_SAMPLE_PROJECT_KEY, "violations", "info_violations", "minor_violations", "major_violations",
"blocker_violations", "critical_violations"));
- assertThat(project.getMeasureIntValue("violations")).isEqualTo(71);
+ assertThat(project.getMeasureIntValue("violations")).isEqualTo(136);
assertThat(project.getMeasureIntValue("info_violations")).isEqualTo(2);
assertThat(project.getMeasureIntValue("minor_violations")).isEqualTo(61);
- assertThat(project.getMeasureIntValue("major_violations")).isEqualTo(4);
- assertThat(project.getMeasureIntValue("blocker_violations")).isEqualTo(0);
+ assertThat(project.getMeasureIntValue("major_violations")).isEqualTo(65);
+ assertThat(project.getMeasureIntValue("blocker_violations")).isEqualTo(4);
assertThat(project.getMeasureIntValue("critical_violations")).isEqualTo(4);
}
@@ -117,38 +116,15 @@ public class IssueMeasureTest extends AbstractIssueTest {
String testKey = "sample-with-tests:src/test/xoo/sample/SampleTest.xoo";
ORCHESTRATOR.getServer().provisionProject(projectKey, projectKey);
- ORCHESTRATOR.getServer().restoreProfile(FileLocation.ofClasspath("/issue/one-issue-per-line-profile.xml"));
- ORCHESTRATOR.getServer().associateProjectToQualityProfile(projectKey, "xoo", "one-issue-per-line-profile");
+ ORCHESTRATOR.getServer().restoreProfile(FileLocation.ofClasspath("/issue/one-issue-per-file-profile.xml"));
+ ORCHESTRATOR.getServer().associateProjectToQualityProfile(projectKey, "xoo", "one-issue-per-file-profile");
runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample-with-tests");
Sonar wsClient = ORCHESTRATOR.getServer().getAdminWsClient();
// Store current number of issues
- Resource project = wsClient.find(ResourceQuery.createForMetrics(projectKey, "violations"));
- int issues = project.getMeasureIntValue("violations");
-
- // Create the manual rule
- createManualRule();
-
- // Create a issue on the test source file
- adminIssueClient().create(NewIssue.create().component(testKey)
- .severity("MAJOR")
- .rule("manual:invalidclassname").line(8)
- .message("The name 'SampleTest' is too generic"));
-
- // Re-analyse the project
- runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample-with-tests");
-
- // And check that the number of issues metrics have changed
- project = wsClient.find(ResourceQuery.createForMetrics(projectKey, "violations"));
- assertThat(project.getMeasureIntValue("violations")).isEqualTo(issues + 1);
+ Resource project = wsClient.find(ResourceQuery.createForMetrics(testKey, "violations"));
+ assertThat(project.getMeasureIntValue("violations")).isEqualTo(1);
}
- private static void createManualRule() {
- ORCHESTRATOR.getServer().adminWsClient().post("/api/rules/create", ImmutableMap.<String, Object>of(
- "manual_key", "invalidclassname",
- "name", "InvalidClassName",
- "markdown_description", "Invalid class name"
- ));
- }
}
diff --git a/it/it-tests/src/test/resources/issue/one-issue-per-file-profile.xml b/it/it-tests/src/test/resources/issue/one-issue-per-file-profile.xml
new file mode 100644
index 00000000000..141921f02e7
--- /dev/null
+++ b/it/it-tests/src/test/resources/issue/one-issue-per-file-profile.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0"?><!-- Generated by Sonar -->
+<profile>
+ <name>one-issue-per-file-profile</name>
+ <language>xoo</language>
+ <rules>
+ <rule>
+ <repositoryKey>xoo</repositoryKey>
+ <key>OneIssuePerFile</key>
+ <priority>CRITICAL</priority>
+ </rule>
+ </rules>
+</profile>