use of com.epam.pipeline.controller.vo.notification.NotificationMessageVO in project cloud-pipeline by epam.
the class NotificationManagerTest method testCreateNotificationsFailsIfReceiverUserDoesNotExist.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testCreateNotificationsFailsIfReceiverUserDoesNotExist() {
final NotificationMessageVO messageWithNonExistingUser = new NotificationMessageVO();
messageWithNonExistingUser.setBody(BODY);
messageWithNonExistingUser.setSubject(SUBJECT);
messageWithNonExistingUser.setToUser(NON_EXISTING_USER);
assertThrows(IllegalArgumentException.class, () -> notificationManager.createNotification(messageWithNonExistingUser));
}
use of com.epam.pipeline.controller.vo.notification.NotificationMessageVO in project cloud-pipeline by epam.
the class NotificationManagerTest method testCreateNotificationFailsIfOneOfCopyUsersDoesNotExist.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testCreateNotificationFailsIfOneOfCopyUsersDoesNotExist() {
final NotificationMessageVO message = new NotificationMessageVO();
message.setBody(BODY);
message.setSubject(SUBJECT);
message.setParameters(PARAMETERS);
message.setToUser(testUser1.getUserName());
message.setCopyUsers(Arrays.asList(testUser2.getUserName(), NON_EXISTING_USER));
assertThrows(IllegalArgumentException.class, () -> notificationManager.createNotification(message));
}
use of com.epam.pipeline.controller.vo.notification.NotificationMessageVO in project cloud-pipeline by epam.
the class NotificationManagerTest method testCreateNotificationFailsIfSubjectIsNotSpecified.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testCreateNotificationFailsIfSubjectIsNotSpecified() {
final String userName = testUser1.getUserName();
final NotificationMessageVO messageWithoutSubject = new NotificationMessageVO();
messageWithoutSubject.setBody(BODY);
messageWithoutSubject.setToUser(userName);
assertThrows(IllegalArgumentException.class, () -> notificationManager.createNotification(messageWithoutSubject));
}
use of com.epam.pipeline.controller.vo.notification.NotificationMessageVO in project cloud-pipeline by epam.
the class NotificationManagerTest method testCreateNotificationFailsIfBodyIsNotSpecified.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testCreateNotificationFailsIfBodyIsNotSpecified() {
final String userName = testUser1.getUserName();
final NotificationMessageVO messageWithoutBody = new NotificationMessageVO();
messageWithoutBody.setSubject(SUBJECT);
messageWithoutBody.setToUser(userName);
assertThrows(IllegalArgumentException.class, () -> notificationManager.createNotification(messageWithoutBody));
}
use of com.epam.pipeline.controller.vo.notification.NotificationMessageVO in project cloud-pipeline by epam.
the class NotificationManagerTest method testCreateNotification.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testCreateNotification() {
final NotificationMessageVO message = new NotificationMessageVO();
message.setBody(BODY);
message.setSubject(SUBJECT);
message.setParameters(PARAMETERS);
message.setToUser(testUser1.getUserName());
final NotificationMessage savedMessage = notificationManager.createNotification(message);
final NotificationMessage loadedMessage = monitoringNotificationDao.loadMonitoringNotification(savedMessage.getId());
Assert.assertEquals(BODY, loadedMessage.getBody());
Assert.assertEquals(SUBJECT, loadedMessage.getSubject());
Assert.assertEquals(PARAMETERS, loadedMessage.getTemplateParameters());
Assert.assertEquals(testUser1.getId(), loadedMessage.getToUserId());
}
Aggregations