use of com.epam.pipeline.entity.notification.NotificationTemplate in project cloud-pipeline by epam.
the class NotificationSettingsManagerTest method createTemplate.
private NotificationTemplate createTemplate(Long id, String name) {
NotificationTemplate template = new NotificationTemplate(id);
template.setName(name);
template.setBody("//");
template.setSubject("//");
notificationTemplateDao.createNotificationTemplate(template);
return template;
}
use of com.epam.pipeline.entity.notification.NotificationTemplate 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());
}
use of com.epam.pipeline.entity.notification.NotificationTemplate 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);
}
use of com.epam.pipeline.entity.notification.NotificationTemplate in project cloud-pipeline by epam.
the class SMTPNotificationManagerTest method testEmailSendingWithParams.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testEmailSendingWithParams() {
PipelineUser user = new PipelineUser();
user.setUserName(USER_NAME);
user.setAdmin(true);
user.setAttributes(Collections.singletonMap(EMAIL_KEY, EMAIL));
userRepository.save(user);
NotificationMessage message = new NotificationMessage();
NotificationTemplate template = new NotificationTemplate();
template.setSubject(MESSAGE_SUBJECT);
template.setBody(MESSAGE_BODY_WITH_PARAM);
message.setTemplate(template);
message.setTemplateParameters(Collections.singletonMap("name", USER_NAME));
message.setToUserId(user.getId());
message.setCopyUserIds(Collections.singletonList(user.getId()));
smtpNotificationManager.notifySubscribers(message);
MimeMessage[] receivedMessages = greenMail.getReceivedMessages();
assertTrue(receivedMessages.length == 2);
String filledMessage = PARSED_MESSAGE_BODY_WITH_PARAM.replace("$templateParameters.get(\"name\")", USER_NAME);
assertTrue(GreenMailUtil.getBody(receivedMessages[0]).contains(filledMessage));
}
Aggregations