Search in sources :

Example 1 with PluggableTask

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

Example 2 with PluggableTask

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);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Gson(com.google.gson.Gson) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Map(java.util.Map) Test(org.junit.Test)

Example 3 with PluggableTask

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

Example 4 with PluggableTask

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)));
}
Also used : ContextConfiguration(org.springframework.test.context.ContextConfiguration) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Test(org.junit.Test)

Example 5 with PluggableTask

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;
}
Also used : ArrayList(java.util.ArrayList) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)

Aggregations

PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)38 Test (org.junit.Test)33 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)28 Configuration (com.thoughtworks.go.domain.config.Configuration)18 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)8 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)7 Map (java.util.Map)6 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)5 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 HashMap (java.util.HashMap)4 BuildLogElement (com.thoughtworks.go.domain.BuildLogElement)3 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)3 ExecutionResult (com.thoughtworks.go.plugin.api.response.execution.ExecutionResult)3 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)3 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)3 Gson (com.google.gson.Gson)2 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)2 Property (com.thoughtworks.go.plugin.api.config.Property)2 TaskConfigProperty (com.thoughtworks.go.plugin.api.task.TaskConfigProperty)2 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)2