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));
}
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);
}
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));
}
Aggregations