aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-12-07 14:22:52 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-12-07 17:58:31 +0100
commitf55222d86df4f24636ee3d1ae6d7877a9e952bc6 (patch)
tree084cfef834cd599a44a9d8f8e9f6c7d6d4b641a7 /it
parent6cf62f0adc9677404df3ff457135591c17ad89a5 (diff)
downloadsonarqube-f55222d86df4f24636ee3d1ae6d7877a9e952bc6.tar.gz
sonarqube-f55222d86df4f24636ee3d1ae6d7877a9e952bc6.zip
Add ITs for auto assign feature
Diffstat (limited to 'it')
-rw-r--r--it/it-projects/issue/xoo-with-scm/sonar-project.properties4
-rw-r--r--it/it-projects/issue/xoo-with-scm/src/main/xoo/sample/Sample.xoo12
-rw-r--r--it/it-projects/issue/xoo-with-scm/src/main/xoo/sample/Sample.xoo.measures2
-rw-r--r--it/it-projects/issue/xoo-with-scm/src/main/xoo/sample/Sample.xoo.scm13
-rw-r--r--it/it-tests/src/test/java/it/issue/AutoAssignTest.java79
5 files changed, 110 insertions, 0 deletions
diff --git a/it/it-projects/issue/xoo-with-scm/sonar-project.properties b/it/it-projects/issue/xoo-with-scm/sonar-project.properties
new file mode 100644
index 00000000000..90da9733771
--- /dev/null
+++ b/it/it-projects/issue/xoo-with-scm/sonar-project.properties
@@ -0,0 +1,4 @@
+sonar.projectKey=sample
+sonar.projectName=Sample
+sonar.projectVersion=1.0-SNAPSHOT
+sonar.sources=src/main/xoo
diff --git a/it/it-projects/issue/xoo-with-scm/src/main/xoo/sample/Sample.xoo b/it/it-projects/issue/xoo-with-scm/src/main/xoo/sample/Sample.xoo
new file mode 100644
index 00000000000..b1210973dd9
--- /dev/null
+++ b/it/it-projects/issue/xoo-with-scm/src/main/xoo/sample/Sample.xoo
@@ -0,0 +1,12 @@
+package sample;
+
+public class Sample {
+
+ public Sample(int i) {
+ int j = i++;
+ }
+
+ private String myMethod() {
+ return "hello";
+ }
+}
diff --git a/it/it-projects/issue/xoo-with-scm/src/main/xoo/sample/Sample.xoo.measures b/it/it-projects/issue/xoo-with-scm/src/main/xoo/sample/Sample.xoo.measures
new file mode 100644
index 00000000000..592bb930674
--- /dev/null
+++ b/it/it-projects/issue/xoo-with-scm/src/main/xoo/sample/Sample.xoo.measures
@@ -0,0 +1,2 @@
+lines:13
+ncloc:13
diff --git a/it/it-projects/issue/xoo-with-scm/src/main/xoo/sample/Sample.xoo.scm b/it/it-projects/issue/xoo-with-scm/src/main/xoo/sample/Sample.xoo.scm
new file mode 100644
index 00000000000..f77a3b3930f
--- /dev/null
+++ b/it/it-projects/issue/xoo-with-scm/src/main/xoo/sample/Sample.xoo.scm
@@ -0,0 +1,13 @@
+1,fabrice,2011-12-04
+1,fabrice,2011-12-04
+2,simon,2015-12-04
+2,simon,2015-12-04
+2,simon,2015-12-04
+3,seb,2015-01-01
+4,julien,2015-12-01
+4,julien,2015-12-01
+4,julien,2015-12-01
+4,julien,2015-12-01
+4,julien,2015-12-01
+4,julien,2015-12-01
+4,julien,2015-12-01
diff --git a/it/it-tests/src/test/java/it/issue/AutoAssignTest.java b/it/it-tests/src/test/java/it/issue/AutoAssignTest.java
new file mode 100644
index 00000000000..ad083ada417
--- /dev/null
+++ b/it/it-tests/src/test/java/it/issue/AutoAssignTest.java
@@ -0,0 +1,79 @@
+package it.issue;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.wsclient.issue.IssueQuery;
+import org.sonarqube.ws.client.PostRequest;
+import org.sonarqube.ws.client.WsResponse;
+import util.ProjectAnalysis;
+import util.ProjectAnalysisRule;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static util.ItUtils.newAdminWsClient;
+import static util.ItUtils.setServerProperty;
+
+public class AutoAssignTest extends AbstractIssueTest {
+
+ static final String SIMON_USER = "simon";
+
+ @Rule
+ public final ProjectAnalysisRule projectAnalysisRule = ProjectAnalysisRule.from(ORCHESTRATOR);
+
+ ProjectAnalysis projectAnalysis;
+
+ @Before
+ public void setup() {
+ ORCHESTRATOR.resetData();
+
+ String qualityProfileKey = projectAnalysisRule.registerProfile("/issue/IssueActionTest/xoo-one-issue-per-line-profile.xml");
+ String projectKey = projectAnalysisRule.registerProject("issue/xoo-with-scm");
+ projectAnalysis = projectAnalysisRule.newProjectAnalysis(projectKey)
+ .withQualityProfile(qualityProfileKey)
+ .withProperties("sonar.scm.disabled", "false", "sonar.scm.provider", "xoo");
+ }
+
+ @After
+ public void resetData() throws Exception {
+ // Remove user simon
+ newAdminWsClient(ORCHESTRATOR).wsConnector().call(
+ new PostRequest("api/users/deactivate")
+ .setParam("login", SIMON_USER));
+
+ // Reset default assignee
+ setServerProperty(ORCHESTRATOR, "sonar.issues.defaultAssigneeLogin", null);
+ }
+
+ @Test
+ public void auto_assign_issues_to_user() throws Exception {
+ createUser(SIMON_USER, SIMON_USER);
+ projectAnalysis.run();
+
+ // Simon has 3 issues
+ assertThat(search(IssueQuery.create().assignees(SIMON_USER)).list()).hasSize(3);
+ // Other issues are not assigned as no user have been created on their author
+ assertThat(search(IssueQuery.create().assigned(false)).list()).hasSize(10);
+ }
+
+ @Test
+ public void auto_assign_issues_to_default_assignee() throws Exception {
+ createUser(SIMON_USER, SIMON_USER);
+ setServerProperty(ORCHESTRATOR, "sonar.issues.defaultAssigneeLogin", SIMON_USER);
+ projectAnalysis.run();
+
+ // Simon has all issues
+ assertThat(search(IssueQuery.create().assignees(SIMON_USER)).list()).hasSize(13);
+ // No unassigned issues
+ assertThat(search(IssueQuery.create().assigned(false)).list()).isEmpty();
+ }
+
+ private void createUser(String login, String password) {
+ WsResponse response = newAdminWsClient(ORCHESTRATOR).wsConnector().call(
+ new PostRequest("api/users/create")
+ .setParam("login", login)
+ .setParam("name", login)
+ .setParam("password", password));
+ assertThat(response.code()).isEqualTo(200);
+ }
+}