use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class ConfigurationModelConfigurationAccessorTestIT method getConfigsByNameTest.
@Test
public void getConfigsByNameTest() {
ConfigurationFieldModel configField1 = ConfigurationFieldModel.create(FIELD_KEY_INSENSITIVE);
ConfigurationFieldModel configField2 = ConfigurationFieldModel.createSensitive(FIELD_KEY_SENSITIVE);
DescriptorKey descriptorKey = createDescriptorKey(DESCRIPTOR_NAME);
configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, Arrays.asList(configField1));
configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, Arrays.asList(configField2));
List<ConfigurationModel> configurationsForDescriptor = configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(descriptorKey);
assertEquals(2, configurationsForDescriptor.size());
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class ConfigurationModelConfigurationAccessorTestIT method getConfigurationsByDescriptorTypeTest.
@Test
public void getConfigurationsByDescriptorTypeTest() {
List<ConfigurationModel> configurationModels = configurationModelConfigurationAccessor.getConfigurationsByDescriptorType(DescriptorType.CHANNEL);
assertTrue(configurationModels.isEmpty());
ConfigurationFieldModel configField1 = ConfigurationFieldModel.create(FIELD_KEY_INSENSITIVE);
ConfigurationFieldModel configField2 = ConfigurationFieldModel.createSensitive(FIELD_KEY_SENSITIVE);
DescriptorKey descriptorKey = createDescriptorKey(DESCRIPTOR_NAME);
configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, Arrays.asList(configField1));
configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, Arrays.asList(configField2));
configurationModels = configurationModelConfigurationAccessor.getConfigurationsByDescriptorType(DescriptorType.PROVIDER);
assertFalse(configurationModels.isEmpty());
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class DefaultConfigurationModelConfigurationAccessorTest method createConfigurationTest.
@Test
public void createConfigurationTest() {
final Long descriptorId = 3L;
final Long configurationId = 5L;
DescriptorKey descriptorKey = createDescriptorKey("descriptorKeyName");
ConfigurationFieldModel configurationFieldModel = ConfigurationFieldModel.create("channel.common.name");
configurationFieldModel.setFieldValue(fieldValue);
List<ConfigurationFieldModel> configuredFields = List.of(configurationFieldModel);
RegisteredDescriptorEntity registeredDescriptorEntity = new RegisteredDescriptorEntity("name", 1L);
registeredDescriptorEntity.setId(descriptorId);
ConfigContextEntity configContextEntity = new ConfigContextEntity(configContextEnum.name());
configContextEntity.setId(3L);
DefinedFieldEntity definedFieldEntity = new DefinedFieldEntity(fieldKey, false);
definedFieldEntity.setId(4L);
DescriptorConfigEntity descriptorConfigEntity = new DescriptorConfigEntity(5L, 6L, DateUtils.createCurrentDateTimestamp(), DateUtils.createCurrentDateTimestamp());
descriptorConfigEntity.setId(configurationId);
Mockito.when(registeredDescriptorRepository.findFirstByName(Mockito.any())).thenReturn(Optional.of(registeredDescriptorEntity));
Mockito.when(configContextRepository.findFirstByContext(Mockito.any())).thenReturn(Optional.of(configContextEntity));
Mockito.when(definedFieldRepository.findByDescriptorIdAndContext(Mockito.any(), Mockito.any())).thenReturn(List.of(definedFieldEntity));
Mockito.when(descriptorConfigRepository.save(Mockito.any())).thenReturn(descriptorConfigEntity);
Mockito.when(definedFieldRepository.findFirstByKey(Mockito.any())).thenReturn(Optional.of(definedFieldEntity));
DefaultConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = new DefaultConfigurationModelConfigurationAccessor(registeredDescriptorRepository, definedFieldRepository, descriptorConfigRepository, configContextRepository, fieldValueRepository, null);
ConfigurationModel configurationModel = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, configContextEnum, configuredFields);
testConfigurationModel(configurationId, descriptorId, configurationModel);
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel 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.common.persistence.model.ConfigurationModel 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