コード例 #1
0
 /**
  * The commentAdded() method should notify both the author of the commented ad and the authors of
  * all of the ad's comments.
  */
 @Test
 public void commentAddedShouldNotifyClassifiedAndCommentAuthors() throws Exception {
   mockGetUserDetailReturnedValue();
   notificationService.commentAdded(concernedComment);
   verify(notificationService).getNotificationSender(CLASSIFIED_INSTANCEID);
   verify(notificationSender).notifyUser(notifInfoCaptor.capture());
   NotificationMetaData notif = getCapturedInfoInNotificiation();
   assertNotNull(notif);
   assertThat("The comment should be in the notification", concernedComment, isSetIn(notif));
   assertEquals(
       "The sender should be the author of the comment from which the callback is invoked",
       COMMENT_AUTHORID,
       notif.getSender());
   for (Comment aComment : classifiedComments) {
     UserRecipient authorId = new UserRecipient(String.valueOf(aComment.getOwnerId()));
     if (!authorId.getUserId().equals(String.valueOf(concernedComment.getOwnerId()))) {
       assertThat(
           "The author '" + authorId + "' should be in the notification recipients",
           notif.getUserRecipients(),
           hasItem(authorId));
     } else {
       assertFalse(
           "The author '" + authorId + "' shouldn't be in the notification recipients",
           notif.getUserRecipients().contains(authorId));
     }
   }
 }
コード例 #2
0
 @Before
 public void setUp() throws Exception {
   setUpClassifieds();
   setUpClassifiedComments();
   notificationService = spy(new CommentUserNotificationService());
   notificationService.register(ClassifiedService.COMPONENT_NAME, classifiedService);
   doReturn(mockCommentService()).when(notificationService).getCommentService();
   doReturn(mockNotificationSender())
       .when(notificationService)
       .getNotificationSender(CLASSIFIED_INSTANCEID);
 }
コード例 #3
0
 @After
 public void tearDown() {
   notificationService.unregister(ClassifiedService.COMPONENT_NAME);
 }