Search in sources :

Example 51 with IdmNotificationTemplateDto

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

the class DefaultNotificationServiceIntegrationTest method testEmailFilterBySent.

@Test
@Transactional
public void testEmailFilterBySent() {
    IdmIdentityDto identity = identityService.getByUsername(InitTestData.TEST_USER_1);
    IdmNotificationFilter filter = new IdmNotificationFilter();
    // 
    // create templates
    IdmNotificationTemplateDto template = createTestTemplate("Idm notification", "subject");
    // 
    emailService.send(new IdmMessageDto.Builder().setTemplate(template).build(), identity);
    filter.setSent(true);
    assertEquals(0, emailLogService.find(filter, null).getTotalElements());
    emailService.send(new IdmMessageDto.Builder().setTemplate(template).build(), identity);
    filter.setSent(false);
    assertEquals(2, emailLogService.find(filter, null).getTotalElements());
}
Also used : IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 52 with IdmNotificationTemplateDto

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

the class DefaultNotificationServiceIntegrationTest method parentFilterText.

@Test
public void parentFilterText() {
    IdmNotificationFilter filter = new IdmNotificationFilter();
    IdmNotificationDto notification = new IdmNotificationDto();
    IdmNotificationDto parentNotification = new IdmNotificationDto();
    // prepare template and message
    IdmNotificationTemplateDto template2 = createTestTemplate("TestTemplate5", "testSubject5");
    IdmMessageDto message2 = new IdmMessageDto.Builder().setTemplate(template2).build();
    // set parent
    parentNotification.setMessage(message2);
    IdmNotificationLogDto logDto = notificationManager.send(parentNotification);
    notification.setParent(logDto.getMessage().getId());
    // 
    // send message
    IdmNotificationTemplateDto template = createTestTemplate("TestTemplate4", "testSubject4");
    IdmMessageDto message = new IdmMessageDto.Builder().setTemplate(template).build();
    notification.setMessage(message);
    notificationManager.send(notification);
    // set filter
    filter.setParent(logDto.getId());
    Page<IdmNotificationLogDto> result = notificationLogService.find(filter, null);
    assertEquals("Wrong sender", logDto.getId(), result.getContent().get(0).getParent());
}
Also used : IdmNotificationDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationDto) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 53 with IdmNotificationTemplateDto

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

the class DefaultNotificationServiceIntegrationTest method createTestTemplate.

private IdmNotificationTemplateDto createTestTemplate(String body, String subject) {
    // create templates
    IdmNotificationTemplateDto template = new IdmNotificationTemplateDto();
    template.setName("test_" + System.currentTimeMillis());
    template.setBodyHtml(body);
    template.setBodyText(body);
    template.setCode(subject);
    template.setSubject(subject);
    return notificationTemplateService.save(template);
}
Also used : IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)

Example 54 with IdmNotificationTemplateDto

use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto 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 55 with IdmNotificationTemplateDto

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

the class DefaultNotificationServiceIntegrationTest method senderFilterTest.

@Test
public void senderFilterTest() {
    IdmIdentityDto sender = helper.createIdentity();
    IdmNotificationFilter filter = new IdmNotificationFilter();
    IdmNotificationDto notification = new IdmNotificationDto();
    notification.setIdentitySender(sender.getId());
    // 
    // create templates
    IdmNotificationTemplateDto template = createTestTemplate("TestTemplate3", "testSubject3");
    IdmMessageDto message = new IdmMessageDto.Builder().setTemplate(template).build();
    notification.setMessage(message);
    notificationManager.send(notification);
    // 
    // filter text BODY
    filter.setSender(sender.getUsername());
    Page<IdmNotificationLogDto> result = notificationLogService.find(filter, null);
    assertEquals("Wrong sender", sender.getId(), result.getContent().get(0).getIdentitySender());
}
Also used : IdmNotificationDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationDto) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)87 Test (org.junit.Test)68 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)53 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)42 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)42 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)31 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)23 NotificationConfigurationDto (eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto)19 Transactional (org.springframework.transaction.annotation.Transactional)18 DefaultAttachmentManagerIntegrationTest (eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest)17 NotificationLevel (eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel)14 IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)13 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)12 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)11 UUID (java.util.UUID)9 AbstractBulkActionTest (eu.bcvsolutions.idm.test.api.AbstractBulkActionTest)8 ZonedDateTime (java.time.ZonedDateTime)8 IdmNotificationDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationDto)7 IdmNotificationTemplateService (eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationTemplateService)7 HashSet (java.util.HashSet)7