Search in sources :

Example 6 with NotificationMessageVO

use of com.epam.pipeline.controller.vo.notification.NotificationMessageVO in project cloud-pipeline by epam.

the class NotificationManagerTest method testCreateNotificationFailsIfReceiverIsNotSpecified.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testCreateNotificationFailsIfReceiverIsNotSpecified() {
    final NotificationMessageVO messageWithoutUserNames = new NotificationMessageVO();
    messageWithoutUserNames.setBody(BODY);
    messageWithoutUserNames.setSubject(SUBJECT);
    assertThrows(IllegalArgumentException.class, () -> notificationManager.createNotification(messageWithoutUserNames));
}
Also used : NotificationMessageVO(com.epam.pipeline.controller.vo.notification.NotificationMessageVO) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with NotificationMessageVO

use of com.epam.pipeline.controller.vo.notification.NotificationMessageVO in project cloud-pipeline by epam.

the class NotificationManagerTest method testCreateNotificationWithExistingCopyUser.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testCreateNotificationWithExistingCopyUser() {
    final NotificationMessageVO message = new NotificationMessageVO();
    message.setBody(BODY);
    message.setSubject(SUBJECT);
    message.setParameters(PARAMETERS);
    message.setToUser(testUser1.getUserName());
    message.setCopyUsers(Collections.singletonList(testUser2.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());
    Assert.assertEquals(Collections.singletonList(testUser2.getId()), loadedMessage.getCopyUserIds());
}
Also used : NotificationMessageVO(com.epam.pipeline.controller.vo.notification.NotificationMessageVO) NotificationMessage(com.epam.pipeline.entity.notification.NotificationMessage) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

NotificationMessageVO (com.epam.pipeline.controller.vo.notification.NotificationMessageVO)7 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)7 Test (org.junit.Test)7 Transactional (org.springframework.transaction.annotation.Transactional)7 NotificationMessage (com.epam.pipeline.entity.notification.NotificationMessage)2