use of com.synopsys.integration.alert.database.notification.NotificationContentRepository in project hub-alert by blackducksoftware.
the class DefaultNotificationAccessorTest method getPageRequestForNotificationsTest.
@Test
void getPageRequestForNotificationsTest() {
final int pageNumber = 1;
final int pageSize = 1;
final String sortField = "content";
String sortOrder = Sort.Direction.ASC.name();
NotificationContentRepository notificationContentRepository = Mockito.mock(NotificationContentRepository.class);
AuditEntryRepository auditEntryRepository = Mockito.mock(AuditEntryRepository.class);
AuditNotificationRepository auditNotificationRepository = Mockito.mock(AuditNotificationRepository.class);
ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
DefaultNotificationAccessor notificationManager = new DefaultNotificationAccessor(notificationContentRepository, auditEntryRepository, configurationModelConfigurationAccessor);
PageRequest pageRequest = notificationManager.getPageRequestForNotifications(pageNumber, pageSize, sortField, sortOrder);
assertEquals(pageNumber, pageRequest.getPageNumber());
assertEquals(pageSize, pageRequest.getPageSize());
}
use of com.synopsys.integration.alert.database.notification.NotificationContentRepository in project hub-alert by blackducksoftware.
the class DefaultNotificationAccessorTest method hasMoreNotificationsToProcessTrueTest.
@Test
void hasMoreNotificationsToProcessTrueTest() {
NotificationContentRepository notificationContentRepository = Mockito.mock(NotificationContentRepository.class);
Mockito.when(notificationContentRepository.existsByProcessedFalse()).thenReturn(Boolean.TRUE);
DefaultNotificationAccessor notificationManager = new DefaultNotificationAccessor(notificationContentRepository, null, null);
assertTrue(notificationManager.hasMoreNotificationsToProcess());
}
use of com.synopsys.integration.alert.database.notification.NotificationContentRepository in project hub-alert by blackducksoftware.
the class DefaultNotificationAccessorTest method findByIdTest.
@Test
void findByIdTest() {
NotificationEntity notificationEntity = new NotificationEntity(id, DateUtils.createCurrentDateTimestamp(), provider, providerConfigId, DateUtils.createCurrentDateTimestamp(), notificationType, content, false);
ConfigurationModel configurationModel = createConfigurationModel();
NotificationContentRepository notificationContentRepository = Mockito.mock(NotificationContentRepository.class);
ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
Mockito.when(notificationContentRepository.findById(Mockito.any())).thenReturn(Optional.of(notificationEntity));
Mockito.when(configurationModelConfigurationAccessor.getConfigurationById(Mockito.any())).thenReturn(Optional.of(configurationModel));
DefaultNotificationAccessor notificationManager = new DefaultNotificationAccessor(notificationContentRepository, null, configurationModelConfigurationAccessor);
Optional<AlertNotificationModel> alertNotificationModel = notificationManager.findById(1L);
assertTrue(alertNotificationModel.isPresent());
testExpectedAlertNotificationModel(expectedAlertNotificationModel, alertNotificationModel.get());
}
use of com.synopsys.integration.alert.database.notification.NotificationContentRepository in project hub-alert by blackducksoftware.
the class DefaultNotificationAccessorTest method setNotificationsProcessedTest.
@Test
void setNotificationsProcessedTest() {
AlertNotificationModel alertNotificationModel = new AlertNotificationModel(null, providerConfigId, provider, providerConfigName, notificationType, content, DateUtils.createCurrentDateTimestamp(), DateUtils.createCurrentDateTimestamp(), false);
NotificationContentRepository notificationContentRepository = Mockito.mock(NotificationContentRepository.class);
ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
DefaultNotificationAccessor notificationManager = new DefaultNotificationAccessor(notificationContentRepository, null, configurationModelConfigurationAccessor);
notificationManager.setNotificationsProcessed(List.of(alertNotificationModel));
Mockito.verify(notificationContentRepository).setProcessedByIds(Mockito.any());
}
use of com.synopsys.integration.alert.database.notification.NotificationContentRepository in project hub-alert by blackducksoftware.
the class DefaultNotificationAccessorTest method findByIdsTest.
@Test
void findByIdsTest() {
NotificationEntity notificationEntity = new NotificationEntity(id, DateUtils.createCurrentDateTimestamp(), provider, providerConfigId, DateUtils.createCurrentDateTimestamp(), notificationType, content, false);
ConfigurationModel configurationModel = createConfigurationModel();
NotificationContentRepository notificationContentRepository = Mockito.mock(NotificationContentRepository.class);
ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
Mockito.when(notificationContentRepository.findAllById(Mockito.any())).thenReturn(List.of(notificationEntity));
Mockito.when(configurationModelConfigurationAccessor.getConfigurationById(Mockito.any())).thenReturn(Optional.of(configurationModel));
DefaultNotificationAccessor notificationManager = new DefaultNotificationAccessor(notificationContentRepository, null, configurationModelConfigurationAccessor);
List<AlertNotificationModel> alertNotificationModelList = notificationManager.findByIds(List.of(1L));
assertEquals(1, alertNotificationModelList.size());
AlertNotificationModel alertNotificationModel = alertNotificationModelList.get(0);
testExpectedAlertNotificationModel(expectedAlertNotificationModel, alertNotificationModel);
}
Aggregations