Search in sources :

Example 11 with ConfigurationFieldModel

use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.

the class MockConfigurationModelFactory method createBlackDuckDistributionFields.

public static List<ConfigurationFieldModel> createBlackDuckDistributionFields() {
    List<ConfigurationFieldModel> fields = new ArrayList<>();
    ConfigurationFieldModel notificationTypes = createFieldModel(ProviderDescriptor.KEY_NOTIFICATION_TYPES, List.of(NotificationType.VULNERABILITY.toString(), NotificationType.RULE_VIOLATION.toString()));
    ConfigurationFieldModel formatType = createFieldModel(ProviderDescriptor.KEY_PROCESSING_TYPE, ProcessingType.DEFAULT.toString());
    ConfigurationFieldModel filterByProject = createFieldModel(ProviderDescriptor.KEY_FILTER_BY_PROJECT, "true");
    ConfigurationFieldModel projectNamePattern = createFieldModel(ProviderDescriptor.KEY_PROJECT_NAME_PATTERN, ".*UnitTest.*");
    ConfigurationFieldModel configuredProject = createFieldModel(ProviderDescriptor.KEY_CONFIGURED_PROJECT, List.of("TestProject1", "TestProject2"));
    fields.add(notificationTypes);
    fields.add(formatType);
    fields.add(filterByProject);
    fields.add(projectNamePattern);
    fields.add(configuredProject);
    return fields;
}
Also used : ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) ArrayList(java.util.ArrayList)

Example 12 with ConfigurationFieldModel

use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.

the class MockConfigurationModelFactory method mockField.

private static void mockField(List<ConfigurationFieldModel> fieldList, ConfigurationModel configurationModel, String key, Collection<String> values) {
    ConfigurationFieldModel field = ConfigurationFieldModel.create(key);
    field.setFieldValues(values);
    Mockito.when(configurationModel.getField(key)).thenReturn(Optional.of(field));
    fieldList.add(field);
}
Also used : ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)

Example 13 with ConfigurationFieldModel

use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.

the class NotificationRemovalTest method createBlackDuckConfiguration.

private ConfigurationModel createBlackDuckConfiguration() {
    ConfigurationFieldModel blackDuckURLField = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_URL);
    blackDuckURLField.setFieldValue(BLACKDUCK_PROVIDER_URL);
    ConfigurationFieldModel blackDuckAPITokenField = ConfigurationFieldModel.createSensitive(BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY);
    blackDuckAPITokenField.setFieldValue("");
    ConfigurationFieldModel blackDuckTimeoutField = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_TIMEOUT);
    blackDuckTimeoutField.setFieldValue("300");
    BlackDuckProviderKey blackDuckProviderKey = new BlackDuckProviderKey();
    return configurationModelConfigurationAccessor.createConfiguration(blackDuckProviderKey, ConfigContextEnum.GLOBAL, List.of(blackDuckURLField, blackDuckAPITokenField, blackDuckTimeoutField));
}
Also used : BlackDuckProviderKey(com.synopsys.integration.alert.descriptor.api.BlackDuckProviderKey) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)

Example 14 with ConfigurationFieldModel

use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.

the class MockConfigurationModelFactory method createEmailDistributionFields.

public static List<ConfigurationFieldModel> createEmailDistributionFields() {
    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, "false");
    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;
}
Also used : ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) ArrayList(java.util.ArrayList)

Example 15 with ConfigurationFieldModel

use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.

the class MockConfigurationModelFactory method createFieldModel.

public static ConfigurationFieldModel createFieldModel(String fieldKey, Collection<String> fieldValues) {
    ConfigurationFieldModel configurationFieldModel = ConfigurationFieldModel.create(fieldKey);
    configurationFieldModel.setFieldValues(fieldValues);
    return configurationFieldModel;
}
Also used : ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)

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