use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.
the class PluggableTaskViewModelFactoryTest method shouldReturnMissingPluginTaskViewIfPluginIsMissing.
@Test
public void shouldReturnMissingPluginTaskViewIfPluginIsMissing() {
String pluginId = "pluginId";
PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
PluggableViewModel<PluggableTask> viewModel = factory.viewModelFor(new PluggableTask(new PluginConfiguration(pluginId, "1"), new Configuration()), "edit");
assertThat(viewModel.getParameters().get("template"), is(String.format("Associated plugin '%s' not found. Please contact the Go admin to install the plugin.", pluginId)));
assertThat(viewModel.getTypeForDisplay(), is(pluginId));
assertThat(viewModel instanceof MissingPluggableTaskViewModel, is(true));
}
use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.
the class PluggableTaskViewModelFactoryTest method dataForViewShouldIncludeErrorsIfAny.
@Test
public void dataForViewShouldIncludeErrorsIfAny() throws Exception {
ConfigurationProperty property1 = create("key1", false, "value1");
property1.addError("key1", "error msg");
ConfigurationProperty property2 = create("KEY2", false, "value2");
Configuration configuration = new Configuration(property1, property2);
PluggableTask taskConfig = new PluggableTask(new PluginConfiguration("plugin-1", "2"), configuration);
PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
PluggableViewModel<PluggableTask> viewModel = factory.viewModelFor(taskConfig, "new");
String actualData = (String) viewModel.getParameters().get("data");
Gson gson = new Gson();
Map actual = gson.fromJson(actualData, Map.class);
Map expected = gson.fromJson("{\"KEY2\":{\"value\": \"value2\"},\"key1\":{\"value\" : \"value1\", \"errors\" : \"error msg\"}}", Map.class);
assertEquals(expected, actual);
}
use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.
the class PluggableTaskViewModelFactoryTest method typeForDisplayAndTemplateOfViewModelShouldBeGotFromThePlugin.
@Test
public void typeForDisplayAndTemplateOfViewModelShouldBeGotFromThePlugin() throws Exception {
PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration("plugin-1", "2"), new Configuration());
PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
PluggableViewModel<PluggableTask> viewModel = factory.viewModelFor(pluggableTask, "new");
assertThat(viewModel.getTypeForDisplay(), is("First plugin"));
assertThat(viewModel.getParameters().get("template"), is("<input type='text' ng-model='abc'></input>"));
}
use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.
the class GoConfigMigrationIntegrationTest method shouldRemoveNameFromPluggableTask_asPartOfMigration71.
@Test
public void shouldRemoveNameFromPluggableTask_asPartOfMigration71() throws Exception {
String oldConfigWithNameInTask = "<cruise schemaVersion='70'> <pipelines>" + "<pipeline name='pipeline1'>" + " <materials>" + " <svn url='svnurl' username='admin' password='%s'/>" + " </materials>" + " <stage name='mingle'>" + " <jobs>" + " <job name='do-something'><tasks>" + " <task name='run-curl'>" + " <pluginConfiguration id='plugin-id' version='1.0' />" + " <configuration>" + " <property><key>url</key><value>http://fake-yum-repo</value></property>" + " <property><key>username</key><value>godev</value></property>" + " <property><key>password</key><value>password</value></property>" + " </configuration>" + " </task> </tasks>" + " </job>" + " </jobs>" + " </stage>" + "</pipeline></pipelines>" + "</cruise>";
String newConfigWithoutNameInTask = migrateXmlString(oldConfigWithNameInTask, 70);
assertThat(newConfigWithoutNameInTask, not(containsString("<task name")));
assertThat(newConfigWithoutNameInTask, containsString("<task>"));
CruiseConfig cruiseConfig = loadConfigFileWithContent(newConfigWithoutNameInTask);
PipelineConfig pipelineConfig = cruiseConfig.getAllPipelineConfigs().get(0);
JobConfig jobConfig = pipelineConfig.getFirstStageConfig().getJobs().get(0);
Configuration configuration = new Configuration(create("url", false, "http://fake-yum-repo"), create("username", false, "godev"), create("password", false, "password"));
Tasks tasks = jobConfig.getTasks();
assertThat(tasks.size(), is(1));
assertThat(tasks.get(0), is(new PluggableTask(new PluginConfiguration("plugin-id", "1.0"), configuration)));
}
use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.
the class TaskViewService method allPluginTasks.
private List<PluggableTask> allPluginTasks() {
final ArrayList<PluggableTask> tasks = new ArrayList<>();
for (final String pluginId : PluggableTaskConfigStore.store().pluginIds()) {
GoPluginDescriptor pluginDescriptor = pluginManager.getPluginDescriptorFor(pluginId);
TaskPreference taskPreference = PluggableTaskConfigStore.store().preferenceFor(pluginId);
if (pluginDescriptor != null && taskPreference != null) {
tasks.add(new PluggableTask(new PluginConfiguration(pluginId, pluginDescriptor.version()), getConfiguration(taskPreference.getConfig())));
}
}
return tasks;
}
Aggregations