use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.
the class DefaultNotificationServiceIntegrationTest method clear.
@Before
public void clear() {
loginAsAdmin("admin");
// TODO: make test stateless!
emailLogRepository.deleteAll();
idmNotificationRepository.deleteAll();
//
config = new NotificationConfigurationDto();
config.setTopic(TOPIC);
config.setNotificationType(IdmEmailLog.NOTIFICATION_TYPE);
config = notificationConfigurationService.save(config);
}
use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.
the class DefaultNotificationServiceIntegrationTest method sendWildCardsWithTemplateWithoutText.
@Test
public void sendWildCardsWithTemplateWithoutText() {
String topic = "testTopic-" + System.currentTimeMillis();
String textTemplate = "testMessageTemplate-" + System.currentTimeMillis();
//
IdmNotificationTemplateDto template = new IdmNotificationTemplateDto();
template.setName(textTemplate);
template.setCode(textTemplate);
template.setBodyHtml(textTemplate);
template.setBodyText(textTemplate);
template.setSubject(textTemplate);
template = notificationTemplateService.save(template);
//
IdmIdentityDto identity = helper.createIdentity();
// create config, for email, topic, template and without level = wildcard
NotificationConfigurationDto config = new NotificationConfigurationDto();
// topic
config.setTopic(topic);
// template
config.setTemplate(template.getId());
// email
config.setNotificationType(IdmEmailLog.NOTIFICATION_TYPE);
config = notificationConfigurationService.save(config);
//
List<IdmNotificationLogDto> notifications = notificationManager.send(topic, new IdmMessageDto.Builder().setLevel(// set level
NotificationLevel.SUCCESS).build(), identity);
//
assertEquals(1, notifications.size());
//
IdmNotificationLogDto notification = notifications.get(0);
// topic has own template and in message isnt set text
assertEquals(textTemplate, notification.getMessage().getHtmlMessage());
assertEquals(textTemplate, notification.getMessage().getSubject());
assertEquals(textTemplate, notification.getMessage().getTextMessage());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.
the class IdmNotificationConfigurationFilterTest method testTemplateIdFilter.
@Test
public void testTemplateIdFilter() {
String text = "someText" + System.currentTimeMillis();
IdmNotificationTemplateDto templ = createTemplate("template " + System.currentTimeMillis(), "code", "testFilter");
NotificationConfigurationDto notification = createNotification(NotificationLevel.SUCCESS, CoreModuleDescriptor.MODULE_ID + ":test003", text, templ.getId());
IdmNotificationConfigurationFilter filter = new IdmNotificationConfigurationFilter();
filter.setTemplate(templ.getId());
filter.setNotificationType(text);
Page<NotificationConfigurationDto> result = idmNotificationConfService.find(filter, null);
assertEquals(1, result.getTotalElements());
assertEquals(notification.getId(), result.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.
the class IdmNotificationConfigurationFilterTest method testLevelFilter.
@Test
public void testLevelFilter() {
String text = "someText" + System.currentTimeMillis();
NotificationConfigurationDto notification = createNotification(NotificationLevel.ERROR, CoreModuleDescriptor.MODULE_ID + ":test002", text, null);
IdmNotificationConfigurationFilter filter = new IdmNotificationConfigurationFilter();
filter.setLevel(NotificationLevel.ERROR);
filter.setNotificationType(text);
Page<NotificationConfigurationDto> result = idmNotificationConfService.find(filter, null);
assertEquals(1, result.getTotalElements());
assertEquals(notification.getId(), result.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.
the class IdmNotificationConfigurationFilterTest method createNotification.
/**
* Creates notification configuration, saves it in service and returns it
*
* @return
*/
private NotificationConfigurationDto createNotification(NotificationLevel level, String topic, String notificationType, UUID templateId) {
NotificationConfigurationDto notification = new NotificationConfigurationDto();
notification.setLevel(level);
notification.setTopic(topic);
notification.setNotificationType(notificationType);
notification.setTemplate(templateId);
notification = idmNotificationConfService.save(notification);
return notification;
}
Aggregations