use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method shouldPopulatePropertiesForDisplayRetainingOrderAndDisplayNameIfConfigured.
@Test
public void shouldPopulatePropertiesForDisplayRetainingOrderAndDisplayNameIfConfigured() throws Exception {
Task taskDetails = mock(Task.class);
TaskConfig taskConfig = new TaskConfig();
addProperty(taskConfig, "KEY2", "Key 2", 1);
addProperty(taskConfig, "KEY1", "Key 1", 0);
addProperty(taskConfig, "KEY3", "Key 3", 2);
when(taskDetails.config()).thenReturn(taskConfig);
when(taskDetails.view()).thenReturn(mock(TaskView.class));
String pluginId = "plugin_with_all_details";
PluggableTaskConfigStore.store().setPreferenceFor(pluginId, new TaskPreference(taskDetails));
Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY3", true, "encryptedValue1"), ConfigurationPropertyMother.create("KEY1", false, "value1"), ConfigurationPropertyMother.create("KEY2", false, "value2"));
PluggableTask task = new PluggableTask(new PluginConfiguration(pluginId, "1"), configuration);
List<TaskProperty> propertiesForDisplay = task.getPropertiesForDisplay();
assertThat(propertiesForDisplay.size(), is(3));
assertProperty(propertiesForDisplay.get(0), "Key 1", "value1", "key1");
assertProperty(propertiesForDisplay.get(1), "Key 2", "value2", "key2");
assertProperty(propertiesForDisplay.get(2), "Key 3", "****", "key3");
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method shouldIgnoreKeysPresentInConfigAttributesMapButNotPresentInConfigStore.
@Test
public void shouldIgnoreKeysPresentInConfigAttributesMapButNotPresentInConfigStore() throws Exception {
TaskPreference taskPreference = mock(TaskPreference.class);
Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
PluggableTaskConfigStore.store().setPreferenceFor("abc.def", taskPreference);
PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1", "Key2", "value2");
TaskConfig taskConfig = new TaskConfig();
TaskProperty property1 = new TaskProperty("KEY1", "value1");
taskConfig.addProperty(property1.getName());
when(taskPreference.getConfig()).thenReturn(taskConfig);
task.setTaskConfigAttributes(attributeMap);
assertThat(task.configAsMap().get("KEY1").get(PluggableTask.VALUE_KEY), is("value1"));
assertFalse(task.configAsMap().containsKey("Key2"));
}
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 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 shouldGetSCMTypeCorrectly.
@Test
public void shouldGetSCMTypeCorrectly() {
SCM scm = SCMMother.create("scm-id");
assertThat(scm.getSCMType(), is("pluggable_material_plugin"));
scm.setPluginConfiguration(new PluginConfiguration("plugin-id-2", "1"));
assertThat(scm.getSCMType(), is("pluggable_material_plugin_id_2"));
}
Aggregations