Search in sources :

Example 21 with TaskPreference

use of com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference in project gocd by gocd.

the class PluggableTaskViewModelBuilder method pluginInfoFor.

public PluginInfo pluginInfoFor(String pluginId) {
    if (!PluggableTaskConfigStore.store().hasPreferenceFor(pluginId)) {
        return null;
    }
    GoPluginDescriptor descriptor = pluginManager.getPluginDescriptorFor(pluginId);
    TaskPreference taskPreference = PluggableTaskConfigStore.store().preferenceFor(pluginId);
    List<PluginConfiguration> pluginConfigurations = configurations(taskPreference.getConfig());
    PluginView pluginView = new PluginView(taskPreference.getView().template());
    return new PluginInfo(descriptor, TaskExtension.TASK_EXTENSION, taskPreference.getView().displayValue(), new PluggableInstanceSettings(pluginConfigurations, pluginView));
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)

Example 22 with TaskPreference

use of com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference in project gocd by gocd.

the class PluggableTaskTest method postConstructShouldHandleSecureConfigurationForConfigurationProperties.

@Test
public void postConstructShouldHandleSecureConfigurationForConfigurationProperties() throws Exception {
    TaskPreference taskPreference = mock(TaskPreference.class);
    ConfigurationProperty configurationProperty = ConfigurationPropertyMother.create("KEY1");
    Configuration configuration = new Configuration(configurationProperty);
    PluggableTaskConfigStore.store().setPreferenceFor("abc.def", taskPreference);
    TaskConfig taskConfig = new TaskConfig();
    taskConfig.addProperty("KEY1").with(Property.SECURE, true);
    when(taskPreference.getConfig()).thenReturn(taskConfig);
    PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
    assertFalse(configurationProperty.isSecure());
    task.applyPluginMetadata();
    assertTrue(configurationProperty.isSecure());
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.Test)

Example 23 with TaskPreference

use of com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference in project gocd by gocd.

the class PluggableTaskTest method shouldPopulateItselfFromConfigAttributesMap.

@Test
public void shouldPopulateItselfFromConfigAttributesMap() throws Exception {
    TaskPreference taskPreference = mock(TaskPreference.class);
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"), ConfigurationPropertyMother.create("Key2"));
    PluggableTaskConfigStore.store().setPreferenceFor("abc.def", taskPreference);
    PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
    Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1", "Key2", "value2");
    TaskConfig taskConfig = new TaskConfig();
    TaskProperty property1 = new TaskProperty("KEY1", "value1");
    TaskProperty property2 = new TaskProperty("Key2", "value2");
    taskConfig.addProperty(property1.getName());
    taskConfig.addProperty(property2.getName());
    when(taskPreference.getConfig()).thenReturn(taskConfig);
    task.setTaskConfigAttributes(attributeMap);
    assertThat(task.configAsMap().get("KEY1").get(PluggableTask.VALUE_KEY), is("value1"));
    assertThat(task.configAsMap().get("Key2").get(PluggableTask.VALUE_KEY), is("value2"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskProperty(com.thoughtworks.go.domain.TaskProperty) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.Test)

Example 24 with TaskPreference

use of com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference 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);
}
Also used : TaskView(com.thoughtworks.go.plugin.api.task.TaskView) JsonBasedPluggableTask(com.thoughtworks.go.plugin.access.pluggabletask.JsonBasedPluggableTask) PluggableTaskPluginInfo(com.thoughtworks.go.server.ui.plugins.PluggableTaskPluginInfo) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluggableTaskConfigStore(com.thoughtworks.go.plugin.access.pluggabletask.PluggableTaskConfigStore) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.Test)

Example 25 with TaskPreference

use of com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference 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);
}
Also used : TaskView(com.thoughtworks.go.plugin.api.task.TaskView) JsonBasedPluggableTask(com.thoughtworks.go.plugin.access.pluggabletask.JsonBasedPluggableTask) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Before(org.junit.Before)

Aggregations

TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)26 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)16 Test (org.junit.Test)14 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)12 Configuration (com.thoughtworks.go.domain.config.Configuration)11 TaskProperty (com.thoughtworks.go.domain.TaskProperty)8 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)8 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)8 TaskConfigProperty (com.thoughtworks.go.plugin.api.task.TaskConfigProperty)7 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)5 JsonBasedPluggableTask (com.thoughtworks.go.plugin.access.pluggabletask.JsonBasedPluggableTask)4 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)4 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)4 Before (org.junit.Before)4 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)3 Property (com.thoughtworks.go.plugin.api.config.Property)3 PluggableTaskPluginInfo (com.thoughtworks.go.server.ui.plugins.PluggableTaskPluginInfo)3 ArrayList (java.util.ArrayList)3 AntTask (com.thoughtworks.go.config.AntTask)2 PluggableTaskConfigStore (com.thoughtworks.go.plugin.access.pluggabletask.PluggableTaskConfigStore)2