]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11989 Send notification when doing manual operations on Security Hotspots
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 13 May 2019 12:23:23 +0000 (14:23 +0200)
committerSonarTech <sonartech@sonarsource.com>
Wed, 22 May 2019 18:21:14 +0000 (20:21 +0200)
server/sonar-server/src/main/java/org/sonar/server/issue/IssueUpdater.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueUpdaterTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java

index 5f88b73eab8f08345a5afc5826db7229c89eff5f..5423d2b7ddda35284f44847a53907576d031c529 100644 (file)
@@ -24,7 +24,6 @@ import java.util.Optional;
 import javax.annotation.Nullable;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
-import org.sonar.api.rules.RuleType;
 import org.sonar.core.issue.DefaultIssue;
 import org.sonar.core.issue.IssueChangeContext;
 import org.sonar.core.util.stream.MoreCollectors;
@@ -93,9 +92,9 @@ public class IssueUpdater {
   private IssueDto doSaveIssue(DbSession session, DefaultIssue issue, IssueChangeContext context,
     Optional<RuleDefinitionDto> rule, ComponentDto project, BranchDto branchDto) {
     IssueDto issueDto = issueStorage.save(session, singletonList(issue)).iterator().next();
-    if (issue.type() == RuleType.SECURITY_HOTSPOT
+    if (
       // since this method is called after an update of the issue, date should never be null
-      || issue.updateDate() == null
+      issue.updateDate() == null
       // name of rule is displayed in notification, rule must therefor be present
       || !rule.isPresent()
       // notification are not supported on PRs and short lived branches
index 1a86962ef86435e79f999abcdf668dc42540ec9b..d48efd5e36c4e99f78fd331ca0b3506e545ce444 100644 (file)
@@ -54,9 +54,7 @@ import org.sonar.server.rule.DefaultRuleFinder;
 
 import static org.apache.commons.lang.math.RandomUtils.nextInt;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.sonar.api.issue.Issue.RESOLUTION_FIXED;
@@ -172,26 +170,6 @@ public class IssueUpdaterTest {
     assertThat(builder.getChange()).isEqualTo(new UserChange(issue.updateDate().getTime(), userOf(changeAuthor)));
   }
 
-  @Test
-  public void verify_no_notification_on_hotspot() {
-    UserDto assignee = db.users().insertUser();
-    RuleDto rule = db.rules().insertRule();
-    ComponentDto project = db.components().insertMainBranch();
-    ComponentDto file = db.components().insertComponent(newFileDto(project));
-    DefaultIssue issue = db.issues().insertIssue(IssueTesting.newIssue(rule.getDefinition(), project, file)
-      .setType(RuleType.SECURITY_HOTSPOT))
-      .setSeverity(MAJOR)
-      .setAssigneeUuid(assignee.getUuid())
-      .toDefaultIssue();
-    UserDto changeAuthor = db.users().insertUser();
-    IssueChangeContext context = IssueChangeContext.createUser(new Date(), changeAuthor.getUuid());
-    issueFieldsSetter.setSeverity(issue, BLOCKER, context);
-
-    underTest.saveIssueAndPreloadSearchResponseData(db.getSession(), issue, context, false);
-
-    verify(notificationManager, never()).scheduleForSending(any());
-  }
-
   @Test
   public void verify_notification_on_long_branch() {
     RuleDto rule = db.rules().insertRule();
index b0b867ae0eb8c680a0780c7b3bac115ac8d74f0b..412b33110371d631ebb2cb5f434f0682eabef3f4 100644 (file)
@@ -56,9 +56,7 @@ import static org.junit.rules.ExpectedException.none;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.sonar.api.rules.RuleType.CODE_SMELL;
-import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT;
 import static org.sonar.api.web.UserRole.CODEVIEWER;
 import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.server.tester.UserSessionRule.standalone;
@@ -192,23 +190,6 @@ public class AssignActionTest {
     verify(notificationManager).scheduleForSending(any(IssuesChangesNotification.class));
   }
 
-  @Test
-  public void do_not_send_notification_on_security_hotspot() {
-    IssueDto issue = db.issues().insertIssue(
-      issueDto -> issueDto
-        .setAssigneeUuid(null)
-        .setType(SECURITY_HOTSPOT));
-    setUserWithBrowsePermission(issue);
-    UserDto arthur = insertUser("arthur");
-
-    ws.newRequest()
-      .setParam("issue", issue.getKey())
-      .setParam("assignee", arthur.getLogin())
-      .execute();
-
-    verifyZeroInteractions(notificationManager);
-  }
-
   @Test
   public void fail_when_assignee_does_not_exist() {
     IssueDto issue = newIssueWithBrowsePermission();