Search in sources :

Example 1 with IdmNotificationFilter

use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter 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 2 with IdmNotificationFilter

use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter 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 3 with IdmNotificationFilter

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

the class IdmNotificationConfigurationDisabledTest method testNotDisabledError.

@Test
@Transactional
public void testNotDisabledError() {
    assertEquals(0, idmNotificationRepository.count());
    NotificationLevel level = NotificationLevel.ERROR;
    IdmNotificationTemplateDto template = createTestTemplate("Idm test notification", "disabled test");
    IdmIdentityDto identity = getHelper().createIdentity("Test_disable_notifications" + System.currentTimeMillis());
    configs.add(createNotificationConfiguration(TOPIC, level, IdmConsoleLog.NOTIFICATION_TYPE, template.getId(), false));
    configs.add(createNotificationConfiguration(TOPIC, level, IdmEmailLog.NOTIFICATION_TYPE, template.getId(), false));
    IdmMessageDto message = new IdmMessageDto();
    message.setTemplate(template);
    message.setLevel(level);
    notificationManager.send(TOPIC, message, identity);
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setNotificationType(IdmNotificationLog.class);
    assertEquals(2, notificationLogService.find(filter, null).getTotalElements());
    deleteNotificationConfig();
}
Also used : IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) NotificationLevel(eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel) 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 4 with IdmNotificationFilter

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

the class IdmNotificationConfigurationDisabledTest method testDisabledErrorWebsocket.

@Test
@Transactional
public void testDisabledErrorWebsocket() {
    assertEquals(0, idmNotificationRepository.count());
    NotificationLevel level = NotificationLevel.ERROR;
    IdmNotificationTemplateDto template = createTestTemplate("Idm test notification", "disabled test");
    IdmIdentityDto identity = getHelper().createIdentity("Test_disable_notifications" + System.currentTimeMillis());
    configs.add(createNotificationConfiguration(TOPIC, level, IdmConsoleLog.NOTIFICATION_TYPE, template.getId(), true));
    IdmMessageDto message = new IdmMessageDto();
    message.setTemplate(template);
    message.setLevel(level);
    notificationManager.send(TOPIC, message, identity);
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setNotificationType(IdmNotificationLog.class);
    assertEquals(0, notificationLogService.find(filter, null).getTotalElements());
    deleteNotificationConfig();
}
Also used : IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) NotificationLevel(eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel) 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 5 with IdmNotificationFilter

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

the class IdmNotificationConfigurationDisabledTest method testNotDisabledErrorEmail.

@Test
@Transactional
public void testNotDisabledErrorEmail() {
    assertEquals(0, idmNotificationRepository.count());
    NotificationLevel level = NotificationLevel.ERROR;
    IdmNotificationTemplateDto template = createTestTemplate("Idm test notification", "disabled test");
    IdmIdentityDto identity = getHelper().createIdentity("Test_disable_notifications" + System.currentTimeMillis());
    configs.add(createNotificationConfiguration(TOPIC, level, IdmEmailLog.NOTIFICATION_TYPE, template.getId(), false));
    IdmMessageDto message = new IdmMessageDto();
    message.setTemplate(template);
    message.setLevel(level);
    notificationManager.send(TOPIC, message, identity);
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setNotificationType(IdmNotificationLog.class);
    assertEquals(1, notificationLogService.find(filter, null).getTotalElements());
    deleteNotificationConfig();
}
Also used : IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) NotificationLevel(eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel) 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)

Aggregations

IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)100 Test (org.junit.Test)97 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)89 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)80 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)65 List (java.util.List)37 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)34 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)33 IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)31 ZonedDateTime (java.time.ZonedDateTime)31 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)29 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)26 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)26 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)26 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)26 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)25 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)23 UUID (java.util.UUID)17 Transactional (org.springframework.transaction.annotation.Transactional)16 NotificationLevel (eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel)14