Search in sources :

Example 16 with NotificationConfigurationDto

use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.

the class DefaultNotificationServiceIntegrationTest method sendTwoWildCardsWithOwnMessage.

@Test
public void sendTwoWildCardsWithOwnMessage() {
    String topic = "testTopic-" + System.currentTimeMillis();
    String textTemplate1 = "testMessageTemplate1-" + System.currentTimeMillis();
    String textTemplate2 = "testMessageTemplate2-" + System.currentTimeMillis();
    String textMessage = "testMessageText-" + System.currentTimeMillis();
    // 
    IdmNotificationTemplateDto template1 = new IdmNotificationTemplateDto();
    template1.setName(textTemplate1);
    template1.setCode(textTemplate1);
    template1.setBodyHtml(textTemplate1);
    template1.setBodyText(textTemplate1);
    template1.setSubject(textTemplate1);
    template1 = notificationTemplateService.save(template1);
    // 
    IdmNotificationTemplateDto template2 = new IdmNotificationTemplateDto();
    template2.setName(textTemplate2);
    template2.setCode(textTemplate2);
    template2.setBodyHtml(textTemplate2);
    template2.setBodyText(textTemplate2);
    template2.setSubject(textTemplate2);
    template2 = notificationTemplateService.save(template2);
    // 
    IdmIdentityDto identity = helper.createIdentity();
    // create config, for email, topic, template and without level = wildcard
    NotificationConfigurationDto config1 = new NotificationConfigurationDto();
    // topic
    config1.setTopic(topic);
    // template
    config1.setTemplate(template1.getId());
    // email
    config1.setNotificationType(IdmEmailLog.NOTIFICATION_TYPE);
    config1 = notificationConfigurationService.save(config1);
    // 
    // create second config, for console, topic, template and without level = wildcard
    NotificationConfigurationDto config = new NotificationConfigurationDto();
    // same topic
    config.setTopic(topic);
    // different template
    config.setTemplate(template2.getId());
    // console
    config.setNotificationType(IdmConsoleLog.NOTIFICATION_TYPE);
    config = notificationConfigurationService.save(config);
    // 
    List<IdmNotificationLogDto> notifications = notificationManager.send(topic, new IdmMessageDto.Builder().setLevel(// set level
    NotificationLevel.SUCCESS).setHtmlMessage(textMessage).setTextMessage(textMessage).setSubject(textMessage).build(), identity);
    // 
    assertEquals(2, notifications.size());
    // 
    // bouth notifacations has same text
    IdmNotificationLogDto notification1 = notifications.get(0);
    IdmNotificationLogDto notification2 = notifications.get(1);
    // 
    assertEquals(textMessage, notification1.getMessage().getHtmlMessage());
    assertEquals(textMessage, notification1.getMessage().getSubject());
    assertEquals(textMessage, notification1.getMessage().getTextMessage());
    // 
    assertEquals(textMessage, notification2.getMessage().getHtmlMessage());
    assertEquals(textMessage, notification2.getMessage().getSubject());
    assertEquals(textMessage, notification2.getMessage().getTextMessage());
}
Also used : NotificationConfigurationDto(eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) 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 17 with NotificationConfigurationDto

use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.

the class DefaultNotificationServiceIntegrationTest method sendTwoWildCardsWithDifferentTemplate.

