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