use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class SCMTest method shouldThrowUpOnSetConfigAttributesIfPluginIsNotAvailable.
@Test
public void shouldThrowUpOnSetConfigAttributesIfPluginIsNotAvailable() throws Exception {
try {
Map<String, String> attributeMap = DataStructureUtils.m(SCM.SCM_ID, "scm-id", SCM.NAME, "scm-name", SCM.AUTO_UPDATE, "false", "url", "http://localhost");
SCM scm = new SCM(null, new PluginConfiguration("plugin-id", "1"), new Configuration());
scm.setConfigAttributes(attributeMap);
fail("should have thrown exception");
} catch (Exception e) {
assertThat(e, instanceOf(RuntimeException.class));
assertThat(e.getMessage(), is("metadata unavailable for plugin: plugin-id"));
}
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class SCMTest method shouldPopulateItselfFromConfigAttributesMap.
@Test
public void shouldPopulateItselfFromConfigAttributesMap() throws Exception {
SCMConfigurations scmConfigurations = new SCMConfigurations();
scmConfigurations.add(new SCMConfiguration("KEY1"));
scmConfigurations.add(new SCMConfiguration("Key2"));
SCMPreference scmPreference = mock(SCMPreference.class);
when(scmPreference.getScmConfigurations()).thenReturn(scmConfigurations);
SCMMetadataStore.getInstance().setPreferenceFor("plugin-id", scmPreference);
Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"), ConfigurationPropertyMother.create("Key2"));
SCM scm = new SCM("scm-id", new PluginConfiguration("plugin-id", "1"), configuration);
Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1", "Key2", "value2");
scm.setConfigAttributes(attributeMap);
assertThat(scm.getConfigAsMap().get("KEY1").get(SCM.VALUE_KEY), is("value1"));
assertThat(scm.getConfigAsMap().get("Key2").get(SCM.VALUE_KEY), is("value2"));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class SCMTest method shouldSetConfigAttributesAsAvailable.
@Test
public void shouldSetConfigAttributesAsAvailable() throws Exception {
SCMConfigurations scmConfigurations = new SCMConfigurations();
scmConfigurations.add(new SCMConfiguration("url"));
scmConfigurations.add(new SCMConfiguration("username"));
scmConfigurations.add(new SCMConfiguration("password").with(SECURE, true));
SCMMetadataStore.getInstance().addMetadataFor("plugin-id", scmConfigurations, null);
Map<String, String> attributeMap = DataStructureUtils.m(SCM.SCM_ID, "scm-id", SCM.NAME, "scm-name", SCM.AUTO_UPDATE, "false", "url", "http://localhost", "username", "user", "password", "pass");
SCM scm = new SCM(null, new PluginConfiguration("plugin-id", "1"), new Configuration());
scm.setConfigAttributes(attributeMap);
assertThat(scm.getId(), is("scm-id"));
assertThat(scm.getName(), is("scm-name"));
assertThat(scm.isAutoUpdate(), is(false));
assertThat(scm.getPluginConfiguration().getId(), is("plugin-id"));
assertThat(scm.getConfigAsMap().get("url").get(SCM.VALUE_KEY), is("http://localhost"));
assertThat(scm.getConfigAsMap().get("username").get(SCM.VALUE_KEY), is("user"));
assertThat(scm.getConfigAsMap().get("password").get(SCM.VALUE_KEY), is("pass"));
assertThat(scm.getConfiguration().getProperty("password").getConfigurationValue(), is(nullValue()));
assertThat(scm.getConfiguration().getProperty("password").getEncryptedConfigurationValue(), is(not(nullValue())));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PackageRepositoryMother method create.
public static PackageRepository create(String id, String name, String pluginId, String pluginVersion, Configuration configuration) {
PackageRepository repository = new PackageRepository();
repository.setId(id);
repository.setName(name);
repository.setPluginConfiguration(new PluginConfiguration(pluginId, pluginVersion));
repository.setConfiguration(configuration);
return repository;
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class ConfigConverter method toPluggableTask.
public PluggableTask toPluggableTask(CRPluggableTask pluggableTask) {
PluginConfiguration pluginConfiguration = toPluginConfiguration(pluggableTask.getPluginConfiguration());
Configuration configuration = toConfiguration(pluggableTask.getConfiguration());
PluggableTask task = new PluggableTask(pluginConfiguration, configuration);
setCommonTaskMembers(task, pluggableTask);
return task;
}
Aggregations