Search in sources :

Example 91 with ConfigurationFieldModel

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);
}
Also used : ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) JiraJobCustomFieldModel(com.synopsys.integration.alert.common.persistence.model.job.details.JiraJobCustomFieldModel) Test(org.junit.jupiter.api.Test)

Example 92 with ConfigurationFieldModel

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);
}
Also used : BlackDuckProviderKey(com.synopsys.integration.alert.descriptor.api.BlackDuckProviderKey) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 93 with ConfigurationFieldModel

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;
}
Also used : ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)

Example 94 with 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);
}
Also used : ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)

Example 95 with 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());
}
Also used : ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) DefinedFieldModel(com.synopsys.integration.alert.common.persistence.model.DefinedFieldModel) MockDescriptorAccessor(com.synopsys.integration.alert.mock.MockDescriptorAccessor) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) MockDescriptorAccessor(com.synopsys.integration.alert.mock.MockDescriptorAccessor) DescriptorAccessor(com.synopsys.integration.alert.common.persistence.accessor.DescriptorAccessor) ConfigurationFieldModelConverter(com.synopsys.integration.alert.common.persistence.util.ConfigurationFieldModelConverter) EncryptionUtility(com.synopsys.integration.alert.common.security.EncryptionUtility) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)105 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)47 Test (org.junit.jupiter.api.Test)32 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)27 FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)23 HashMap (java.util.HashMap)20 ConfigurationFieldModelConverter (com.synopsys.integration.alert.common.persistence.util.ConfigurationFieldModelConverter)14 ArrayList (java.util.ArrayList)13 ConfigurationModelConfigurationAccessor (com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)12 FieldValueModel (com.synopsys.integration.alert.common.rest.model.FieldValueModel)12 DescriptorAccessor (com.synopsys.integration.alert.common.persistence.accessor.DescriptorAccessor)11 DefinedFieldModel (com.synopsys.integration.alert.common.persistence.model.DefinedFieldModel)11 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)10 BlackDuckProviderKey (com.synopsys.integration.alert.descriptor.api.BlackDuckProviderKey)10 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)9 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)9 ConfigurationModelMutable (com.synopsys.integration.alert.common.persistence.model.mutable.ConfigurationModelMutable)8 EncryptionUtility (com.synopsys.integration.alert.common.security.EncryptionUtility)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 FieldUtility (com.synopsys.integration.alert.common.persistence.accessor.FieldUtility)7