use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmNotificationConfigurationService method initDefaultTopics.
/**
* Inits default notification configuration from all module descriptors.
*/
@Override
@Transactional
public void initDefaultTopics() {
moduleService.getInstalledModules().forEach(module -> {
Set<String> topicToCreate = new HashSet<>();
module.getDefaultNotificationConfigurations().forEach(config -> {
String topic = config.getTopic();
Long count = repository.countByTopic(topic);
if (topicToCreate.contains(topic) || count == 0) {
topicToCreate.add(topic);
UUID template = config.getTemplate();
NotificationConfigurationDto notConfiguration = new NotificationConfigurationDto(config);
notConfiguration.setTemplate(template);
repository.save(toEntity(notConfiguration, null));
}
});
});
}
use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.
the class ExampleModuleDescriptor method getDefaultNotificationConfigurations.
@Override
public List<NotificationConfigurationDto> getDefaultNotificationConfigurations() {
List<NotificationConfigurationDto> configs = new ArrayList<>();
configs.add(new NotificationConfigurationDto(TOPIC_EXAMPLE, null, IdmWebsocketLog.NOTIFICATION_TYPE, "Example notification", null));
return configs;
}
use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.
the class DefaultNotificationServiceIntegrationTest method sendWildCardsWithTemplateAndOwnText.
@Test
public void sendWildCardsWithTemplateAndOwnText() {
String topic = "testTopic-" + System.currentTimeMillis();
String textMessage = "testMessageText-" + 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);
//
// set all text into message
List<IdmNotificationLogDto> notifications = notificationManager.send(topic, new IdmMessageDto.Builder().setLevel(// set level
NotificationLevel.SUCCESS).setHtmlMessage(textMessage).setTextMessage(textMessage).setSubject(textMessage).build(), identity);
//
assertEquals(1, notifications.size());
//
IdmNotificationLogDto notification = notifications.get(0);
// topic has own template, but in message is set text
assertEquals(textMessage, notification.getMessage().getHtmlMessage());
assertEquals(textMessage, notification.getMessage().getSubject());
assertEquals(textMessage, notification.getMessage().getTextMessage());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.
the class DefaultNotificationServiceIntegrationTest method sendWildCardsWithoutTemplate.
@Test
public void sendWildCardsWithoutTemplate() {
String topic = "testTopic-" + System.currentTimeMillis();
String text = "testMessageText-" + System.currentTimeMillis();
//
IdmIdentityDto identity = helper.createIdentity();
// create config, for email, topic and without level = wildcard
NotificationConfigurationDto config = new NotificationConfigurationDto();
// topic
config.setTopic(topic);
// email
config.setNotificationType(IdmEmailLog.NOTIFICATION_TYPE);
config = notificationConfigurationService.save(config);
//
// set all text into message
List<IdmNotificationLogDto> notifications = notificationManager.send(topic, new IdmMessageDto.Builder().setLevel(// set level
NotificationLevel.SUCCESS).setHtmlMessage(text).setTextMessage(text).setSubject(text).build(), identity);
//
assertEquals(1, notifications.size());
//
IdmNotificationLogDto notification = notifications.get(0);
assertEquals(text, notification.getMessage().getHtmlMessage());
assertEquals(text, notification.getMessage().getSubject());
assertEquals(text, notification.getMessage().getTextMessage());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.
the class DefaultNotificationServiceIntegrationTest method sendNofificationToConsoleIfTopicNotFound.
@Test
public void sendNofificationToConsoleIfTopicNotFound() {
String topic = helper.createName();
// create config, for email, topic, template and without level = wildcard
NotificationConfigurationDto config = new NotificationConfigurationDto();
// topic
config.setTopic(topic);
config.setLevel(NotificationLevel.INFO);
// email
config.setNotificationType(IdmEmailLog.NOTIFICATION_TYPE);
config = notificationConfigurationService.save(config);
//
IdmIdentityDto identity = helper.createIdentity();
List<IdmNotificationLogDto> notifications = notificationManager.send(topic, new IdmMessageDto.Builder().setLevel(// set level
NotificationLevel.SUCCESS).setMessage("message").setSubject("subject").build(), identity);
//
assertEquals(1, notifications.size());
//
// console channel is expected, because topic configuration is wrong
IdmNotificationLogDto notification = notifications.get(0);
//
Assert.assertEquals(IdmConsoleLog.NOTIFICATION_TYPE, notification.getType());
}
Aggregations