Search in sources :

Example 31 with ConfigurationValue

use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.

the class MaterialConfigsMother method pluggableSCMMaterialConfigWithConfigProperties.

public static PluggableSCMMaterialConfig pluggableSCMMaterialConfigWithConfigProperties(String... properties) {
    SCM scmConfig = SCMMother.create("scm-id");
    Configuration configuration = new Configuration();
    for (String property : properties) {
        ConfigurationProperty configurationProperty = new ConfigurationProperty(new ConfigurationKey(property), new ConfigurationValue(property + "-value"));
        configuration.add(configurationProperty);
    }
    scmConfig.setConfiguration(configuration);
    return new PluggableSCMMaterialConfig(null, scmConfig, "des-folder", null);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) Configuration(com.thoughtworks.go.domain.config.Configuration) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) SCM(com.thoughtworks.go.domain.scm.SCM)

Example 32 with ConfigurationValue

use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.

the class SCMTest method shouldClearConfigurationsWhichAreEmptyAndNoErrors.

@Test
public void shouldClearConfigurationsWhichAreEmptyAndNoErrors() throws Exception {
    SCM scm = new SCM();
    scm.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name-one"), new ConfigurationValue()));
    scm.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name-two"), new EncryptedConfigurationValue()));
    scm.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name-three"), null, new EncryptedConfigurationValue(), null));
    ConfigurationProperty configurationProperty = new ConfigurationProperty(new ConfigurationKey("name-four"), null, new EncryptedConfigurationValue(), null);
    configurationProperty.addErrorAgainstConfigurationValue("error");
    scm.getConfiguration().add(configurationProperty);
    scm.clearEmptyConfigurations();
    assertThat(scm.getConfiguration().size(), is(1));
    assertThat(scm.getConfiguration().get(0).getConfigurationKey().getName(), is("name-four"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Test(org.junit.Test)

Example 33 with ConfigurationValue

use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.

the class PluggableScmServiceTest method shouldPassValidationIfAllRequiredFieldsHaveValuesForSCM.

@Test
public void shouldPassValidationIfAllRequiredFieldsHaveValuesForSCM() {
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    configuration.getProperty("KEY1").setConfigurationValue(new ConfigurationValue("junk"));
    SCM modifiedSCM = new SCM("scm-id", new PluginConfiguration(pluginId, "1"), configuration);
    ValidationResult validationResult = new ValidationResult();
    when(scmExtension.isSCMConfigurationValid(eq(modifiedSCM.getPluginConfiguration().getId()), any(SCMPropertyConfiguration.class))).thenReturn(validationResult);
    pluggableScmService.validate(modifiedSCM);
    assertTrue(validationResult.getErrors().isEmpty());
}
Also used : ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCM(com.thoughtworks.go.domain.scm.SCM) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) Test(org.junit.Test)

Example 34 with ConfigurationValue

use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.

the class PluggableScmServiceTest method shouldHandleIncorrectKeyForValidateSCM.

@Test
public void shouldHandleIncorrectKeyForValidateSCM() {
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    configuration.getProperty("KEY1").setConfigurationValue(new ConfigurationValue("junk"));
    SCM modifiedSCM = new SCM("scm-id", new PluginConfiguration(pluginId, "1"), configuration);
    ValidationResult validationResult = new ValidationResult();
    validationResult.addError(new ValidationError("NON-EXISTENT-KEY", "error message"));
    when(scmExtension.isSCMConfigurationValid(eq(modifiedSCM.getPluginConfiguration().getId()), any(SCMPropertyConfiguration.class))).thenReturn(validationResult);
    pluggableScmService.validate(modifiedSCM);
    assertTrue(modifiedSCM.errors().isEmpty());
}
Also used : ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) ValidationError(com.thoughtworks.go.plugin.api.response.validation.ValidationError) SCM(com.thoughtworks.go.domain.scm.SCM) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) Test(org.junit.Test)

Aggregations

ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)34 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)28 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)27 Test (org.junit.Test)27 Configuration (com.thoughtworks.go.domain.config.Configuration)20 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)16 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)14 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)9 GoCipher (com.thoughtworks.go.security.GoCipher)8 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)5 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)4 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)4 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)4 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)4 SCM (com.thoughtworks.go.domain.scm.SCM)3 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)3 HashMap (java.util.HashMap)3 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)2 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)2 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)2