use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method shouldPopulateItselfFromConfigAttributesMap.
@Test
public void shouldPopulateItselfFromConfigAttributesMap() throws Exception {
TaskPreference taskPreference = mock(TaskPreference.class);
Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"), ConfigurationPropertyMother.create("Key2"));
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");
TaskProperty property2 = new TaskProperty("Key2", "value2");
taskConfig.addProperty(property1.getName());
taskConfig.addProperty(property2.getName());
when(taskPreference.getConfig()).thenReturn(taskConfig);
task.setTaskConfigAttributes(attributeMap);
assertThat(task.configAsMap().get("KEY1").get(PluggableTask.VALUE_KEY), is("value1"));
assertThat(task.configAsMap().get("Key2").get(PluggableTask.VALUE_KEY), is("value2"));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method shouldAddConfigurationPropertiesForAInvalidPlugin.
@Test
public void shouldAddConfigurationPropertiesForAInvalidPlugin() {
List<ConfigurationProperty> configurationProperties = Arrays.asList(ConfigurationPropertyMother.create("key", "value", "encValue"));
PluginConfiguration pluginConfiguration = new PluginConfiguration("does_not_exist", "1.1");
Configuration configuration = new Configuration();
PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, configuration);
pluggableTask.addConfigurations(configurationProperties);
assertThat(configuration.size(), is(1));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method taskTypeShouldBeSanitizedToHaveNoSpecialCharacters.
@Test
public void taskTypeShouldBeSanitizedToHaveNoSpecialCharacters() throws Exception {
assertThat(new PluggableTask(new PluginConfiguration("abc.def", "1"), new Configuration()).getTaskType(), is("pluggable_task_abc_def"));
assertThat(new PluggableTask(new PluginConfiguration("abc_def", "1"), new Configuration()).getTaskType(), is("pluggable_task_abc_def"));
assertThat(new PluggableTask(new PluginConfiguration("abcdef", "1"), new Configuration()).getTaskType(), is("pluggable_task_abcdef"));
assertThat(new PluggableTask(new PluginConfiguration("abc#def", "1"), new Configuration()).getTaskType(), is("pluggable_task_abc_def"));
assertThat(new PluggableTask(new PluginConfiguration("abc#__def", "1"), new Configuration()).getTaskType(), is("pluggable_task_abc___def"));
assertThat(new PluggableTask(new PluginConfiguration("Abc#dEF", "1"), new Configuration()).getTaskType(), is("pluggable_task_Abc_dEF"));
assertThat(new PluggableTask(new PluginConfiguration("1234567890#ABCDEF", "1"), new Configuration()).getTaskType(), is("pluggable_task_1234567890_ABCDEF"));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method validateTreeShouldVerifyIfConfigurationHasErrors.
@Test
public void validateTreeShouldVerifyIfConfigurationHasErrors() {
Configuration configuration = mock(Configuration.class);
PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration(), configuration);
when(configuration.hasErrors()).thenReturn(true);
assertFalse(pluggableTask.validateTree(null));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskBuilderCreatorTest method setup.
@BeforeEach
public void setup() throws Exception {
pluggableTask = new PluggableTask(new PluginConfiguration("test-plugin-id", "13.4"), new Configuration());
pluggableTaskBuilderCreator = new PluggableTaskBuilderCreator();
execTaskBuilder = new ExecTaskBuilder();
builderFactory = mock(BuilderFactory.class);
resolver = mock(UpstreamPipelineResolver.class);
}
Aggregations