use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class ConfigurationModelConfigurationAccessorTestIT method getConfigurationByIdTest.
@Test
public void getConfigurationByIdTest() {
ConfigurationFieldModel configField1 = ConfigurationFieldModel.create(FIELD_KEY_INSENSITIVE);
ConfigurationFieldModel configField2 = ConfigurationFieldModel.createSensitive(FIELD_KEY_SENSITIVE);
DescriptorKey descriptorKey = createDescriptorKey(DESCRIPTOR_NAME);
ConfigurationModel configurationModel1 = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, Arrays.asList(configField1));
ConfigurationModel configurationModel2 = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, Arrays.asList(configField2));
Optional<ConfigurationModel> optionalFoundConfig1 = configurationModelConfigurationAccessor.getConfigurationById(configurationModel1.getConfigurationId());
assertTrue(optionalFoundConfig1.isPresent());
ConfigurationModel foundConfig1 = optionalFoundConfig1.get();
assertEquals(configurationModel1.getDescriptorId(), foundConfig1.getDescriptorId());
assertEquals(configurationModel1.getConfigurationId(), foundConfig1.getConfigurationId());
Optional<ConfigurationModel> optionalFoundConfig2 = configurationModelConfigurationAccessor.getConfigurationById(configurationModel2.getConfigurationId());
assertTrue(optionalFoundConfig2.isPresent());
ConfigurationModel foundConfig2 = optionalFoundConfig2.get();
assertEquals(configurationModel2.getDescriptorId(), foundConfig2.getDescriptorId());
assertEquals(configurationModel2.getConfigurationId(), foundConfig2.getConfigurationId());
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel 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.ConfigurationFieldModel 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.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class MockConfigurationModelFactory method createEmailDistributionFieldsProjectOwnerOnly.
public static List<ConfigurationFieldModel> createEmailDistributionFieldsProjectOwnerOnly() {
List<ConfigurationFieldModel> fields = new ArrayList<>();
ConfigurationFieldModel emailAddresses = createFieldModel(EmailDescriptor.KEY_EMAIL_ADDRESSES, List.of("noreply@blackducksoftware.com"));
ConfigurationFieldModel projectOwnerOnly = createFieldModel(EmailDescriptor.KEY_PROJECT_OWNER_ONLY, "true");
ConfigurationFieldModel subjectLine = createFieldModel(EmailDescriptor.KEY_SUBJECT_LINE, "Alert unit test subject line");
fields.add(emailAddresses);
fields.add(projectOwnerOnly);
fields.add(subjectLine);
Collection<ConfigurationFieldModel> commonFields = createCommonDistributionFields("Email Test Job", ChannelKeys.EMAIL.getUniversalKey());
fields.addAll(commonFields);
return fields;
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class MockConfigurationModelFactory method mapStringsToFields.
public static Map<String, ConfigurationFieldModel> mapStringsToFields(Map<String, String> fields) {
Map<String, ConfigurationFieldModel> configurationFieldMap = new HashMap<>(fields.size());
for (Map.Entry<String, String> entry : fields.entrySet()) {
ConfigurationFieldModel configurationFieldModel = ConfigurationFieldModel.create(entry.getKey());
configurationFieldModel.setFieldValue(entry.getValue());
configurationFieldMap.put(entry.getKey(), configurationFieldModel);
}
return configurationFieldMap;
}
Aggregations