Search in sources :

Example 6 with IdmNotificationTemplateDto

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

the class DefaultNotificationServiceIntegrationTest method testFilterByDate.

@Test
@Transactional
public void testFilterByDate() {
    assertEquals(0, idmNotificationRepository.count());
    IdmNotificationTemplateDto template = createTestTemplate("Idm notification", "subject");
    IdmIdentityDto identity = identityService.getByUsername(InitTestData.TEST_USER_1);
    DateTime from = new DateTime().minusDays(1);
    DateTime till = new DateTime().minusDays(1);
    notificationManager.send(TOPIC, new IdmMessageDto.Builder().setTemplate(template).build(), identity);
    notificationManager.send(TOPIC, new IdmMessageDto.Builder().setTemplate(template).build(), identity);
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setNotificationType(IdmNotificationLog.class);
    assertEquals(2, notificationLogService.find(filter, null).getTotalElements());
    filter.setFrom(from);
    assertEquals(2, notificationLogService.find(filter, null).getTotalElements());
    filter.setFrom(null);
    filter.setTill(till);
    assertEquals(0, notificationLogService.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) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) DateTime(org.joda.time.DateTime) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with IdmNotificationTemplateDto

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

the class DefaultNotificationServiceIntegrationTest method testEmailFilterBySender.

@Test
@Transactional
public void testEmailFilterBySender() {
    // create templates
    IdmNotificationTemplateDto template = createTestTemplate("Idm notification", "subject");
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setSender(InitTestData.TEST_USER_2);
    assertEquals(0, emailLogService.find(filter, null).getTotalElements());
    filter.setSender(InitTestData.TEST_USER_1);
    assertEquals(0, emailLogService.find(filter, null).getTotalElements());
    // send some email
    IdmIdentityDto identity = identityService.getByUsername(InitTestData.TEST_USER_1);
    IdmIdentityDto identity2 = identityService.getByUsername(InitTestData.TEST_USER_2);
    emailService.send(TOPIC, new IdmMessageDto.Builder().setTemplate(template).build(), identity);
    filter.setSender(null);
    assertEquals(1, emailLogService.find(filter, null).getTotalElements());
    filter.setSender(identity2.getUsername());
    assertEquals(0, emailLogService.find(filter, null).getTotalElements());
    filter.setSender(null);
    filter.setRecipient(identity.getUsername());
    assertEquals(1, 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) 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with IdmNotificationTemplateDto

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

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

the class IdmMessageDtoUnitTest method testTemplateOveloadMessageAndSubject.

@Test
public void testTemplateOveloadMessageAndSubject() {
    IdmNotificationTemplateDto template = new IdmNotificationTemplateDto();
    template.setSubject("template");
    template.setBodyText("template");
    IdmMessageDto message = new IdmMessageDto.Builder().setTemplate(template).setMessage(PARAMETER_TEXT).setSubject(PARAMETER_SUBJECT).build();
    // 
    Assert.assertEquals(PARAMETER_SUBJECT, message.getSubject());
    Assert.assertEquals(PARAMETER_TEXT, message.getTextMessage());
    Assert.assertEquals(PARAMETER_TEXT, message.getHtmlMessage());
}
Also used : IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest) Test(org.junit.Test)

Example 10 with IdmNotificationTemplateDto

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

Aggregations

IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)32 Test (org.junit.Test)22 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)20 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)13 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)11 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)8 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)7 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)5 NotificationConfigurationDto (eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto)5 Transactional (org.springframework.transaction.annotation.Transactional)5 IOException (java.io.IOException)4 DateTime (org.joda.time.DateTime)3 SysProvisioningBreakConfigDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto)2 IdmNotificationDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationDto)2 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)2 ApiOperation (io.swagger.annotations.ApiOperation)2 File (java.io.File)2 DecimalFormat (java.text.DecimalFormat)2 ResponseEntity (org.springframework.http.ResponseEntity)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2