use of org.orcid.persistence.dao.NotificationDao 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());
}
use of org.orcid.persistence.dao.NotificationDao 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