Search in sources :

Example 16 with IdmNotificationTemplateDto

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

the class AbstractModuleDescriptor method getNotificationTemplateId.

/**
 * Returns notification template by given code
 * @param code
 * @return
 * @throws IllegalArgumentException if template by given code is not found
 */
protected UUID getNotificationTemplateId(String code) {
    Assert.hasLength(code);
    // 
    IdmNotificationTemplateDto notificationTemplate = notificationTemplateService.getByCode(code);
    if (notificationTemplate == null) {
        throw new IllegalArgumentException(String.format("System template with code [%s] for module [%s] not found. Check template's path configuration [%s].", code, getId(), IdmNotificationTemplateService.TEMPLATE_FOLDER));
    }
    return notificationTemplate.getId();
}
Also used : IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)

Example 17 with IdmNotificationTemplateDto

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

the class DefaultNotificationServiceIntegrationTest method testSendSimple.

@Test
@Transactional
public void testSendSimple() {
    assertEquals(0, idmNotificationRepository.count());
    IdmNotificationTemplateDto template = createTestTemplate("Idm notification", "subject");
    IdmIdentityDto identity = identityService.getByUsername(InitTestData.TEST_USER_1);
    notificationManager.send(TOPIC, new IdmMessageDto.Builder().setTemplate(template).build(), identity);
    assertEquals(1, idmNotificationRepository.count());
    assertEquals(1, emailLogRepository.count());
}
Also used : 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 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 19 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 20 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)

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