3 * Copyright (C) 2009-2023 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.notification.ws;
22 import org.junit.Test;
23 import org.sonar.api.notifications.NotificationChannel;
24 import org.sonar.server.issue.notification.FPOrWontFixNotificationHandler;
25 import org.sonar.server.issue.notification.MyNewIssuesNotificationHandler;
26 import org.sonar.server.issue.notification.NewIssuesNotificationHandler;
27 import org.sonar.server.notification.NotificationDispatcherMetadata;
28 import org.sonar.server.qualitygate.notification.QGChangeNotificationHandler;
30 import static org.assertj.core.api.Java6Assertions.assertThat;
31 import static org.sonar.server.notification.NotificationDispatcherMetadata.GLOBAL_NOTIFICATION;
32 import static org.sonar.server.notification.NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION;
34 public class DispatchersImplTest {
36 private NotificationCenter notificationCenter = new NotificationCenter(
37 new NotificationDispatcherMetadata[] {
38 NotificationDispatcherMetadata.create(MyNewIssuesNotificationHandler.KEY)
39 .setProperty(GLOBAL_NOTIFICATION, "true")
40 .setProperty(PER_PROJECT_NOTIFICATION, "true"),
41 NotificationDispatcherMetadata.create(NewIssuesNotificationHandler.KEY)
42 .setProperty(GLOBAL_NOTIFICATION, "false"),
43 NotificationDispatcherMetadata.create(QGChangeNotificationHandler.KEY)
44 .setProperty(GLOBAL_NOTIFICATION, "true")
45 .setProperty(PER_PROJECT_NOTIFICATION, "true"),
46 NotificationDispatcherMetadata.create(FPOrWontFixNotificationHandler.KEY)
47 .setProperty(GLOBAL_NOTIFICATION, "false")
48 .setProperty(PER_PROJECT_NOTIFICATION, "true")
50 new NotificationChannel[] {});
52 private DispatchersImpl underTest = new DispatchersImpl(notificationCenter);
55 public void get_sorted_global_dispatchers() {
58 assertThat(underTest.getGlobalDispatchers()).containsExactly(
59 QGChangeNotificationHandler.KEY, MyNewIssuesNotificationHandler.KEY);
63 public void get_sorted_project_dispatchers() {
66 assertThat(underTest.getProjectDispatchers()).containsExactly(
67 QGChangeNotificationHandler.KEY, FPOrWontFixNotificationHandler.KEY, MyNewIssuesNotificationHandler.KEY);