aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2019-05-13 14:23:23 +0200
committerSonarTech <sonartech@sonarsource.com>2019-05-22 20:21:14 +0200
commit3775e29dbe727665644e7f0f4312cacb80518b38 (patch)
tree41c554e5059b1ba1dd3250873ec03ab64d0fe893 /server
parent020c4390d4d830041ec5f640a543d2f56101c16f (diff)
downloadsonarqube-3775e29dbe727665644e7f0f4312cacb80518b38.tar.gz
sonarqube-3775e29dbe727665644e7f0f4312cacb80518b38.zip
SONAR-11989 Send notification when doing manual operations on Security Hotspots
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/IssueUpdater.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/IssueUpdaterTest.java22
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java19
3 files changed, 2 insertions, 44 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueUpdater.java
index 5f88b73eab8..5423d2b7ddd 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueUpdater.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueUpdater.java
@@ -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
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueUpdaterTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueUpdaterTest.java
index 1a86962ef86..d48efd5e36c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueUpdaterTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueUpdaterTest.java
@@ -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;
@@ -173,26 +171,6 @@ public class IssueUpdaterTest {
}
@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();
ComponentDto project = db.components().insertMainBranch();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
index b0b867ae0eb..412b3311037 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
@@ -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;
@@ -193,23 +191,6 @@ public class AssignActionTest {
}
@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();