use of org.orcid.core.manager.impl.NotificationManagerImpl in project ORCID-Source by ORCID.
the class NotificationManagerTest method sendAcknowledgeMessageToAccountWithNotificationsEnabledTest.
/**
* 0000-0000-0000-0003 Must have notifications enabled
*/
@Test
public void sendAcknowledgeMessageToAccountWithNotificationsEnabledTest() throws Exception {
String clientId = "APP-5555555555555555";
String orcid = "0000-0000-0000-0003";
// Mock the notification DAO
NotificationManagerImpl notificationManagerImpl = getTargetObject(notificationManager, NotificationManagerImpl.class);
notificationManagerImpl.setNotificationDao(mockNotificationDao);
notificationManagerImpl.setMailGunManager(mockMailGunManager);
notificationManagerImpl.sendAcknowledgeMessage(orcid, clientId);
verify(mockNotificationDao, times(1)).persist(Matchers.any(NotificationEntity.class));
verify(mockMailGunManager, never()).sendEmail(Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString());
// Rollback mocked
notificationManagerImpl.setNotificationDao(notificationDao);
notificationManagerImpl.setMailGunManager(mailGunManager);
}
use of org.orcid.core.manager.impl.NotificationManagerImpl in project ORCID-Source by ORCID.
the class NotificationManagerTest method sendAcknowledgeMessageToAccountWithNotificationsDisabledTest.
/**
* 0000-0000-0000-0002 Must have notifications disabled
*/
@Test
public void sendAcknowledgeMessageToAccountWithNotificationsDisabledTest() throws Exception {
String clientId = "APP-5555555555555555";
String orcid = "0000-0000-0000-0002";
// Mock the notification DAO
NotificationManagerImpl notificationManagerImpl = getTargetObject(notificationManager, NotificationManagerImpl.class);
notificationManagerImpl.setNotificationDao(mockNotificationDao);
notificationManagerImpl.setMailGunManager(mockMailGunManager);
notificationManagerImpl.sendAcknowledgeMessage(orcid, clientId);
verify(mockNotificationDao, never()).persist(Matchers.any(NotificationEntity.class));
verify(mockMailGunManager, times(1)).sendEmail(Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString());
// Rollback mocked
notificationManagerImpl.setNotificationDao(notificationDao);
notificationManagerImpl.setMailGunManager(mailGunManager);
}
use of org.orcid.core.manager.impl.NotificationManagerImpl in project ORCID-Source by ORCID.
the class NotificationManagerTest method testFindPermissionsByOrcidAndClient.
/**
* Test independent of spring context, sets up NotificationManager with
* mocked notifiation dao and notification adapter
*/
@Test
public void testFindPermissionsByOrcidAndClient() {
List<Notification> notificationPermissions = IntStream.range(0, 10).mapToObj(i -> new NotificationPermission()).collect(Collectors.toList());
NotificationDao notificationDao = mock(NotificationDaoImpl.class);
JpaJaxbNotificationAdapter adapter = mock(JpaJaxbNotificationAdapterImpl.class);
when(notificationDao.findPermissionsByOrcidAndClient(anyString(), anyString(), anyInt(), anyInt())).thenReturn(new ArrayList<NotificationEntity>());
when(adapter.toNotification(Matchers.<ArrayList<NotificationEntity>>any())).thenReturn(notificationPermissions);
NotificationManager notificationManager = new NotificationManagerImpl();
ReflectionTestUtils.setField(notificationManager, "notificationAdapter", adapter);
ReflectionTestUtils.setField(notificationManager, "notificationDao", notificationDao);
NotificationPermissions notifications = notificationManager.findPermissionsByOrcidAndClient("some-orcid", "some-client", 0, OrcidApiConstants.MAX_NOTIFICATIONS_AVAILABLE);
assertEquals(notificationPermissions.size(), notifications.getNotifications().size());
}
Aggregations