Search in sources :

Example 26 with PluggableTask

use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.

the class MissingPluggableTaskViewModelTest method shouldReturnPluginIdAsDisplayValue.

@Test
public void shouldReturnPluginIdAsDisplayValue() throws Exception {
    PluginConfiguration pluginConfiguration = new PluginConfiguration("test-plugin-1", "1.0");
    PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, new Configuration());
    MissingPluggableTaskViewModel viewModel = new MissingPluggableTaskViewModel(pluggableTask, null);
    assertThat(viewModel.getParameters().get("template"), is(String.format("Associated plugin '%s' not found. Please contact the Go admin to install the plugin.", pluginConfiguration.getId())));
    assertThat(viewModel.getTypeForDisplay(), is(pluginConfiguration.getId()));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) 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 27 with PluggableTask

use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.

the class PluggableTaskViewModelFactoryTest method assertPluggableViewModel.

private void assertPluggableViewModel(String actionName, String expectedTemplatePath) {
    PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration("plugin-1", "2"), new Configuration());
    PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
    PluggableViewModel<PluggableTask> viewModel = factory.viewModelFor(pluggableTask, actionName);
    assertThat(viewModel.getModel(), is(pluggableTask));
    assertThat(viewModel.getTaskType(), is("pluggable_task_plugin_1"));
    assertThat(viewModel.getTemplatePath(), is(expectedTemplatePath));
}
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)

Example 28 with PluggableTask

use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.

the class PluggableTaskViewModelFactoryTest method getModelWithTaskTemplateHavingValue.

private PluggableViewModel<PluggableTask> getModelWithTaskTemplateHavingValue(final String templateContentValue) {
    when(taskPreference.getView()).thenReturn(new TaskView() {

        @Override
        public String displayValue() {
            return "view";
        }

        @Override
        public String template() {
            return templateContentValue;
        }
    });
    PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration("plugin-1", "2"), new Configuration());
    PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
    return factory.viewModelFor(pluggableTask, "new");
}
Also used : TaskView(com.thoughtworks.go.plugin.api.task.TaskView) 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)

Example 29 with PluggableTask

use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.

the class PluggableTaskViewModelFactoryTest method dataForViewShouldBeGotFromTheTaskInJSONFormat.

@Test
public void dataForViewShouldBeGotFromTheTaskInJSONFormat() throws Exception {
    Configuration configuration = new Configuration(create("key1", false, "value1"), create("KEY2", false, "value2"));
    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\"}}", Map.class);
    assertEquals(expected, actual);
}
Also used : 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 30 with PluggableTask

use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldAllowPluggableTaskConfiguration.

@Test
public void shouldAllowPluggableTaskConfiguration() throws Exception {
    String configString = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'>\n" + " <pipelines>" + "<pipeline name='pipeline1'>" + "    <materials>" + "      <svn url='svnurl' username='admin' password='%s'/>" + "    </materials>" + "  <stage name='mingle'>" + "    <jobs>" + "      <job name='do-something'><tasks>" + "        <task>" + "          <pluginConfiguration id='plugin-id-1' version='1.0'/>" + "          <configuration>" + "            <property><key>url</key><value>http://fake-go-server</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>";
    CruiseConfig cruiseConfig = ConfigMigrator.loadWithMigration(configString).configForEdit;
    PipelineConfig pipelineConfig = cruiseConfig.getAllPipelineConfigs().get(0);
    JobConfig jobConfig = pipelineConfig.getFirstStageConfig().getJobs().get(0);
    Tasks tasks = jobConfig.getTasks();
    assertThat(tasks.size(), is(1));
    assertThat(tasks.get(0) instanceof PluggableTask, is(true));
    PluggableTask task = (PluggableTask) tasks.get(0);
    assertThat(task.getTaskType(), is("pluggable_task_plugin_id_1"));
    assertThat(task.getTypeForDisplay(), is("Pluggable Task"));
    final Configuration configuration = task.getConfiguration();
    assertThat(configuration.listOfConfigKeys().size(), is(3));
    assertThat(configuration.listOfConfigKeys(), is(asList("url", "username", "password")));
    Collection values = CollectionUtils.collect(configuration.listOfConfigKeys(), new Transformer() {

        @Override
        public Object transform(Object o) {
            ConfigurationProperty property = configuration.getProperty((String) o);
            return property.getConfigurationValue().getValue();
        }
    });
    assertThat(new ArrayList<>(values), is(asList("http://fake-go-server", "godev", "password")));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Transformer(org.apache.commons.collections.Transformer) Configuration(com.thoughtworks.go.domain.config.Configuration) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Collection(java.util.Collection) Test(org.junit.Test)

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 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)3 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)3 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)3 Gson (com.google.gson.Gson)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)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 MissingPluggableTaskViewModel (com.thoughtworks.go.presentation.MissingPluggableTaskViewModel)2