Search in sources :

Example 6 with NotificationConfigurationDto

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);
}
Also used : NotificationConfigurationDto(eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto) Before(org.junit.Before)

Example 7 with NotificationConfigurationDto

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());
}
Also used : NotificationConfigurationDto(eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 8 with NotificationConfigurationDto

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());
}
Also used : NotificationConfigurationDto(eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto) IdmNotificationConfigurationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationConfigurationFilter) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 9 with NotificationConfigurationDto

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());
}
Also used : NotificationConfigurationDto(eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto) IdmNotificationConfigurationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationConfigurationFilter) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 10 with NotificationConfigurationDto

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;
}
Also used : NotificationConfigurationDto(eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto)

Aggregations

NotificationConfigurationDto (eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto)19 Test (org.junit.Test)11 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)10 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)7 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)6 IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)5 ArrayList (java.util.ArrayList)5 IdmNotificationConfigurationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationConfigurationFilter)4 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)3 EmailModel (com.nilhcem.fakesmtp.model.EmailModel)1 AbstractNotificationTest (eu.bcvsolutions.idm.test.api.AbstractNotificationTest)1 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 Before (org.junit.Before)1 Transactional (org.springframework.transaction.annotation.Transactional)1