use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationModelConverterTest method validConversionMissingOptionalFieldsTest.
@Test
void validConversionMissingOptionalFieldsTest() {
ConfigurationModel configurationModel = createDefaultConfigurationModel();
Map<String, ConfigurationFieldModel> fields = configurationModel.getCopyOfKeyToFieldMap();
fields.remove(JiraServerGlobalConfigurationModelConverter.PASSWORD_KEY);
fields.remove(JiraServerGlobalConfigurationModelConverter.DISABLE_PLUGIN_CHECK_KEY);
configurationModel = new ConfigurationModel(1L, 1L, "", "", ConfigContextEnum.GLOBAL, fields);
JiraServerGlobalConfigurationModelConverter converter = new JiraServerGlobalConfigurationModelConverter();
Optional<JiraServerGlobalConfigModel> model = converter.convert(configurationModel);
assertTrue(model.isPresent());
JiraServerGlobalConfigModel jiraModel = model.get();
assertNull(jiraModel.getId());
assertEquals(TEST_URL, jiraModel.getUrl());
assertEquals(TEST_USERNAME, jiraModel.getUserName());
assertTrue(jiraModel.getPassword().isEmpty());
assertTrue(jiraModel.getDisablePluginCheck().isEmpty());
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationModelConverterTest method createDefaultConfigurationModel.
private ConfigurationModel createDefaultConfigurationModel() {
Map<String, ConfigurationFieldModel> fieldValuesMap = new HashMap<>();
ConfigurationFieldModel urlField = ConfigurationFieldModel.create(JiraServerGlobalConfigurationModelConverter.URL_KEY);
ConfigurationFieldModel userField = ConfigurationFieldModel.create(JiraServerGlobalConfigurationModelConverter.USERNAME_KEY);
ConfigurationFieldModel passwordField = ConfigurationFieldModel.create(JiraServerGlobalConfigurationModelConverter.PASSWORD_KEY);
ConfigurationFieldModel disableCheckField = ConfigurationFieldModel.create(JiraServerGlobalConfigurationModelConverter.DISABLE_PLUGIN_CHECK_KEY);
urlField.setFieldValue(TEST_URL);
passwordField.setFieldValue(TEST_PASSWORD);
userField.setFieldValue(TEST_USERNAME);
disableCheckField.setFieldValue(TEST_DISABLE_PLUGIN_CHECK);
fieldValuesMap.put(JiraServerGlobalConfigurationModelConverter.URL_KEY, urlField);
fieldValuesMap.put(JiraServerGlobalConfigurationModelConverter.PASSWORD_KEY, passwordField);
fieldValuesMap.put(JiraServerGlobalConfigurationModelConverter.USERNAME_KEY, userField);
fieldValuesMap.put(JiraServerGlobalConfigurationModelConverter.DISABLE_PLUGIN_CHECK_KEY, disableCheckField);
return new ConfigurationModel(1L, 1L, "", "", ConfigContextEnum.GLOBAL, fieldValuesMap);
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class ConfigurationModelConfigurationAccessorTestIT method deleteConfigurationTest.
@Test
public void deleteConfigurationTest() {
DescriptorKey descriptorKey = createDescriptorKey(DESCRIPTOR_NAME);
ConfigurationModel createdModel1 = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, List.of());
ConfigurationModel createdModel2 = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, List.of());
List<ConfigurationModel> foundModels = configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(descriptorKey);
assertEquals(2, foundModels.size());
configurationModelConfigurationAccessor.deleteConfiguration(createdModel1);
List<ConfigurationModel> afterFirstDeletion = configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(descriptorKey);
assertEquals(foundModels.size() - 1, afterFirstDeletion.size());
configurationModelConfigurationAccessor.deleteConfiguration(createdModel2);
List<ConfigurationModel> afterSecondDeletion = configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(descriptorKey);
assertEquals(foundModels.size() - 2, afterSecondDeletion.size());
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class ConfigurationModelConfigurationAccessorTestIT method updateConfigurationReplaceValueTest.
@Test
public void updateConfigurationReplaceValueTest() throws AlertConfigurationException {
final String initialValue = "initial value";
ConfigurationFieldModel originalField = ConfigurationFieldModel.create(FIELD_KEY_INSENSITIVE);
originalField.setFieldValue(initialValue);
DescriptorKey descriptorKey = createDescriptorKey(DESCRIPTOR_NAME);
ConfigurationModel createdModel = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, Arrays.asList(originalField));
List<ConfigurationFieldModel> copyOfFieldList = createdModel.getCopyOfFieldList();
assertEquals(1, copyOfFieldList.size());
Optional<String> optionalValue = copyOfFieldList.get(0).getFieldValue();
assertTrue(optionalValue.isPresent());
assertEquals(initialValue, optionalValue.get());
final String additionalValue = "additional value";
ConfigurationFieldModel newFieldWithSameKey = ConfigurationFieldModel.create(FIELD_KEY_INSENSITIVE);
newFieldWithSameKey.setFieldValue(additionalValue);
ConfigurationModel updatedModel = configurationModelConfigurationAccessor.updateConfiguration(createdModel.getConfigurationId(), Arrays.asList(newFieldWithSameKey));
List<ConfigurationFieldModel> configuredFields = updatedModel.getCopyOfFieldList();
assertEquals(1, configuredFields.size());
ConfigurationFieldModel configuredField = configuredFields.get(0);
assertEquals(originalField, configuredField);
assertTrue(configuredField.getFieldValues().contains(additionalValue));
List<FieldValueEntity> databaseFieldValues = fieldValueRepository.findByConfigId(updatedModel.getConfigurationId());
assertNotNull(databaseFieldValues);
assertEquals(1, databaseFieldValues.size());
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class ConfigurationModelConfigurationAccessorTestIT method createConfigTest.
@Test
public void createConfigTest() {
ConfigurationFieldModel configField1 = ConfigurationFieldModel.create(FIELD_KEY_INSENSITIVE);
ConfigurationFieldModel configField2 = ConfigurationFieldModel.createSensitive(FIELD_KEY_SENSITIVE);
DescriptorKey descriptorKey = createDescriptorKey(DESCRIPTOR_NAME);
ConfigurationModel createdConfig = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, List.of(configField1, configField2));
assertTrue(createdConfig.getCopyOfFieldList().contains(configField1));
assertTrue(createdConfig.getCopyOfFieldList().contains(configField2));
Optional<DescriptorConfigEntity> configEntityOptional = descriptorConfigsRepository.findById(createdConfig.getConfigurationId());
assertTrue(configEntityOptional.isPresent());
}
Aggregations