@Test
public void sendTwoWildCardsWithDifferentTemplate() {
    String topic = "testTopic-" + System.currentTimeMillis();
    String textTemplate1 = "testMessageTemplate1-" + System.currentTimeMillis();
    String textTemplate2 = "testMessageTemplate2-" + System.currentTimeMillis();
    // 
    IdmNotificationTemplateDto template1 = new IdmNotificationTemplateDto();
    template1.setName(textTemplate1);
    template1.setCode(textTemplate1);
    template1.setBodyHtml(textTemplate1);
    template1.setBodyText(textTemplate1);
    template1.setSubject(textTemplate1);
    template1 = notificationTemplateService.save(template1);
    // 
    IdmNotificationTemplateDto template2 = new IdmNotificationTemplateDto();
    template2.setName(textTemplate2);
    template2.setCode(textTemplate2);
    template2.setBodyHtml(textTemplate2);
    template2.setBodyText(textTemplate2);
    template2.setSubject(textTemplate2);
    template2 = notificationTemplateService.save(template2);
    // 
    IdmIdentityDto identity = helper.createIdentity();
    // create config, for email, topic, template and without level = wildcard
    NotificationConfigurationDto config1 = new NotificationConfigurationDto();
    // topic
    config1.setTopic(topic);
    // template
    config1.setTemplate(template1.getId());
    // email
    config1.setNotificationType(IdmEmailLog.NOTIFICATION_TYPE);
    config1 = notificationConfigurationService.save(config1);
    // 
    // create second config, for console, topic, template and without level = wildcard
    NotificationConfigurationDto config = new NotificationConfigurationDto();
    // same topic
    config.setTopic(topic);
    // different template
    config.setTemplate(template2.getId());
    // console
    config.setNotificationType(IdmConsoleLog.NOTIFICATION_TYPE);
    config = notificationConfigurationService.save(config);
    // 
    List<IdmNotificationLogDto> notifications = notificationManager.send(topic, new IdmMessageDto.Builder().setLevel(// set level
    NotificationLevel.SUCCESS).build(), identity);
    // 
    assertEquals(2, notifications.size());
    // 
    // 
    int orderConsole = 0;
    int orderEmail = 1;
    // we didn't know order
    if (!notifications.get(0).getMessage().getHtmlMessage().equals(textTemplate2)) {
        // email first
        orderConsole = 1;
        orderEmail = 0;
    }
    // 
    // Notification has different text
    IdmNotificationLogDto notificationConsole = notifications.get(orderConsole);
    assertEquals(textTemplate2, notificationConsole.getMessage().getHtmlMessage());
    assertEquals(textTemplate2, notificationConsole.getMessage().getSubject());
    assertEquals(textTemplate2, notificationConsole.getMessage().getTextMessage());
    // 
    IdmNotificationLogDto notificationEmail = notifications.get(orderEmail);
    assertEquals(textTemplate1, notificationEmail.getMessage().getHtmlMessage());
    assertEquals(textTemplate1, notificationEmail.getMessage().getSubject());
    assertEquals(textTemplate1, notificationEmail.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 18 with NotificationConfigurationDto

use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.

the class IdmNotificationConfigurationFilterTest method testTopicFilter.

@Test
public void testTopicFilter() {
    String text = "someText" + System.currentTimeMillis();
    NotificationConfigurationDto notification = createNotification(NotificationLevel.SUCCESS, CoreModuleDescriptor.MODULE_ID + ":test001", text, null);
    IdmNotificationConfigurationFilter filter = new IdmNotificationConfigurationFilter();
    filter.setText("core:test001");
    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 19 with NotificationConfigurationDto

use of eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto in project CzechIdMng by bcvsolutions.

the class DefaultRptModuleDescriptor method getDefaultNotificationConfigurations.

@Override
public List<NotificationConfigurationDto> getDefaultNotificationConfigurations() {
    List<NotificationConfigurationDto> configs = new ArrayList<>();
    // 
    configs.add(new NotificationConfigurationDto(TOPIC_REPORT_GENERATE_SUCCESS, null, IdmWebsocketLog.NOTIFICATION_TYPE, "Send notification, after report is successfully generated.", getNotificationTemplateId("reportGenerateSuccess")));
    // 
    configs.add(new NotificationConfigurationDto(TOPIC_REPORT_GENERATE_FAILED, null, IdmWebsocketLog.NOTIFICATION_TYPE, "Send notification, after report generation failed.", getNotificationTemplateId("reportGenerateFailed")));
    // 
    return configs;
}
Also used : NotificationConfigurationDto(eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto) ArrayList(java.util.ArrayList)

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