From b0e768ada85207c3ac6424b069e0dbc4e162c9db Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Wed, 27 Jul 2011 18:35:42 +0400 Subject: SONAR-2596 Add unit tests --- .../reviews/ReviewsNotificationManagerTest.java | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'sonar-server') 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 oldValues = Maps.newHashMap(); + Map 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")); + } + } -- cgit v1.2.3