Search in sources :

Example 1 with NotificationMessageVO

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));
}
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 2 with NotificationMessageVO

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));
}
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 3 with NotificationMessageVO

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));
}
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 4 with NotificationMessageVO

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));
}
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 5 with NotificationMessageVO

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());
}
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