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();
}
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());
}
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());
}
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());
}
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);
}
Aggregations