use of com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor in project hub-alert by blackducksoftware.
the class DefaultNotificationAccessorTest method finalAllShowNotificationsFalseTest.
@Test
void finalAllShowNotificationsFalseTest() {
PageRequest pageRequest = PageRequest.of(0, 10);
NotificationEntity notificationEntity = new NotificationEntity(id, DateUtils.createCurrentDateTimestamp(), provider, providerConfigId, DateUtils.createCurrentDateTimestamp(), notificationType, content, false);
Page<NotificationEntity> allSentNotifications = new PageImpl<>(List.of(notificationEntity));
ConfigurationModel configurationModel = createConfigurationModel();
NotificationContentRepository notificationContentRepository = Mockito.mock(NotificationContentRepository.class);
ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
Mockito.when(configurationModelConfigurationAccessor.getConfigurationById(Mockito.any())).thenReturn(Optional.of(configurationModel));
Mockito.when(notificationContentRepository.findAll(pageRequest)).thenReturn(allSentNotifications);
DefaultNotificationAccessor notificationManager = new DefaultNotificationAccessor(notificationContentRepository, null, configurationModelConfigurationAccessor);
Page<AlertNotificationModel> alertNotificationModelPage = notificationManager.findAll(pageRequest, Boolean.FALSE);
assertEquals(1, alertNotificationModelPage.getTotalPages());
AlertNotificationModel testAlertNotificationModel = alertNotificationModelPage.getContent().get(0);
testExpectedAlertNotificationModel(expectedAlertNotificationModel, testAlertNotificationModel);
}
use of com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor in project hub-alert by blackducksoftware.
the class DefaultNotificationAccessorTest method findByCreatedAtBeforeTest.
@Test
void findByCreatedAtBeforeTest() {
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.findByCreatedAtBefore(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.findByCreatedAtBefore(DateUtils.createCurrentDateTimestamp());
assertEquals(1, alertNotificationModelList.size());
AlertNotificationModel alertNotificationModel = alertNotificationModelList.get(0);
testExpectedAlertNotificationModel(expectedAlertNotificationModel, alertNotificationModel);
}
use of com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor in project hub-alert by blackducksoftware.
the class DefaultNotificationAccessorTest method finalAllTest.
@Test
void finalAllTest() {
PageRequest pageRequest = PageRequest.of(0, 10);
NotificationEntity notificationEntity = new NotificationEntity(id, DateUtils.createCurrentDateTimestamp(), provider, providerConfigId, DateUtils.createCurrentDateTimestamp(), notificationType, content, false);
Page<NotificationEntity> allSentNotifications = new PageImpl<>(List.of(notificationEntity));
ConfigurationModel configurationModel = createConfigurationModel();
NotificationContentRepository notificationContentRepository = Mockito.mock(NotificationContentRepository.class);
ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
Mockito.when(notificationContentRepository.findAllSentNotifications(Mockito.any())).thenReturn(allSentNotifications);
Mockito.when(configurationModelConfigurationAccessor.getConfigurationById(Mockito.any())).thenReturn(Optional.of(configurationModel));
DefaultNotificationAccessor notificationManager = new DefaultNotificationAccessor(notificationContentRepository, null, configurationModelConfigurationAccessor);
Page<AlertNotificationModel> alertNotificationModelPage = notificationManager.findAll(pageRequest, Boolean.TRUE);
assertEquals(1, alertNotificationModelPage.getTotalPages());
AlertNotificationModel testAlertNotificationModel = alertNotificationModelPage.getContent().get(0);
testExpectedAlertNotificationModel(expectedAlertNotificationModel, testAlertNotificationModel);
}
use of com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor in project hub-alert by blackducksoftware.
the class DefaultNotificationAccessorTest method findByCreatedAtBeforeDayOffsetTest.
@Test
void findByCreatedAtBeforeDayOffsetTest() {
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.findByCreatedAtBefore(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.findByCreatedAtBeforeDayOffset(1);
assertEquals(1, alertNotificationModelList.size());
AlertNotificationModel alertNotificationModel = alertNotificationModelList.get(0);
testExpectedAlertNotificationModel(expectedAlertNotificationModel, alertNotificationModel);
}
use of com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor in project hub-alert by blackducksoftware.
the class ProviderConfigMissingValidatorTest method testValidConfigurations.
@Test
public void testValidConfigurations() {
SystemMessageAccessor systemMessageAccessor = Mockito.mock(SystemMessageAccessor.class);
ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
List<Provider> providers = List.of(Mockito.mock(Provider.class));
ConfigurationModel model = Mockito.mock(ConfigurationModel.class);
Mockito.when(model.getCopyOfFieldList()).thenReturn(List.of(Mockito.mock(ConfigurationFieldModel.class)));
Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKeyAndContext(Mockito.any(), Mockito.any())).thenReturn(List.of(model));
ProviderConfigMissingValidator validator = new ProviderConfigMissingValidator(systemMessageAccessor, providers, configurationModelConfigurationAccessor);
validator.validate();
Mockito.verify(systemMessageAccessor, Mockito.never()).addSystemMessage(Mockito.anyString(), Mockito.any(SystemMessageSeverity.class), Mockito.anyString());
}
Aggregations