Search in sources :

Example 86 with PluginConfiguration

use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.

the class PluggableTaskBuilderTest method shouldReturnDefaultValueInExecConfigWhenNoConfigValueIsProvided.

@Test
public void shouldReturnDefaultValueInExecConfigWhenNoConfigValueIsProvided() throws Exception {
    Map<String, Map<String, String>> configMap = new HashMap<>();
    PluggableTask task = mock(PluggableTask.class);
    when(task.getPluginConfiguration()).thenReturn(new PluginConfiguration());
    when(task.configAsMap()).thenReturn(configMap);
    PluggableTaskBuilder taskBuilder = new PluggableTaskBuilder(runIfConfigs, cancelBuilder, task, TEST_PLUGIN_ID, "test-directory");
    TaskConfig defaultTaskConfig = new TaskConfig();
    String propertyName = "URL";
    String defaultValue = "ABC.TXT";
    defaultTaskConfig.addProperty(propertyName).withDefault(defaultValue);
    TaskConfig config = taskBuilder.buildTaskConfig(defaultTaskConfig);
    assertThat(config.getValue(propertyName), is(defaultValue));
}
Also used : HashMap(java.util.HashMap) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) HashMap(java.util.HashMap) Map(java.util.Map) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Test(org.junit.jupiter.api.Test)

Example 87 with PluginConfiguration

use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.

the class PluggableTaskBuilderTest method setUp.

@BeforeEach
public void setUp() {
    PluginManagerReference.reference().setPluginManager(pluginManager);
    when(pluggableTask.getPluginConfiguration()).thenReturn(new PluginConfiguration(TEST_PLUGIN_ID, "1.0"));
    HashMap<String, Map<String, String>> pluginConfig = new HashMap<>();
    when(pluggableTask.configAsMap()).thenReturn(pluginConfig);
    taskExtension = new TaskExtension(pluginManager, extensionsRegistry);
}
Also used : TaskExtension(com.thoughtworks.go.plugin.access.pluggabletask.TaskExtension) HashMap(java.util.HashMap) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) HashMap(java.util.HashMap) Map(java.util.Map) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 88 with PluginConfiguration

use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.

the class PluggableTaskBuilderTest method shouldReturnPluggableTaskContext.

@Test
public void shouldReturnPluggableTaskContext() throws Exception {
    PluggableTask task = mock(PluggableTask.class);
    when(task.getPluginConfiguration()).thenReturn(new PluginConfiguration());
    String workingDir = "test-directory";
    PluggableTaskBuilder taskBuilder = new PluggableTaskBuilder(runIfConfigs, cancelBuilder, task, TEST_PLUGIN_ID, workingDir);
    TaskExecutionContext taskExecutionContext = taskBuilder.buildTaskContext(goPublisher, variableContext, "utf-8");
    assertThat(taskExecutionContext instanceof PluggableTaskContext, is(true));
    assertThat(taskExecutionContext.workingDir(), is(workingDir));
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Test(org.junit.jupiter.api.Test)

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