aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-07-27 18:35:42 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-07-28 06:06:02 +0400
commitb0e768ada85207c3ac6424b069e0dbc4e162c9db (patch)
tree48e6709ae5d60d084c3d58a4701efeca8c890597 /sonar-server
parent223cc999564d32633fbdc493e11556e8a29e2d8b (diff)
downloadsonarqube-b0e768ada85207c3ac6424b069e0dbc4e162c9db.tar.gz
sonarqube-b0e768ada85207c3ac6424b069e0dbc4e162c9db.zip
SONAR-2596 Add unit tests
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/test/java/org/sonar/server/notifications/reviews/ReviewsNotificationManagerTest.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/sonar-server/src/test/java/org/sonar/server/notifications/reviews/ReviewsNotificationManagerTest.java b/sonar-server/src/test/java/org/sonar/server/notifications/reviews/ReviewsNotificationManagerTest.java
index 187d3e965b3..3cd20d65b5c 100644
--- a/sonar-server/src/test/java/org/sonar/server/notifications/reviews/ReviewsNotificationManagerTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/notifications/reviews/ReviewsNotificationManagerTest.java
@@ -19,17 +19,25 @@
*/
package org.sonar.server.notifications.reviews;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
+import java.util.Map;
+
import org.junit.Before;
+import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.sonar.api.notifications.Notification;
import org.sonar.api.notifications.NotificationManager;
-public class ReviewsNotificationManagerTest { // FIXME implement
+import com.google.common.collect.Maps;
+
+public class ReviewsNotificationManagerTest {
private Notification notification;
private ReviewsNotificationManager manager;
@@ -46,4 +54,28 @@ public class ReviewsNotificationManagerTest { // FIXME implement
manager = new ReviewsNotificationManager(delegate);
}
+ @Test
+ public void shouldScheduleNotification() {
+ Map<String, String> oldValues = Maps.newHashMap();
+ Map<String, String> newValues = Maps.newHashMap();
+ newValues.put("project", "Sonar");
+ newValues.put("resource", "org.sonar.server.ui.DefaultPages");
+ newValues.put("title", "Utility classes should not have a public or default constructor.");
+ newValues.put("creator", "olivier");
+ newValues.put("assignee", "godin");
+ oldValues.put("assignee", "simon");
+ manager.notifyChanged(1L, "freddy", oldValues, newValues);
+ assertThat(notification, notNullValue());
+ assertThat(notification.getType(), is("review-changed"));
+ assertThat(notification.getFieldValue("reviewId"), is("1"));
+ assertThat(notification.getFieldValue("author"), is("freddy"));
+ assertThat(notification.getFieldValue("project"), is("Sonar"));
+ assertThat(notification.getFieldValue("resource"), is("org.sonar.server.ui.DefaultPages"));
+ assertThat(notification.getFieldValue("title"), is("Utility classes should not have a public or default constructor."));
+ assertThat(notification.getFieldValue("creator"), is("olivier"));
+ assertThat(notification.getFieldValue("assignee"), is("godin"));
+ assertThat(notification.getFieldValue("old.assignee"), is("simon"));
+ assertThat(notification.getFieldValue("new.assignee"), is("godin"));
+ }
+
}