use of com.thoughtworks.go.plugin.api.task.TaskConfig in project gocd by gocd.
the class PluggableTaskServiceTest method isValidShouldMapPluginValidationErrorsToPluggableTaskForMissingConfigurations.
@Test
public void isValidShouldMapPluginValidationErrorsToPluggableTaskForMissingConfigurations() {
PluginConfiguration pluginConfiguration = new PluginConfiguration("plugin_id", "version");
ValidationResult validationResult = new ValidationResult();
validationResult.addError(new ValidationError("source", "source is mandatory"));
PluggableTask pluggableTask = mock(PluggableTask.class);
when(pluggableTask.isValid()).thenReturn(true);
when(pluggableTask.toTaskConfig()).thenReturn(new TaskConfig());
when(pluggableTask.getPluginConfiguration()).thenReturn(pluginConfiguration);
when(pluggableTask.getConfiguration()).thenReturn(new Configuration());
when(taskExtension.validate(any(String.class), any(TaskConfig.class))).thenReturn(validationResult);
assertFalse(pluggableTaskService.isValid(pluggableTask));
verify(pluggableTask).addError("source", "source is mandatory");
}
use of com.thoughtworks.go.plugin.api.task.TaskConfig in project gocd by gocd.
the class PluggableTaskPluginInfoBuilderTest method pluginInfoFor_ShouldProvidePluginInfoForAPlugin.
@Test
public void pluginInfoFor_ShouldProvidePluginInfoForAPlugin() throws Exception {
GoPluginDescriptor.About about = new GoPluginDescriptor.About("Plugin Descriptor Validator", "1.0.1", "12.4", "Validates its own plugin descriptor", new GoPluginDescriptor.Vendor("ThoughtWorks Go Team", "www.thoughtworks.com"), Arrays.asList("Linux", "Windows", "Mac OS X"));
GoPluginDescriptor plugin = new GoPluginDescriptor("docker-plugin", "1.0", about, null, null, false);
PluginManager pluginManager = mock(PluginManager.class);
PluggableTaskConfigStore packageMetadataStore = mock(PluggableTaskConfigStore.class);
when(packageMetadataStore.pluginIds()).thenReturn(Collections.singleton(plugin.id()));
when(pluginManager.getPluginDescriptorFor(plugin.id())).thenReturn(plugin);
JsonBasedPluggableTask jsonBasedPluggableTask = mock(JsonBasedPluggableTask.class);
TaskView taskView = new TaskView() {
@Override
public String displayValue() {
return "task display value";
}
@Override
public String template() {
return "pluggable task view template";
}
};
TaskConfig taskConfig = new TaskConfig();
taskConfig.add(new TaskConfigProperty("key1", null));
taskConfig.add(new TaskConfigProperty("key2", null));
when(jsonBasedPluggableTask.config()).thenReturn(taskConfig);
when(jsonBasedPluggableTask.view()).thenReturn(taskView);
TaskPreference taskPreference = new TaskPreference(jsonBasedPluggableTask);
when(packageMetadataStore.preferenceFor(plugin.id())).thenReturn(taskPreference);
PluggableTaskPluginInfoBuilder builder = new PluggableTaskPluginInfoBuilder(pluginManager, packageMetadataStore);
PluggableTaskPluginInfo pluginInfo = builder.pluginInfoFor(plugin.id());
PluggableTaskPluginInfo expectedPluginInfo = new PluggableTaskPluginInfo(plugin, taskView.displayValue(), new PluggableInstanceSettings(configurations(taskConfig), new PluginView(taskView.template())));
assertEquals(expectedPluginInfo, pluginInfo);
}
use of com.thoughtworks.go.plugin.api.task.TaskConfig in project gocd by gocd.
the class PluggableTaskViewModelBuilderTest method setUp.
@Before
public void setUp() {
initMocks(this);
builder = new PluggableTaskViewModelBuilder(manager);
xunitConvertor = new GoPluginDescriptor("xunit.convertor", "version1", new GoPluginDescriptor.About("Xunit Convertor", "1.0", null, null, null, null), null, null, false);
powershellTask = new GoPluginDescriptor("powershell.task", "version1", new GoPluginDescriptor.About("Powershell Task", "2.0", null, null, null, null), null, null, false);
JsonBasedPluggableTask jsonBasedPluggableTask = mock(JsonBasedPluggableTask.class);
TaskView taskView = new TaskView() {
@Override
public String displayValue() {
return "task display value";
}
@Override
public String template() {
return "pluggable task view template";
}
};
TaskConfig taskConfig = new TaskConfig();
taskConfig.add(new TaskConfigProperty("key1", null));
taskConfig.add(new TaskConfigProperty("key2", null));
when(jsonBasedPluggableTask.config()).thenReturn(taskConfig);
when(jsonBasedPluggableTask.view()).thenReturn(taskView);
taskPreference = new TaskPreference(jsonBasedPluggableTask);
PluggableTaskConfigStore.store().setPreferenceFor("xunit.convertor", taskPreference);
PluggableTaskConfigStore.store().setPreferenceFor("powershell.task", taskPreference);
}
use of com.thoughtworks.go.plugin.api.task.TaskConfig in project go-plugins by gocd.
the class CurlTask method config.
@Override
public TaskConfig config() {
TaskConfig config = new TaskConfig();
config.addProperty(URL_PROPERTY);
config.addProperty(SECURE_CONNECTION_PROPERTY).withDefault(SECURE_CONNECTION);
config.addProperty(REQUEST_PROPERTY).withDefault(REQUEST_TYPE);
config.addProperty(ADDITIONAL_OPTIONS);
return config;
}
Aggregations