use of org.orcid.jaxb.model.notification_v2.Notification in project ORCID-Source by ORCID.
the class NotificationManagerTest method filterActionedNotificationAlertsTest.
@Test
public void filterActionedNotificationAlertsTest() {
TargetProxyHelper.injectIntoProxy(notificationManager, "notificationDao", mockNotificationDao);
when(mockNotificationDao.findByOricdAndId(Matchers.anyString(), Matchers.anyLong())).thenReturn(null);
List<Notification> notifications = IntStream.range(0, 10).mapToObj(new IntFunction<Notification>() {
@Override
public Notification apply(int value) {
if (value % 3 == 0) {
NotificationInstitutionalConnection n = new NotificationInstitutionalConnection();
n.setSource(new Source("0000-0000-0000-0000"));
n.setPutCode(Long.valueOf(value));
return n;
} else {
NotificationPermission n = new NotificationPermission();
n.setPutCode(Long.valueOf(value));
return n;
}
}
}).collect(Collectors.toList());
assertEquals(10, notifications.size());
notifications = notificationManager.filterActionedNotificationAlerts(notifications, "some-orcid");
assertEquals(6, notifications.size());
for (Notification n : notifications) {
assertEquals(NotificationType.PERMISSION, n.getNotificationType());
assertNotNull(n.getPutCode());
assertThat(n.getPutCode(), not(anyOf(is(Long.valueOf(0)), is(Long.valueOf(3)), is(Long.valueOf(6)), is(Long.valueOf(9)))));
}
}
use of org.orcid.jaxb.model.notification_v2.Notification in project ORCID-Source by ORCID.
the class NotificationManagerTest method testCreateCustomNotification.
@Test
public void testCreateCustomNotification() {
SourceEntity sourceEntity = new SourceEntity(new ClientDetailsEntity("APP-5555555555555555"));
when(sourceManager.retrieveSourceEntity()).thenReturn(sourceEntity);
when(sourceManager.retrieveSourceOrcid()).thenReturn("APP-5555555555555555");
String testOrcid = "0000-0000-0000-0003";
NotificationCustom notification = new NotificationCustom();
notification.setSubject("Test subject");
notification.setLang("en-gb");
Notification result = notificationManager.createNotification(testOrcid, notification);
assertNotNull(result);
assertTrue(result instanceof NotificationCustom);
NotificationCustom customResult = (NotificationCustom) result;
assertEquals("Test subject", customResult.getSubject());
assertEquals("en-gb", customResult.getLang());
}
use of org.orcid.jaxb.model.notification_v2.Notification in project ORCID-Source by ORCID.
the class JpaJaxbNotificationAdapterTest method testCustomEntityToNotification.
@Test
public void testCustomEntityToNotification() {
NotificationCustomEntity notificationEntity = new NotificationCustomEntity();
notificationEntity.setId(123L);
notificationEntity.setNotificationType(NotificationType.CUSTOM);
notificationEntity.setSubject("Test subject");
notificationEntity.setDateCreated(DateUtils.convertToDate("2014-01-01T09:17:56"));
notificationEntity.setReadDate(DateUtils.convertToDate("2014-03-04T17:43:06"));
Notification notification = jpaJaxbNotificationAdapter.toNotification(notificationEntity);
assertNotNull(notification);
assertTrue(notification instanceof NotificationCustom);
NotificationCustom notificationCustom = (NotificationCustom) notification;
assertEquals(NotificationType.CUSTOM, notification.getNotificationType());
assertEquals("Test subject", notificationCustom.getSubject());
assertEquals("2014-01-01T09:17:56.000Z", notification.getCreatedDate().toXMLFormat());
assertEquals("2014-03-04T17:43:06.000Z", notification.getReadDate().toXMLFormat());
}
use of org.orcid.jaxb.model.notification_v2.Notification in project ORCID-Source by ORCID.
the class NotificationController method addSubjectToNotifications.
private void addSubjectToNotifications(List<Notification> notifications) {
for (Notification notification : notifications) {
if (notification instanceof NotificationPermission) {
NotificationPermission naa = (NotificationPermission) notification;
String customSubject = naa.getNotificationSubject();
if (StringUtils.isNotBlank(customSubject)) {
naa.setSubject(customSubject);
} else {
naa.setSubject(getMessage(buildInternationalizationKey(NotificationType.class, naa.getNotificationType().value())));
}
} else if (notification instanceof NotificationAmended) {
NotificationAmended na = (NotificationAmended) notification;
na.setSubject(getMessage(buildInternationalizationKey(NotificationType.class, na.getNotificationType().value())));
} else if (notification instanceof NotificationInstitutionalConnection) {
NotificationInstitutionalConnection nic = (NotificationInstitutionalConnection) notification;
nic.setSubject(getMessage(buildInternationalizationKey(NotificationType.class, nic.getNotificationType().value())));
}
}
}
use of org.orcid.jaxb.model.notification_v2.Notification in project ORCID-Source by ORCID.
the class NotificationController method getAmendedNotificationHtml.
@RequestMapping(value = "/AMENDED/{id}/notification.html", produces = OrcidApiConstants.HTML_UTF)
public ModelAndView getAmendedNotificationHtml(@PathVariable("id") String id) {
ModelAndView mav = new ModelAndView();
Notification notification = notificationManager.findByOrcidAndId(getCurrentUserOrcid(), Long.valueOf(id));
addSourceDescription(notification);
mav.addObject("notification", notification);
mav.addObject("emailName", notificationManager.deriveEmailFriendlyName(getEffectiveProfile()));
mav.setViewName("notification/amended_notification");
mav.addObject("noIndex", true);
return mav;
}
Aggregations