]> source.dussan.org Git - sonarqube.git/blob
5d500178f0c3e397dea420ebb28c59894670664c
[sonarqube.git] /
1 /*
2  * SonarQube
3  * Copyright (C) 2009-2023 SonarSource SA
4  * mailto:info AT sonarsource DOT com
5  *
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.
10  *
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.
15  *
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.
19  */
20 package org.sonar.server.notification.ws;
21
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;
29
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;
33
34 public class DispatchersImplTest {
35
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")
49     },
50     new NotificationChannel[] {});
51
52   private DispatchersImpl underTest = new DispatchersImpl(notificationCenter);
53
54   @Test
55   public void get_sorted_global_dispatchers() {
56     underTest.start();
57
58     assertThat(underTest.getGlobalDispatchers()).containsExactly(
59       QGChangeNotificationHandler.KEY, MyNewIssuesNotificationHandler.KEY);
60   }
61
62   @Test
63   public void get_sorted_project_dispatchers() {
64     underTest.start();
65
66     assertThat(underTest.getProjectDispatchers()).containsExactly(
67       QGChangeNotificationHandler.KEY, FPOrWontFixNotificationHandler.KEY, MyNewIssuesNotificationHandler.KEY);
68   }
69
70 }