]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7098 Add IT 677/head
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 7 Dec 2015 13:23:06 +0000 (14:23 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 7 Dec 2015 16:58:32 +0000 (17:58 +0100)
it/it-tests/src/test/java/it/issue/AutoAssignTest.java

index ad083ada417e67984b3baee0f76d7c9cc3986096..2fe25024e313b29e0e4d59a76a0840bb91b3de3e 100644 (file)
@@ -1,9 +1,11 @@
 package it.issue;
 
+import java.util.List;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.sonar.wsclient.issue.Issue;
 import org.sonar.wsclient.issue.IssueQuery;
 import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.WsResponse;
@@ -68,6 +70,41 @@ public class AutoAssignTest extends AbstractIssueTest {
     assertThat(search(IssueQuery.create().assigned(false)).list()).isEmpty();
   }
 
+  /**
+   * SONAR-7098
+   *
+   * Given two versions of same project:
+   * v1: issue, but no SCM data
+   * v2: old issue and SCM data
+   * Expected: all issues should be associated with authors
+   */
+  @Test
+  public void update_author_and_assignee_when_scm_is_activated() {
+    createUser(SIMON_USER, SIMON_USER);
+
+    // Run a first analysis without SCM
+    projectAnalysis.withProperties("sonar.scm.disabled", "true").run();
+    List<Issue> issues = searchIssues();
+    assertThat(issues).isNotEmpty();
+
+    // No author and assignee are set
+    for (Issue issue : issues) {
+      assertThat(issue.author()).isEmpty();
+    }
+    assertThat(search(IssueQuery.create().assigned(true)).list()).isEmpty();
+
+    // Run a second analysis with SCM
+    projectAnalysis.run();
+    issues = searchIssues();
+    assertThat(issues).isNotEmpty();
+
+    // Authors and assignees are set
+    for (Issue issue : issues) {
+      assertThat(issue.author()).isNotEmpty();
+    }
+    assertThat(search(IssueQuery.create().assignees(SIMON_USER)).list()).hasSize(3);
+  }
+
   private void createUser(String login, String password) {
     WsResponse response = newAdminWsClient(ORCHESTRATOR).wsConnector().call(
       new PostRequest("api/users/create")