Search in sources :

Example 61 with PluginConfiguration

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"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskProperty(com.thoughtworks.go.domain.TaskProperty) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.jupiter.api.Test)

Example 62 with PluginConfiguration

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));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.jupiter.api.Test)

Example 63 with PluginConfiguration

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"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.jupiter.api.Test)

Example 64 with PluginConfiguration

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));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.jupiter.api.Test)

Example 65 with PluginConfiguration

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);
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) UpstreamPipelineResolver(com.thoughtworks.go.server.service.UpstreamPipelineResolver) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)88 Configuration (com.thoughtworks.go.domain.config.Configuration)63 Test (org.junit.jupiter.api.Test)61 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)29 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)23 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)18 SCM (com.thoughtworks.go.domain.scm.SCM)17 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)13 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)13 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)9 Test (org.junit.Test)9 TaskProperty (com.thoughtworks.go.domain.TaskProperty)8 Map (java.util.Map)8 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)6 HashMap (java.util.HashMap)5 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)4 Result (com.thoughtworks.go.plugin.api.response.Result)4 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)4 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 AntTask (com.thoughtworks.go.config.AntTask)3