Search in sources :

Example 6 with Notification

use of amu.zhcet.notification.Notification in project zhcet-web by zhcet-amu.

the class NotificationSendingController method sendNotification.

@GetMapping
public String sendNotification(Model model) {
    User user = userService.getLoggedInUser().orElseThrow(() -> new AccessDeniedException("403"));
    model.addAttribute("page_title", "Send Notifications");
    model.addAttribute("page_subtitle", "Notification Manager");
    model.addAttribute("page_description", "Send notifications to students, sections or departments");
    model.addAttribute("channel_types", Arrays.asList(ChannelType.STUDENT, ChannelType.COURSE, ChannelType.TAUGHT_COURSE, ChannelType.SECTION, ChannelType.FACULTY));
    if (!model.containsAttribute("notification")) {
        Notification notification = new Notification();
        notification.setSender(user);
        model.addAttribute("notification", notification);
    }
    return "management/send_notification";
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) User(amu.zhcet.data.user.User) Notification(amu.zhcet.notification.Notification) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 7 with Notification

use of amu.zhcet.notification.Notification in project zhcet-web by zhcet-amu.

the class NotificationSendingServiceTest method saveNotificationRecipient.

@Test
public void saveNotificationRecipient() {
    Notification notification = getNotification();
    setBehaviour();
    notificationSendingService.sendNotification(notification);
    Stream.of(userIds).forEach(id -> verify(cachedNotificationService).resetUnreadCount(id));
    List<NotificationRecipient> recipients = getRecipients();
    verify(emailSendingService).sendEmailForNotification(notification, userList);
    recipients.forEach(notificationRecipient -> {
        assertTrue(Arrays.asList(userIds).contains(notificationRecipient.getRecipient().getUserId()));
        assertEquals(notification, notificationRecipient.getNotification());
        verify(cachedNotificationService).resetUnreadCount(notificationRecipient.getRecipient().getUserId());
        verify(firebaseNotificationSender).sendFirebaseNotification(notificationRecipient);
    });
}
Also used : NotificationRecipient(amu.zhcet.notification.recipient.NotificationRecipient) Notification(amu.zhcet.notification.Notification) Test(org.junit.Test)

Example 8 with Notification

use of amu.zhcet.notification.Notification in project zhcet-web by zhcet-amu.

the class NotificationSendingServiceTest method saveNotificationPrimary.

@Test
public void saveNotificationPrimary() {
    Notification notification = getNotification();
    notificationSendingService.sendNotification(notification);
    assertNotNull(notification.getSentTime());
    verify(cachedNotificationService).save(notification);
}
Also used : Notification(amu.zhcet.notification.Notification) Test(org.junit.Test)

Aggregations

Notification (amu.zhcet.notification.Notification)8 Test (org.junit.Test)4 NotificationRecipient (amu.zhcet.notification.recipient.NotificationRecipient)3 User (amu.zhcet.data.user.User)2 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1