Search in sources :

Example 11 with NotificationSettings

use of com.epam.pipeline.entity.notification.NotificationSettings in project cloud-pipeline by epam.

the class NotificationSettingsManagerTest method testDelete.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testDelete() {
    NotificationTemplate template = createTemplate(1L, "template");
    NotificationSettings settings = createSettings(NotificationType.LONG_RUNNING, template.getId(), 1L, 1L);
    notificationSettingsManager.createOrUpdate(settings);
    NotificationSettings loaded = notificationSettingsManager.load(NotificationType.LONG_RUNNING);
    Assert.assertNotNull(loaded);
    notificationSettingsManager.delete(loaded.getId());
    loaded = notificationSettingsManager.load(NotificationType.LONG_RUNNING);
    Assert.assertNull(loaded);
}
Also used : NotificationSettings(com.epam.pipeline.entity.notification.NotificationSettings) NotificationTemplate(com.epam.pipeline.entity.notification.NotificationTemplate) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with NotificationSettings

use of com.epam.pipeline.entity.notification.NotificationSettings in project cloud-pipeline by epam.

the class NotificationAspectTest method setUp.

@Before
public void setUp() throws Exception {
    statusTemplate = new NotificationTemplate(5L);
    statusTemplate.setBody("///");
    statusTemplate.setSubject("//");
    statusTemplate.setName("testTemplate");
    notificationTemplateDao.createNotificationTemplate(statusTemplate);
    NotificationSettings settings = new NotificationSettings();
    settings.setType(NotificationSettings.NotificationType.PIPELINE_RUN_STATUS);
    settings.setKeepInformedAdmins(true);
    settings.setInformedUserIds(Collections.emptyList());
    settings.setTemplateId(statusTemplate.getId());
    settings.setThreshold(null);
    settings.setEnabled(true);
    settings.setResendDelay(null);
    settings.setKeepInformedOwner(true);
    notificationSettingsDao.createNotificationSettings(settings);
    testOwner = new PipelineUser("testOwner");
    userDao.createUser(testOwner, Collections.emptyList());
    pipeline = new Pipeline();
    pipeline.setName("TestPipeline");
    Mockito.when(pipelineManager.load(Mockito.anyLong())).thenReturn(pipeline);
}
Also used : PipelineUser(com.epam.pipeline.entity.user.PipelineUser) NotificationSettings(com.epam.pipeline.entity.notification.NotificationSettings) NotificationTemplate(com.epam.pipeline.entity.notification.NotificationTemplate) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Before(org.junit.Before)

Example 13 with NotificationSettings

use of com.epam.pipeline.entity.notification.NotificationSettings in project cloud-pipeline by epam.

the class NotificationSettingsManagerTest method testCreateWithoutThresholdAndResendDelay.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testCreateWithoutThresholdAndResendDelay() {
    NotificationTemplate template = createTemplate(1L, "template");
    NotificationSettings settings = createSettings(NotificationType.LONG_RUNNING, template.getId(), null, null);
    notificationSettingsManager.createOrUpdate(settings);
    NotificationSettings loaded = notificationSettingsManager.load(NotificationType.LONG_RUNNING);
    Assert.assertEquals(-1, loaded.getThreshold().longValue());
    Assert.assertEquals(-1, loaded.getResendDelay().longValue());
}
Also used : NotificationSettings(com.epam.pipeline.entity.notification.NotificationSettings) NotificationTemplate(com.epam.pipeline.entity.notification.NotificationTemplate) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

NotificationSettings (com.epam.pipeline.entity.notification.NotificationSettings)13 NotificationTemplate (com.epam.pipeline.entity.notification.NotificationTemplate)8 Transactional (org.springframework.transaction.annotation.Transactional)8 NotificationMessage (com.epam.pipeline.entity.notification.NotificationMessage)5 PipelineUser (com.epam.pipeline.entity.user.PipelineUser)5 Test (org.junit.Test)4 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)3 TypeReference (com.fasterxml.jackson.core.type.TypeReference)3 AbstractSecuredEntity (com.epam.pipeline.entity.AbstractSecuredEntity)2 Issue (com.epam.pipeline.entity.issue.Issue)2 IssueComment (com.epam.pipeline.entity.issue.IssueComment)2 NotificationType (com.epam.pipeline.entity.notification.NotificationSettings.NotificationType)2 ExtendedRole (com.epam.pipeline.entity.user.ExtendedRole)2 Map (java.util.Map)2 MessageConstants (com.epam.pipeline.common.MessageConstants)1 MessageHelper (com.epam.pipeline.common.MessageHelper)1 JsonMapper (com.epam.pipeline.config.JsonMapper)1 NotificationMessageVO (com.epam.pipeline.controller.vo.notification.NotificationMessageVO)1 MonitoringNotificationDao (com.epam.pipeline.dao.notification.MonitoringNotificationDao)1 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)1