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);
}
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"));
}
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());
}
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());
}
Aggregations