use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class SCMTest method shouldValidateUniqueKeysInConfiguration.
@Test
public void shouldValidateUniqueKeysInConfiguration() {
ConfigurationProperty one = create("one", false, "value1");
ConfigurationProperty duplicate1 = create("ONE", false, "value2");
ConfigurationProperty duplicate2 = create("ONE", false, "value3");
ConfigurationProperty two = create("two", false, null);
SCM scm = new SCM();
scm.setConfiguration(new Configuration(one, duplicate1, duplicate2, two));
scm.setName("git");
scm.validate(null);
assertThat(one.errors().isEmpty(), is(false));
assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for SCM 'git'"), is(true));
assertThat(duplicate1.errors().isEmpty(), is(false));
assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for SCM 'git'"), is(true));
assertThat(duplicate2.errors().isEmpty(), is(false));
assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for SCM 'git'"), is(true));
assertThat(two.errors().isEmpty(), is(true));
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class SCMTest method shouldGetConfigAsMap.
@Test
public void shouldGetConfigAsMap() throws Exception {
PluginConfiguration pluginConfiguration = new PluginConfiguration("test-plugin-id", "13.4");
GoCipher cipher = new GoCipher();
List<String> keys = Arrays.asList("Avengers 1", "Avengers 2", "Avengers 3", "Avengers 4");
List<String> values = Arrays.asList("Iron man", "Hulk", "Thor", "Captain America");
Configuration configuration = new Configuration(new ConfigurationProperty(new ConfigurationKey(keys.get(0)), new ConfigurationValue(values.get(0))), new ConfigurationProperty(new ConfigurationKey(keys.get(1)), new ConfigurationValue(values.get(1))), new ConfigurationProperty(new ConfigurationKey(keys.get(2)), new ConfigurationValue(values.get(2))), new ConfigurationProperty(new ConfigurationKey(keys.get(3)), new ConfigurationValue(values.get(3)), new EncryptedConfigurationValue(cipher.encrypt(values.get(3))), cipher));
SCM scm = new SCM("scm-id", pluginConfiguration, configuration);
Map<String, Map<String, String>> configMap = scm.getConfigAsMap();
assertThat(configMap.keySet().size(), is(keys.size()));
assertThat(configMap.values().size(), is(values.size()));
assertThat(configMap.keySet().containsAll(keys), is(true));
for (int i = 0; i < keys.size(); i++) {
assertThat(configMap.get(keys.get(i)).get(SCM.VALUE_KEY), is(values.get(i)));
}
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class SCMTest method shouldAddConfigurationPropertiesForAnyPlugin.
@Test
public void shouldAddConfigurationPropertiesForAnyPlugin() {
List<ConfigurationProperty> configurationProperties = Arrays.asList(ConfigurationPropertyMother.create("key", "value", "encValue"));
Configuration configuration = new Configuration();
SCM scm = SCMMother.create("id", "name", "does_not_exist", "1.1", configuration);
assertThat(configuration.size(), is(0));
scm.addConfigurations(configurationProperties);
assertThat(configuration.size(), is(1));
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty 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.ConfigurationProperty 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);
}
Aggregations