From a9503346ee526d2d5cee4b74658736ec62846a69 Mon Sep 17 00:00:00 2001 From: Sébastien Lesaint Date: Tue, 26 Mar 2019 17:26:21 +0100 Subject: SONAR-11753 move "QG change" notification classes to single package --- .../ce/container/ComputeEngineContainerImpl.java | 4 +- .../java/org/sonar/server/event/NewAlerts.java | 74 ------- .../java/org/sonar/server/event/package-info.java | 23 --- .../notification/email/AlertsEmailTemplate.java | 129 ------------- .../notification/AlertsEmailTemplate.java | 129 +++++++++++++ .../server/qualitygate/notification/NewAlerts.java | 74 +++++++ .../qualitygate/notification/package-info.java | 23 +++ .../java/org/sonar/server/event/NewAlertsTest.java | 85 --------- .../notification/AlertsEmailTemplateTest.java | 212 +++++++++++++++++++++ .../qualitygate/notification/NewAlertsTest.java | 85 +++++++++ .../server/notification/ws/DispatchersImpl.java | 2 +- .../platform/platformlevel/PlatformLevel4.java | 2 +- .../email/AlertsEmailTemplateTest.java | 211 -------------------- .../notification/ws/DispatchersImplTest.java | 2 +- 14 files changed, 528 insertions(+), 527 deletions(-) delete mode 100644 server/sonar-server-common/src/main/java/org/sonar/server/event/NewAlerts.java delete mode 100644 server/sonar-server-common/src/main/java/org/sonar/server/event/package-info.java delete mode 100644 server/sonar-server-common/src/main/java/org/sonar/server/notification/email/AlertsEmailTemplate.java create mode 100644 server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/AlertsEmailTemplate.java create mode 100644 server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/NewAlerts.java create mode 100644 server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/package-info.java delete mode 100644 server/sonar-server-common/src/test/java/org/sonar/server/event/NewAlertsTest.java create mode 100644 server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/AlertsEmailTemplateTest.java create mode 100644 server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/NewAlertsTest.java delete mode 100644 server/sonar-server/src/test/java/org/sonar/server/notification/email/AlertsEmailTemplateTest.java (limited to 'server') diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java index 4e5a5d16b9a..f17fed85c8a 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java @@ -91,7 +91,7 @@ import org.sonar.server.component.index.ComponentIndexer; import org.sonar.server.config.ConfigurationProvider; import org.sonar.server.es.EsModule; import org.sonar.server.es.ProjectIndexersImpl; -import org.sonar.server.event.NewAlerts; +import org.sonar.server.qualitygate.notification.NewAlerts; import org.sonar.server.extension.CoreExtensionBootstraper; import org.sonar.server.extension.CoreExtensionStopper; import org.sonar.server.favorite.FavoriteUpdater; @@ -115,7 +115,7 @@ import org.sonar.server.metric.CoreCustomMetrics; import org.sonar.server.metric.DefaultMetricFinder; import org.sonar.server.notification.DefaultNotificationManager; import org.sonar.server.notification.NotificationService; -import org.sonar.server.notification.email.AlertsEmailTemplate; +import org.sonar.server.qualitygate.notification.AlertsEmailTemplate; import org.sonar.server.notification.email.EmailNotificationChannel; import org.sonar.server.organization.BillingValidationsProxyImpl; import org.sonar.server.organization.DefaultOrganizationProviderImpl; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/event/NewAlerts.java b/server/sonar-server-common/src/main/java/org/sonar/server/event/NewAlerts.java deleted file mode 100644 index 31eee0c973b..00000000000 --- a/server/sonar-server-common/src/main/java/org/sonar/server/event/NewAlerts.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.event; - -import com.google.common.collect.Multimap; -import java.util.Collection; -import java.util.Map; -import org.sonar.api.notifications.Notification; -import org.sonar.api.notifications.NotificationChannel; -import org.sonar.server.notification.NotificationDispatcher; -import org.sonar.server.notification.NotificationDispatcherMetadata; -import org.sonar.server.notification.NotificationManager; - -import static org.sonar.server.notification.NotificationManager.SubscriberPermissionsOnProject.ALL_MUST_HAVE_ROLE_USER; - -/** - * This dispatcher means: "notify me each new alert event". - * - * @since 3.5 - */ -public class NewAlerts extends NotificationDispatcher { - - public static final String KEY = "NewAlerts"; - private final NotificationManager notifications; - - public NewAlerts(NotificationManager notifications) { - super("alerts"); - this.notifications = notifications; - } - - @Override - public String getKey() { - return KEY; - } - - public static NotificationDispatcherMetadata newMetadata() { - return NotificationDispatcherMetadata.create(KEY) - .setProperty(NotificationDispatcherMetadata.GLOBAL_NOTIFICATION, String.valueOf(true)) - .setProperty(NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION, String.valueOf(true)); - } - - @Override - public void dispatch(Notification notification, Context context) { - String projectKey = notification.getFieldValue("projectKey"); - if (projectKey != null) { - Multimap subscribedRecipients = notifications - .findSubscribedRecipientsForDispatcher(this, projectKey, ALL_MUST_HAVE_ROLE_USER); - - for (Map.Entry> channelsByRecipients : subscribedRecipients.asMap().entrySet()) { - String userLogin = channelsByRecipients.getKey(); - for (NotificationChannel channel : channelsByRecipients.getValue()) { - context.addUser(userLogin, channel); - } - } - } - } -} diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/event/package-info.java b/server/sonar-server-common/src/main/java/org/sonar/server/event/package-info.java deleted file mode 100644 index e91ec90276f..00000000000 --- a/server/sonar-server-common/src/main/java/org/sonar/server/event/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.event; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/AlertsEmailTemplate.java b/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/AlertsEmailTemplate.java deleted file mode 100644 index 519ac52d502..00000000000 --- a/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/AlertsEmailTemplate.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.notification.email; - -import javax.annotation.Nullable; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.config.EmailSettings; -import org.sonar.api.measures.Metric; -import org.sonar.api.notifications.Notification; -import org.sonar.plugins.emailnotifications.api.EmailMessage; -import org.sonar.plugins.emailnotifications.api.EmailTemplate; - -/** - * Creates email message for notification "alerts". - * - * @since 3.5 - */ -public class AlertsEmailTemplate extends EmailTemplate { - - private EmailSettings configuration; - - public AlertsEmailTemplate(EmailSettings configuration) { - this.configuration = configuration; - } - - @Override - public EmailMessage format(Notification notification) { - if (!"alerts".equals(notification.getType())) { - return null; - } - - // Retrieve useful values - String projectId = notification.getFieldValue("projectId"); - String projectKey = notification.getFieldValue("projectKey"); - String projectName = notification.getFieldValue("projectName"); - String projectVersion = notification.getFieldValue("projectVersion"); - String branchName = notification.getFieldValue("branch"); - String alertName = notification.getFieldValue("alertName"); - String alertText = notification.getFieldValue("alertText"); - String alertLevel = notification.getFieldValue("alertLevel"); - boolean isNewAlert = Boolean.parseBoolean(notification.getFieldValue("isNewAlert")); - String fullProjectName = computeFullProjectName(projectName, branchName); - - // Generate text - String subject = generateSubject(fullProjectName, alertLevel, isNewAlert); - String messageBody = generateMessageBody(projectName, projectKey, projectVersion, branchName, alertName, alertText, isNewAlert); - - // And finally return the email that will be sent - return new EmailMessage() - .setMessageId("alerts/" + projectId) - .setSubject(subject) - .setMessage(messageBody); - } - - private static String computeFullProjectName(String projectName, @Nullable String branchName) { - if (branchName == null || branchName.isEmpty()) { - return projectName; - } - return String.format("%s (%s)", projectName, branchName); - } - - private static String generateSubject(String fullProjectName, String alertLevel, boolean isNewAlert) { - StringBuilder subjectBuilder = new StringBuilder(); - if (Metric.Level.OK.toString().equals(alertLevel)) { - subjectBuilder.append("\"").append(fullProjectName).append("\" is back to green"); - } else if (isNewAlert) { - subjectBuilder.append("New quality gate threshold reached on \"").append(fullProjectName).append("\""); - } else { - subjectBuilder.append("Quality gate status changed on \"").append(fullProjectName).append("\""); - } - return subjectBuilder.toString(); - } - - private String generateMessageBody(String projectName, String projectKey, - @Nullable String projectVersion, @Nullable String branchName, - String alertName, String alertText, boolean isNewAlert) { - StringBuilder messageBody = new StringBuilder(); - messageBody.append("Project: ").append(projectName).append("\n"); - if (branchName != null) { - messageBody.append("Branch: ").append(branchName).append("\n"); - } - if (projectVersion != null) { - messageBody.append("Version: ").append(projectVersion).append("\n"); - } - messageBody.append("Quality gate status: ").append(alertName).append("\n\n"); - - String[] alerts = StringUtils.split(alertText, ","); - if (alerts.length > 0) { - if (isNewAlert) { - messageBody.append("New quality gate threshold"); - } else { - messageBody.append("Quality gate threshold"); - } - if (alerts.length == 1) { - messageBody.append(": ").append(alerts[0].trim()).append("\n"); - } else { - messageBody.append("s:\n"); - for (String alert : alerts) { - messageBody.append(" - ").append(alert.trim()).append("\n"); - } - } - } - - messageBody.append("\n").append("More details at: ").append(configuration.getServerBaseURL()).append("/dashboard?id=").append(projectKey); - if (branchName != null) { - messageBody.append("&branch=").append(branchName); - } - - return messageBody.toString(); - } - -} diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/AlertsEmailTemplate.java b/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/AlertsEmailTemplate.java new file mode 100644 index 00000000000..1fa513208a4 --- /dev/null +++ b/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/AlertsEmailTemplate.java @@ -0,0 +1,129 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.qualitygate.notification; + +import javax.annotation.Nullable; +import org.apache.commons.lang.StringUtils; +import org.sonar.api.config.EmailSettings; +import org.sonar.api.measures.Metric; +import org.sonar.api.notifications.Notification; +import org.sonar.plugins.emailnotifications.api.EmailMessage; +import org.sonar.plugins.emailnotifications.api.EmailTemplate; + +/** + * Creates email message for notification "alerts". + * + * @since 3.5 + */ +public class AlertsEmailTemplate extends EmailTemplate { + + private EmailSettings configuration; + + public AlertsEmailTemplate(EmailSettings configuration) { + this.configuration = configuration; + } + + @Override + public EmailMessage format(Notification notification) { + if (!"alerts".equals(notification.getType())) { + return null; + } + + // Retrieve useful values + String projectId = notification.getFieldValue("projectId"); + String projectKey = notification.getFieldValue("projectKey"); + String projectName = notification.getFieldValue("projectName"); + String projectVersion = notification.getFieldValue("projectVersion"); + String branchName = notification.getFieldValue("branch"); + String alertName = notification.getFieldValue("alertName"); + String alertText = notification.getFieldValue("alertText"); + String alertLevel = notification.getFieldValue("alertLevel"); + boolean isNewAlert = Boolean.parseBoolean(notification.getFieldValue("isNewAlert")); + String fullProjectName = computeFullProjectName(projectName, branchName); + + // Generate text + String subject = generateSubject(fullProjectName, alertLevel, isNewAlert); + String messageBody = generateMessageBody(projectName, projectKey, projectVersion, branchName, alertName, alertText, isNewAlert); + + // And finally return the email that will be sent + return new EmailMessage() + .setMessageId("alerts/" + projectId) + .setSubject(subject) + .setMessage(messageBody); + } + + private static String computeFullProjectName(String projectName, @Nullable String branchName) { + if (branchName == null || branchName.isEmpty()) { + return projectName; + } + return String.format("%s (%s)", projectName, branchName); + } + + private static String generateSubject(String fullProjectName, String alertLevel, boolean isNewAlert) { + StringBuilder subjectBuilder = new StringBuilder(); + if (Metric.Level.OK.toString().equals(alertLevel)) { + subjectBuilder.append("\"").append(fullProjectName).append("\" is back to green"); + } else if (isNewAlert) { + subjectBuilder.append("New quality gate threshold reached on \"").append(fullProjectName).append("\""); + } else { + subjectBuilder.append("Quality gate status changed on \"").append(fullProjectName).append("\""); + } + return subjectBuilder.toString(); + } + + private String generateMessageBody(String projectName, String projectKey, + @Nullable String projectVersion, @Nullable String branchName, + String alertName, String alertText, boolean isNewAlert) { + StringBuilder messageBody = new StringBuilder(); + messageBody.append("Project: ").append(projectName).append("\n"); + if (branchName != null) { + messageBody.append("Branch: ").append(branchName).append("\n"); + } + if (projectVersion != null) { + messageBody.append("Version: ").append(projectVersion).append("\n"); + } + messageBody.append("Quality gate status: ").append(alertName).append("\n\n"); + + String[] alerts = StringUtils.split(alertText, ","); + if (alerts.length > 0) { + if (isNewAlert) { + messageBody.append("New quality gate threshold"); + } else { + messageBody.append("Quality gate threshold"); + } + if (alerts.length == 1) { + messageBody.append(": ").append(alerts[0].trim()).append("\n"); + } else { + messageBody.append("s:\n"); + for (String alert : alerts) { + messageBody.append(" - ").append(alert.trim()).append("\n"); + } + } + } + + messageBody.append("\n").append("More details at: ").append(configuration.getServerBaseURL()).append("/dashboard?id=").append(projectKey); + if (branchName != null) { + messageBody.append("&branch=").append(branchName); + } + + return messageBody.toString(); + } + +} diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/NewAlerts.java b/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/NewAlerts.java new file mode 100644 index 00000000000..61adbc65d4d --- /dev/null +++ b/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/NewAlerts.java @@ -0,0 +1,74 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.qualitygate.notification; + +import com.google.common.collect.Multimap; +import java.util.Collection; +import java.util.Map; +import org.sonar.api.notifications.Notification; +import org.sonar.api.notifications.NotificationChannel; +import org.sonar.server.notification.NotificationDispatcher; +import org.sonar.server.notification.NotificationDispatcherMetadata; +import org.sonar.server.notification.NotificationManager; + +import static org.sonar.server.notification.NotificationManager.SubscriberPermissionsOnProject.ALL_MUST_HAVE_ROLE_USER; + +/** + * This dispatcher means: "notify me each new alert event". + * + * @since 3.5 + */ +public class NewAlerts extends NotificationDispatcher { + + public static final String KEY = "NewAlerts"; + private final NotificationManager notifications; + + public NewAlerts(NotificationManager notifications) { + super("alerts"); + this.notifications = notifications; + } + + @Override + public String getKey() { + return KEY; + } + + public static NotificationDispatcherMetadata newMetadata() { + return NotificationDispatcherMetadata.create(KEY) + .setProperty(NotificationDispatcherMetadata.GLOBAL_NOTIFICATION, String.valueOf(true)) + .setProperty(NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION, String.valueOf(true)); + } + + @Override + public void dispatch(Notification notification, Context context) { + String projectKey = notification.getFieldValue("projectKey"); + if (projectKey != null) { + Multimap subscribedRecipients = notifications + .findSubscribedRecipientsForDispatcher(this, projectKey, ALL_MUST_HAVE_ROLE_USER); + + for (Map.Entry> channelsByRecipients : subscribedRecipients.asMap().entrySet()) { + String userLogin = channelsByRecipients.getKey(); + for (NotificationChannel channel : channelsByRecipients.getValue()) { + context.addUser(userLogin, channel); + } + } + } + } +} diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/package-info.java b/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/package-info.java new file mode 100644 index 00000000000..b3abc41d5ba --- /dev/null +++ b/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.server.qualitygate.notification; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/event/NewAlertsTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/event/NewAlertsTest.java deleted file mode 100644 index 811122a80e8..00000000000 --- a/server/sonar-server-common/src/test/java/org/sonar/server/event/NewAlertsTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.event; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import org.junit.Test; -import org.sonar.api.notifications.Notification; -import org.sonar.api.notifications.NotificationChannel; -import org.sonar.api.web.UserRole; -import org.sonar.server.notification.NotificationDispatcher; -import org.sonar.server.notification.NotificationManager; - -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -public class NewAlertsTest { - - private NotificationManager notificationManager = mock(NotificationManager.class); - private NotificationDispatcher.Context context = mock(NotificationDispatcher.Context.class); - private NotificationChannel emailChannel = mock(NotificationChannel.class); - private NotificationChannel twitterChannel = mock(NotificationChannel.class); - private NewAlerts dispatcher = new NewAlerts(notificationManager); - - @Test - public void should_not_dispatch_if_not_alerts_notification() { - Notification notification = new Notification("other-notif"); - dispatcher.performDispatch(notification, context); - - verify(context, never()).addUser(any(String.class), any(NotificationChannel.class)); - } - - @Test - public void should_dispatch_to_users_who_have_subscribed() { - Multimap recipients = HashMultimap.create(); - recipients.put("user1", emailChannel); - recipients.put("user2", twitterChannel); - when(notificationManager.findSubscribedRecipientsForDispatcher(dispatcher, "key_34", new NotificationManager.SubscriberPermissionsOnProject(UserRole.USER))) - .thenReturn(recipients); - - Notification notification = new Notification("alerts") - .setFieldValue("projectKey", "key_34"); - dispatcher.performDispatch(notification, context); - - verify(context).addUser("user1", emailChannel); - verify(context).addUser("user2", twitterChannel); - verifyNoMoreInteractions(context); - } - - @Test - public void should_not_dispatch_if_missing_project_key() { - Multimap recipients = HashMultimap.create(); - recipients.put("user1", emailChannel); - recipients.put("user2", twitterChannel); - when(notificationManager.findSubscribedRecipientsForDispatcher(dispatcher, "key_34", new NotificationManager.SubscriberPermissionsOnProject(UserRole.USER))) - .thenReturn(recipients); - - Notification notification = new Notification("alerts"); - dispatcher.performDispatch(notification, context); - - verifyNoMoreInteractions(context); - } - -} diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/AlertsEmailTemplateTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/AlertsEmailTemplateTest.java new file mode 100644 index 00000000000..e8a06c216bb --- /dev/null +++ b/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/AlertsEmailTemplateTest.java @@ -0,0 +1,212 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.qualitygate.notification; + +import org.junit.Before; +import org.junit.Test; +import org.sonar.api.config.EmailSettings; +import org.sonar.api.notifications.Notification; +import org.sonar.plugins.emailnotifications.api.EmailMessage; +import org.sonar.server.qualitygate.notification.AlertsEmailTemplate; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class AlertsEmailTemplateTest { + + private AlertsEmailTemplate template; + + @Before + public void setUp() { + EmailSettings configuration = mock(EmailSettings.class); + when(configuration.getServerBaseURL()).thenReturn("http://nemo.sonarsource.org"); + template = new AlertsEmailTemplate(configuration); + } + + @Test + public void shouldNotFormatIfNotCorrectNotification() { + Notification notification = new Notification("other-notif"); + EmailMessage message = template.format(notification); + assertThat(message, nullValue()); + } + + @Test + public void shouldFormatAlertWithSeveralMessages() { + Notification notification = createNotification("Red (was Green)", "violations > 4, coverage < 75%", "ERROR", "false"); + + EmailMessage message = template.format(notification); + assertThat(message.getMessageId(), is("alerts/45")); + assertThat(message.getSubject(), is("Quality gate status changed on \"Foo\"")); + assertThat(message.getMessage(), is("" + + "Project: Foo\n" + + "Version: V1-SNAP\n" + + "Quality gate status: Red (was Green)\n" + + "\n" + + "Quality gate thresholds:\n" + + " - violations > 4\n" + + " - coverage < 75%\n" + + "\n" + + "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo")); + } + + @Test + public void shouldFormatAlertWithSeveralMessagesOnBranch() { + Notification notification = createNotification("Red (was Green)", "violations > 4, coverage < 75%", "ERROR", "false") + .setFieldValue("branch", "feature"); + + EmailMessage message = template.format(notification); + assertThat(message.getMessageId(), is("alerts/45")); + assertThat(message.getSubject(), is("Quality gate status changed on \"Foo (feature)\"")); + assertThat(message.getMessage(), is("" + + "Project: Foo\n" + + "Branch: feature\n" + + "Version: V1-SNAP\n" + + "Quality gate status: Red (was Green)\n" + + "\n" + + "Quality gate thresholds:\n" + + " - violations > 4\n" + + " - coverage < 75%\n" + + "\n" + + "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo&branch=feature")); + } + + @Test + public void shouldFormatNewAlertWithSeveralMessages() { + Notification notification = createNotification("Red (was Green)", "violations > 4, coverage < 75%", "ERROR", "true"); + + EmailMessage message = template.format(notification); + assertThat(message.getMessageId(), is("alerts/45")); + assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\"")); + assertThat(message.getMessage(), is("" + + "Project: Foo\n" + + "Version: V1-SNAP\n" + + "Quality gate status: Red (was Green)\n" + + "\n" + + "New quality gate thresholds:\n" + + " - violations > 4\n" + + " - coverage < 75%\n" + + "\n" + + "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo")); + } + + @Test + public void shouldFormatNewAlertWithOneMessage() { + Notification notification = createNotification("Red (was Green)", "violations > 4", "ERROR", "true"); + + EmailMessage message = template.format(notification); + assertThat(message.getMessageId(), is("alerts/45")); + assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\"")); + assertThat(message.getMessage(), is("" + + "Project: Foo\n" + + "Version: V1-SNAP\n" + + "Quality gate status: Red (was Green)\n" + + "\n" + + "New quality gate threshold: violations > 4\n" + + "\n" + + "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo")); + } + + @Test + public void shouldFormatNewAlertWithoutVersion() { + Notification notification = createNotification("Red (was Green)", "violations > 4", "ERROR", "true") + .setFieldValue("projectVersion", null); + + EmailMessage message = template.format(notification); + assertThat(message.getMessageId(), is("alerts/45")); + assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\"")); + assertThat(message.getMessage(), is("" + + "Project: Foo\n" + + "Quality gate status: Red (was Green)\n" + + "\n" + + "New quality gate threshold: violations > 4\n" + + "\n" + + "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo")); + } + + @Test + public void shouldFormatNewAlertWithOneMessageOnBranch() { + Notification notification = createNotification("Red (was Green)", "violations > 4", "ERROR", "true") + .setFieldValue("branch", "feature"); + + EmailMessage message = template.format(notification); + assertThat(message.getMessageId(), is("alerts/45")); + assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo (feature)\"")); + assertThat(message.getMessage(), is("" + + "Project: Foo\n" + + "Branch: feature\n" + + "Version: V1-SNAP\n" + + "Quality gate status: Red (was Green)\n" + + "\n" + + "New quality gate threshold: violations > 4\n" + + "\n" + + "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo&branch=feature")); + } + + @Test + public void shouldFormatBackToGreenMessage() { + Notification notification = createNotification("Green (was Red)", "", "OK", "false"); + + EmailMessage message = template.format(notification); + assertThat(message.getMessageId(), is("alerts/45")); + assertThat(message.getSubject(), is("\"Foo\" is back to green")); + assertThat(message.getMessage(), is("" + + "Project: Foo\n" + + "Version: V1-SNAP\n" + + "Quality gate status: Green (was Red)\n" + + "\n" + + "\n" + + "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo")); + } + + @Test + public void shouldFormatBackToGreenMessageOnBranch() { + Notification notification = createNotification("Green (was Red)", "", "OK", "false") + .setFieldValue("branch", "feature"); + + EmailMessage message = template.format(notification); + assertThat(message.getMessageId(), is("alerts/45")); + assertThat(message.getSubject(), is("\"Foo (feature)\" is back to green")); + assertThat(message.getMessage(), is("" + + "Project: Foo\n" + + "Branch: feature\n" + + "Version: V1-SNAP\n" + + "Quality gate status: Green (was Red)\n" + + "\n" + + "\n" + + "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo&branch=feature")); + } + + private Notification createNotification(String alertName, String alertText, String alertLevel, String isNewAlert) { + Notification notification = new Notification("alerts") + .setFieldValue("projectName", "Foo") + .setFieldValue("projectKey", "org.sonar.foo:foo") + .setFieldValue("projectId", "45") + .setFieldValue("projectVersion", "V1-SNAP") + .setFieldValue("alertName", alertName) + .setFieldValue("alertText", alertText) + .setFieldValue("alertLevel", alertLevel) + .setFieldValue("isNewAlert", isNewAlert); + return notification; + } + +} diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/NewAlertsTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/NewAlertsTest.java new file mode 100644 index 00000000000..48a7b9f036c --- /dev/null +++ b/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/NewAlertsTest.java @@ -0,0 +1,85 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.qualitygate.notification; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import org.junit.Test; +import org.sonar.api.notifications.Notification; +import org.sonar.api.notifications.NotificationChannel; +import org.sonar.api.web.UserRole; +import org.sonar.server.notification.NotificationDispatcher; +import org.sonar.server.notification.NotificationManager; + +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class NewAlertsTest { + + private NotificationManager notificationManager = mock(NotificationManager.class); + private NotificationDispatcher.Context context = mock(NotificationDispatcher.Context.class); + private NotificationChannel emailChannel = mock(NotificationChannel.class); + private NotificationChannel twitterChannel = mock(NotificationChannel.class); + private NewAlerts dispatcher = new NewAlerts(notificationManager); + + @Test + public void should_not_dispatch_if_not_alerts_notification() { + Notification notification = new Notification("other-notif"); + dispatcher.performDispatch(notification, context); + + verify(context, never()).addUser(any(String.class), any(NotificationChannel.class)); + } + + @Test + public void should_dispatch_to_users_who_have_subscribed() { + Multimap recipients = HashMultimap.create(); + recipients.put("user1", emailChannel); + recipients.put("user2", twitterChannel); + when(notificationManager.findSubscribedRecipientsForDispatcher(dispatcher, "key_34", new NotificationManager.SubscriberPermissionsOnProject(UserRole.USER))) + .thenReturn(recipients); + + Notification notification = new Notification("alerts") + .setFieldValue("projectKey", "key_34"); + dispatcher.performDispatch(notification, context); + + verify(context).addUser("user1", emailChannel); + verify(context).addUser("user2", twitterChannel); + verifyNoMoreInteractions(context); + } + + @Test + public void should_not_dispatch_if_missing_project_key() { + Multimap recipients = HashMultimap.create(); + recipients.put("user1", emailChannel); + recipients.put("user2", twitterChannel); + when(notificationManager.findSubscribedRecipientsForDispatcher(dispatcher, "key_34", new NotificationManager.SubscriberPermissionsOnProject(UserRole.USER))) + .thenReturn(recipients); + + Notification notification = new Notification("alerts"); + dispatcher.performDispatch(notification, context); + + verifyNoMoreInteractions(context); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java b/server/sonar-server/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java index 9c755aebced..5800cca5d34 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java @@ -26,7 +26,7 @@ import java.util.function.Predicate; import org.sonar.api.Startable; import org.sonar.api.config.Configuration; import org.sonar.process.ProcessProperties; -import org.sonar.server.event.NewAlerts; +import org.sonar.server.qualitygate.notification.NewAlerts; import org.sonar.server.issue.notification.DoNotFixNotificationHandler; import org.sonar.server.issue.notification.NewIssuesNotificationHandler; import org.sonar.server.notification.NotificationCenter; diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index e10db664628..bdb47697472 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -64,7 +64,7 @@ import org.sonar.server.es.RecoveryIndexer; import org.sonar.server.es.metadata.EsDbCompatibilityImpl; import org.sonar.server.es.metadata.MetadataIndex; import org.sonar.server.es.metadata.MetadataIndexDefinition; -import org.sonar.server.event.NewAlerts; +import org.sonar.server.qualitygate.notification.NewAlerts; import org.sonar.server.extension.CoreExtensionBootstraper; import org.sonar.server.extension.CoreExtensionStopper; import org.sonar.server.favorite.FavoriteModule; diff --git a/server/sonar-server/src/test/java/org/sonar/server/notification/email/AlertsEmailTemplateTest.java b/server/sonar-server/src/test/java/org/sonar/server/notification/email/AlertsEmailTemplateTest.java deleted file mode 100644 index 164abbbaf72..00000000000 --- a/server/sonar-server/src/test/java/org/sonar/server/notification/email/AlertsEmailTemplateTest.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.notification.email; - -import org.junit.Before; -import org.junit.Test; -import org.sonar.api.config.EmailSettings; -import org.sonar.api.notifications.Notification; -import org.sonar.plugins.emailnotifications.api.EmailMessage; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class AlertsEmailTemplateTest { - - private AlertsEmailTemplate template; - - @Before - public void setUp() { - EmailSettings configuration = mock(EmailSettings.class); - when(configuration.getServerBaseURL()).thenReturn("http://nemo.sonarsource.org"); - template = new AlertsEmailTemplate(configuration); - } - - @Test - public void shouldNotFormatIfNotCorrectNotification() { - Notification notification = new Notification("other-notif"); - EmailMessage message = template.format(notification); - assertThat(message, nullValue()); - } - - @Test - public void shouldFormatAlertWithSeveralMessages() { - Notification notification = createNotification("Red (was Green)", "violations > 4, coverage < 75%", "ERROR", "false"); - - EmailMessage message = template.format(notification); - assertThat(message.getMessageId(), is("alerts/45")); - assertThat(message.getSubject(), is("Quality gate status changed on \"Foo\"")); - assertThat(message.getMessage(), is("" + - "Project: Foo\n" + - "Version: V1-SNAP\n" + - "Quality gate status: Red (was Green)\n" + - "\n" + - "Quality gate thresholds:\n" + - " - violations > 4\n" + - " - coverage < 75%\n" + - "\n" + - "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo")); - } - - @Test - public void shouldFormatAlertWithSeveralMessagesOnBranch() { - Notification notification = createNotification("Red (was Green)", "violations > 4, coverage < 75%", "ERROR", "false") - .setFieldValue("branch", "feature"); - - EmailMessage message = template.format(notification); - assertThat(message.getMessageId(), is("alerts/45")); - assertThat(message.getSubject(), is("Quality gate status changed on \"Foo (feature)\"")); - assertThat(message.getMessage(), is("" + - "Project: Foo\n" + - "Branch: feature\n" + - "Version: V1-SNAP\n" + - "Quality gate status: Red (was Green)\n" + - "\n" + - "Quality gate thresholds:\n" + - " - violations > 4\n" + - " - coverage < 75%\n" + - "\n" + - "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo&branch=feature")); - } - - @Test - public void shouldFormatNewAlertWithSeveralMessages() { - Notification notification = createNotification("Red (was Green)", "violations > 4, coverage < 75%", "ERROR", "true"); - - EmailMessage message = template.format(notification); - assertThat(message.getMessageId(), is("alerts/45")); - assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\"")); - assertThat(message.getMessage(), is("" + - "Project: Foo\n" + - "Version: V1-SNAP\n" + - "Quality gate status: Red (was Green)\n" + - "\n" + - "New quality gate thresholds:\n" + - " - violations > 4\n" + - " - coverage < 75%\n" + - "\n" + - "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo")); - } - - @Test - public void shouldFormatNewAlertWithOneMessage() { - Notification notification = createNotification("Red (was Green)", "violations > 4", "ERROR", "true"); - - EmailMessage message = template.format(notification); - assertThat(message.getMessageId(), is("alerts/45")); - assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\"")); - assertThat(message.getMessage(), is("" + - "Project: Foo\n" + - "Version: V1-SNAP\n" + - "Quality gate status: Red (was Green)\n" + - "\n" + - "New quality gate threshold: violations > 4\n" + - "\n" + - "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo")); - } - - @Test - public void shouldFormatNewAlertWithoutVersion() { - Notification notification = createNotification("Red (was Green)", "violations > 4", "ERROR", "true") - .setFieldValue("projectVersion", null); - - EmailMessage message = template.format(notification); - assertThat(message.getMessageId(), is("alerts/45")); - assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\"")); - assertThat(message.getMessage(), is("" + - "Project: Foo\n" + - "Quality gate status: Red (was Green)\n" + - "\n" + - "New quality gate threshold: violations > 4\n" + - "\n" + - "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo")); - } - - @Test - public void shouldFormatNewAlertWithOneMessageOnBranch() { - Notification notification = createNotification("Red (was Green)", "violations > 4", "ERROR", "true") - .setFieldValue("branch", "feature"); - - EmailMessage message = template.format(notification); - assertThat(message.getMessageId(), is("alerts/45")); - assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo (feature)\"")); - assertThat(message.getMessage(), is("" + - "Project: Foo\n" + - "Branch: feature\n" + - "Version: V1-SNAP\n" + - "Quality gate status: Red (was Green)\n" + - "\n" + - "New quality gate threshold: violations > 4\n" + - "\n" + - "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo&branch=feature")); - } - - @Test - public void shouldFormatBackToGreenMessage() { - Notification notification = createNotification("Green (was Red)", "", "OK", "false"); - - EmailMessage message = template.format(notification); - assertThat(message.getMessageId(), is("alerts/45")); - assertThat(message.getSubject(), is("\"Foo\" is back to green")); - assertThat(message.getMessage(), is("" + - "Project: Foo\n" + - "Version: V1-SNAP\n" + - "Quality gate status: Green (was Red)\n" + - "\n" + - "\n" + - "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo")); - } - - @Test - public void shouldFormatBackToGreenMessageOnBranch() { - Notification notification = createNotification("Green (was Red)", "", "OK", "false") - .setFieldValue("branch", "feature"); - - EmailMessage message = template.format(notification); - assertThat(message.getMessageId(), is("alerts/45")); - assertThat(message.getSubject(), is("\"Foo (feature)\" is back to green")); - assertThat(message.getMessage(), is("" + - "Project: Foo\n" + - "Branch: feature\n" + - "Version: V1-SNAP\n" + - "Quality gate status: Green (was Red)\n" + - "\n" + - "\n" + - "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo&branch=feature")); - } - - private Notification createNotification(String alertName, String alertText, String alertLevel, String isNewAlert) { - Notification notification = new Notification("alerts") - .setFieldValue("projectName", "Foo") - .setFieldValue("projectKey", "org.sonar.foo:foo") - .setFieldValue("projectId", "45") - .setFieldValue("projectVersion", "V1-SNAP") - .setFieldValue("alertName", alertName) - .setFieldValue("alertText", alertText) - .setFieldValue("alertLevel", alertLevel) - .setFieldValue("isNewAlert", isNewAlert); - return notification; - } - -} diff --git a/server/sonar-server/src/test/java/org/sonar/server/notification/ws/DispatchersImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/notification/ws/DispatchersImplTest.java index 5aa8aec6f5d..8b6c25b88fe 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/notification/ws/DispatchersImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/notification/ws/DispatchersImplTest.java @@ -22,7 +22,7 @@ package org.sonar.server.notification.ws; import org.junit.Test; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.notifications.NotificationChannel; -import org.sonar.server.event.NewAlerts; +import org.sonar.server.qualitygate.notification.NewAlerts; import org.sonar.server.issue.notification.DoNotFixNotificationHandler; import org.sonar.server.issue.notification.MyNewIssuesNotificationHandler; import org.sonar.server.issue.notification.NewIssuesNotificationHandler; -- cgit v1.2.3