diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-07-20 19:09:57 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-07-20 23:18:56 +0400 |
commit | 04a940ca3a7b57020bca2b529d2e04c3437ae77e (patch) | |
tree | 8f6aa187ee08247d9124102391d3f725641c0b99 /sonar-server/src/test/java | |
parent | 98f009fed3aaede468f70bb2d848e31e5e54b7d2 (diff) | |
download | sonarqube-04a940ca3a7b57020bca2b529d2e04c3437ae77e.tar.gz sonarqube-04a940ca3a7b57020bca2b529d2e04c3437ae77e.zip |
SONAR-2599 First draft of settings for notifications in user profile
Diffstat (limited to 'sonar-server/src/test/java')
-rw-r--r-- | sonar-server/src/test/java/org/sonar/server/notifications/NotificationServiceDbTest.java | 54 | ||||
-rw-r--r-- | sonar-server/src/test/java/org/sonar/server/notifications/NotificationServiceTest.java | 2 |
2 files changed, 55 insertions, 1 deletions
diff --git a/sonar-server/src/test/java/org/sonar/server/notifications/NotificationServiceDbTest.java b/sonar-server/src/test/java/org/sonar/server/notifications/NotificationServiceDbTest.java new file mode 100644 index 00000000000..a7a57c9044b --- /dev/null +++ b/sonar-server/src/test/java/org/sonar/server/notifications/NotificationServiceDbTest.java @@ -0,0 +1,54 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.server.notifications; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.junit.Before; +import org.junit.Test; +import org.sonar.api.notifications.NotificationChannel; +import org.sonar.api.notifications.NotificationDispatcher; +import org.sonar.jpa.test.AbstractDbUnitTestCase; + +public class NotificationServiceDbTest extends AbstractDbUnitTestCase { + + private NotificationService notificationService; + + @Before + public void setUp() { + setupData("fixture"); + notificationService = new NotificationService(getSessionFactory(), null, null); + } + + @Test + public void should() { + NotificationChannel email = mock(NotificationChannel.class); + when(email.getKey()).thenReturn("EmailNotificationChannel"); + NotificationDispatcher commentOnReviewAssignedToMe = mock(NotificationDispatcher.class); + when(commentOnReviewAssignedToMe.getKey()).thenReturn("CommentOnReviewAssignedToMe"); + + assertThat(notificationService.isEnabled("simon", email, commentOnReviewAssignedToMe), is(true)); + assertThat(notificationService.isEnabled("godin", email, commentOnReviewAssignedToMe), is(false)); + } + +} diff --git a/sonar-server/src/test/java/org/sonar/server/notifications/NotificationServiceTest.java b/sonar-server/src/test/java/org/sonar/server/notifications/NotificationServiceTest.java index 46633e27a90..d17ada17562 100644 --- a/sonar-server/src/test/java/org/sonar/server/notifications/NotificationServiceTest.java +++ b/sonar-server/src/test/java/org/sonar/server/notifications/NotificationServiceTest.java @@ -77,7 +77,7 @@ public class NotificationServiceTest { NotificationDispatcher[] dispatchers = new NotificationDispatcher[] { commentOnReviewAssignedToMe, commentOnReviewCreatedByMe }; NotificationChannel[] channels = new NotificationChannel[] { emailChannel, gtalkChannel }; manager = mock(DefaultNotificationManager.class); - service = spy(new NotificationService(manager, dispatchers, channels)); + service = spy(new NotificationService(null, manager, dispatchers, channels)); doReturn(false).when(service).isEnabled(any(String.class), any(NotificationChannel.class), any(NotificationDispatcher.class)); } |