use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class JiraJobDetailsExtractorTest method extractFieldMappingsTest.
@Test
public void extractFieldMappingsTest() {
String testFieldName = "field.name";
String testFieldValue = "some random value";
JiraJobCustomFieldModel testCustomField = new JiraJobCustomFieldModel(testFieldName, testFieldValue);
ConfigurationFieldModel testFieldModel = ConfigurationFieldModel.create(testFieldName);
String testCustomFieldJson = GSON.toJson(testCustomField);
testFieldModel.setFieldValue(testCustomFieldJson);
JiraJobDetailsExtractor jobDetailsExtractor = createJobDetailsExtractor();
List<JiraJobCustomFieldModel> fieldMappings = jobDetailsExtractor.extractJiraFieldMappings(testFieldName, Map.of(testFieldName, testFieldModel));
assertEquals(1, fieldMappings.size());
JiraJobCustomFieldModel extractedFieldMapping = fieldMappings.get(0);
assertEquals(testCustomField, extractedFieldMapping);
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class NotificationAccessorTestIT method init.
@BeforeEach
public void init() {
cleanDB();
ConfigurationFieldModel providerConfigEnabled = ConfigurationFieldModel.create(ProviderDescriptor.KEY_PROVIDER_CONFIG_ENABLED);
providerConfigEnabled.setFieldValue("true");
ConfigurationFieldModel providerConfigName = ConfigurationFieldModel.create(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME);
providerConfigName.setFieldValue("My Black Duck Config");
ConfigurationFieldModel blackduckUrl = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_URL);
blackduckUrl.setFieldValue("https://a-blackduck-server");
ConfigurationFieldModel blackduckApiKey = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY);
blackduckApiKey.setFieldValue("123456789012345678901234567890123456789012345678901234567890");
ConfigurationFieldModel blackduckTimeout = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_TIMEOUT);
blackduckTimeout.setFieldValue("300");
List<ConfigurationFieldModel> providerConfigFields = List.of(providerConfigEnabled, providerConfigName, blackduckUrl, blackduckApiKey, blackduckTimeout);
providerConfigModel = configurationModelConfigurationAccessor.createConfiguration(new BlackDuckProviderKey(), ConfigContextEnum.GLOBAL, providerConfigFields);
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class BlackDuckSSOConfigRetrieverTest method createConfigFieldModel.
private ConfigurationFieldModel createConfigFieldModel(String key, String value) {
ConfigurationFieldModel configurationFieldModel = ConfigurationFieldModel.create(key);
configurationFieldModel.setFieldValue(value);
return configurationFieldModel;
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class BlackDuckNotificationRetrieverFactoryTest method addConfigurationField.
private void addConfigurationField(Map<String, ConfigurationFieldModel> configuredFields, String key, String value) {
ConfigurationFieldModel configurationFieldModel = ConfigurationFieldModel.create(key);
configurationFieldModel.setFieldValue(value);
configuredFields.put(key, configurationFieldModel);
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class ConfigurationFieldModelTest method convertDefinedFieldModelTest.
@Test
public void convertDefinedFieldModelTest() throws Exception {
List<DefinedFieldModel> configFields = createConfigFields();
EncryptionUtility encryptionUtility = Mockito.mock(EncryptionUtility.class);
Mockito.when(encryptionUtility.isInitialized()).thenReturn(true);
DescriptorAccessor descriptorAccessor = new MockDescriptorAccessor(configFields);
List<DescriptorKey> descriptorKeys = createDescriptorKeyList();
ConfigurationFieldModelConverter modelConverter = new ConfigurationFieldModelConverter(encryptionUtility, descriptorAccessor, descriptorKeys);
Optional<ConfigurationFieldModel> optionalModel = modelConverter.convertFromDefinedFieldModel(new DefinedFieldModel(KEY_FIELD_1, ConfigContextEnum.GLOBAL, false), VALUE_FIELD_1, true);
assertTrue(optionalModel.isPresent());
ConfigurationFieldModel actualModel = optionalModel.get();
assertEquals(VALUE_FIELD_1, actualModel.getFieldValue().orElseThrow(IllegalArgumentException::new));
assertFalse(actualModel.isSensitive());
assertEquals(KEY_FIELD_1, actualModel.getFieldKey());
optionalModel = modelConverter.convertFromDefinedFieldModel(new DefinedFieldModel(KEY_FIELD_1, ConfigContextEnum.GLOBAL, true), VALUE_FIELD_1, true);
assertTrue(optionalModel.isPresent());
actualModel = optionalModel.get();
assertEquals(VALUE_FIELD_1, actualModel.getFieldValue().orElseThrow(IllegalArgumentException::new));
assertTrue(actualModel.isSensitive());
assertEquals(KEY_FIELD_1, actualModel.getFieldKey());
}
Aggregations