Search in sources :

Example 46 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("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)

Example 47 with IdmNotificationTemplateDto

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

the class IdmNotificationConfigurationFilterTest method createTemplate.

/**
 * Creates and returns notification template
 *
 * @return
 */
private IdmNotificationTemplateDto createTemplate(String subject) {
    IdmNotificationTemplateDto templ = new IdmNotificationTemplateDto();
    templ.setName(getHelper().createName());
    templ.setCode(templ.getName());
    templ.setSubject(subject);
    return idmNotificationTemplateService.save(templ);
}
Also used : IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)

Example 48 with IdmNotificationTemplateDto

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

the class NotificationTemplateDeleteBulkAction method prevalidate.

@Override
public ResultModels prevalidate() {
    IdmBulkActionDto action = getAction();
    List<UUID> entities = getEntities(action, new StringBuilder());
    ResultModels results = new ResultModels();
    IdmNotificationTemplateFilter templateFilter = new IdmNotificationTemplateFilter();
    templateFilter.setUnmodifiable(Boolean.TRUE);
    List<IdmNotificationTemplateDto> unmodifiable = notificationService.find(templateFilter, null).getContent();
    List<IdmNotificationTemplateDto> templatesToWarn = unmodifiable.stream().filter(dto -> {
        return entities.contains(dto.getId());
    }).collect(Collectors.toList());
    for (IdmNotificationTemplateDto item : templatesToWarn) {
        results.addInfo(new DefaultResultModel(CoreResultCode.NOTIFICATION_SYSTEM_TEMPLATE_DELETE_FAILED, ImmutableMap.of("template", item.getCode())));
    }
    return results;
}
Also used : Description(org.springframework.context.annotation.Description) AbstractRemoveBulkAction(eu.bcvsolutions.idm.core.api.bulk.action.AbstractRemoveBulkAction) ResultModels(eu.bcvsolutions.idm.core.api.dto.ResultModels) NotificationGroupPermission(eu.bcvsolutions.idm.core.notification.domain.NotificationGroupPermission) ImmutableMap(com.google.common.collect.ImmutableMap) ReadWriteDtoService(eu.bcvsolutions.idm.core.api.service.ReadWriteDtoService) Autowired(org.springframework.beans.factory.annotation.Autowired) UUID(java.util.UUID) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) Collectors(java.util.stream.Collectors) IdmNotificationTemplateFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationTemplateFilter) List(java.util.List) Component(org.springframework.stereotype.Component) Lists(com.google.common.collect.Lists) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) IdmNotificationTemplateService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationTemplateService) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmNotificationTemplateFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationTemplateFilter) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) UUID(java.util.UUID) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) ResultModels(eu.bcvsolutions.idm.core.api.dto.ResultModels)

Example 49 with IdmNotificationTemplateDto

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

the class DefaultRptReportManagerIntegrationTest method createTestTemplate.

private IdmNotificationTemplateDto createTestTemplate() {
    // create templates
    IdmNotificationTemplateDto template = new IdmNotificationTemplateDto();
    template.setName(getHelper().createName());
    template.setBodyHtml(getHelper().createName());
    template.setBodyText(template.getBodyHtml());
    template.setCode(template.getName());
    template.setSubject(getHelper().createName());
    return notificationTemplateService.save(template);
}
Also used : IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)

Example 50 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)

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