use of com.synopsys.integration.alert.descriptor.api.model.DescriptorKey in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationModelSaveActionsTest method createAuthorizationManager.
private AuthorizationManager createAuthorizationManager() {
AuthenticationTestUtils authenticationTestUtils = new AuthenticationTestUtils();
DescriptorKey descriptorKey = ChannelKeys.JIRA_SERVER;
PermissionKey permissionKey = new PermissionKey(ConfigContextEnum.GLOBAL.name(), descriptorKey.getUniversalKey());
Map<PermissionKey, Integer> permissions = Map.of(permissionKey, AuthenticationTestUtils.FULL_PERMISSIONS);
return authenticationTestUtils.createAuthorizationManagerWithCurrentUserSet("admin", "admin", () -> new PermissionMatrixModel(permissions));
}
use of com.synopsys.integration.alert.descriptor.api.model.DescriptorKey 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.descriptor.api.model.DescriptorKey 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.descriptor.api.model.DescriptorKey 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());
}
use of com.synopsys.integration.alert.descriptor.api.model.DescriptorKey in project hub-alert by blackducksoftware.
the class ConfigurationModelConfigurationAccessorTestIT method updateConfigurationMultipleValueTest.
@Test
public void updateConfigurationMultipleValueTest() 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(originalField, newFieldWithSameKey));
List<ConfigurationFieldModel> configuredFields = updatedModel.getCopyOfFieldList();
assertEquals(1, configuredFields.size());
ConfigurationFieldModel configuredField = configuredFields.get(0);
assertEquals(originalField, configuredField);
assertTrue(configuredField.getFieldValues().contains(initialValue));
assertTrue(configuredField.getFieldValues().contains(additionalValue));
List<FieldValueEntity> databaseFieldValues = fieldValueRepository.findByConfigId(updatedModel.getConfigurationId());
assertNotNull(databaseFieldValues);
assertEquals(2, databaseFieldValues.size());
assertEquals(configuredField.getFieldValues().size(), databaseFieldValues.size());
}
Aggregations