Search in sources :

Example 1 with PluginView

use of com.thoughtworks.go.plugin.domain.common.PluginView in project gocd by gocd.

the class PluggableTaskPluginInfoBuilderTest method shouldBuildPluginInfo.

@Test
public void shouldBuildPluginInfo() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    PluggableTaskPluginInfo pluginInfo = new PluggableTaskPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    List<PluginConfiguration> pluginConfigurations = Arrays.asList(new PluginConfiguration("username", new Metadata(true, false)), new PluginConfiguration("password", new Metadata(true, true)));
    PluginView pluginView = new PluginView("some html");
    assertThat(pluginInfo.getDescriptor(), is(descriptor));
    assertThat(pluginInfo.getExtensionName(), is("task"));
    assertThat(pluginInfo.getDisplayName(), is("my task plugin"));
    assertThat(pluginInfo.getTaskSettings(), is(new PluggableInstanceSettings(pluginConfigurations, pluginView)));
    assertNull(pluginInfo.getPluginSettings());
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluggableTaskPluginInfo(com.thoughtworks.go.plugin.domain.pluggabletask.PluggableTaskPluginInfo) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) PluginView(com.thoughtworks.go.plugin.domain.common.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 2 with PluginView

use of com.thoughtworks.go.plugin.domain.common.PluginView in project gocd by gocd.

the class ConfigRepoPluginInfoBuilderTest method shouldBuildPluginInfo.

@Test
public void shouldBuildPluginInfo() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    stub(extension.getPluginSettingsView("plugin1")).toReturn("some-html");
    ConfigRepoPluginInfo pluginInfo = new ConfigRepoPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    List<PluginConfiguration> pluginConfigurations = Arrays.asList(new PluginConfiguration("username", new Metadata(true, false)), new PluginConfiguration("password", new Metadata(true, true)));
    PluginView pluginView = new PluginView("some-html");
    assertThat(pluginInfo.getDescriptor(), is(descriptor));
    assertThat(pluginInfo.getExtensionName(), is("configrepo"));
    assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(pluginConfigurations, pluginView)));
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) PluginView(com.thoughtworks.go.plugin.domain.common.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ConfigRepoPluginInfo(com.thoughtworks.go.plugin.domain.configrepo.ConfigRepoPluginInfo) Test(org.junit.Test)

Example 3 with PluginView

use of com.thoughtworks.go.plugin.domain.common.PluginView in project gocd by gocd.

the class NotificationPluginInfoBuilderTest method shouldBuildPluginInfo.

@Test
public void shouldBuildPluginInfo() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    NotificationPluginInfo pluginInfo = new NotificationPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    List<PluginConfiguration> pluginConfigurations = Arrays.asList(new PluginConfiguration("username", new Metadata(true, false)), new PluginConfiguration("password", new Metadata(true, true)));
    PluginView pluginView = new PluginView("some-html");
    assertThat(pluginInfo.getDescriptor(), is(descriptor));
    assertThat(pluginInfo.getExtensionName(), is("notification"));
    assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(pluginConfigurations, pluginView)));
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) NotificationPluginInfo(com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) PluginView(com.thoughtworks.go.plugin.domain.common.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 4 with PluginView

use of com.thoughtworks.go.plugin.domain.common.PluginView in project gocd by gocd.

the class ElasticAgentPluginInfoBuilder method elasticProfileSettings.

private PluggableInstanceSettings elasticProfileSettings(String pluginId) {
    List<PluginConfiguration> profileMetadata = extension.getProfileMetadata(pluginId);
    String profileView = extension.getProfileView(pluginId);
    return new PluggableInstanceSettings(profileMetadata, new PluginView(profileView));
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) PluginView(com.thoughtworks.go.plugin.domain.common.PluginView)

Example 5 with PluginView

use of com.thoughtworks.go.plugin.domain.common.PluginView in project gocd by gocd.

the class PluggableTaskPluginInfoBuilder method pluginInfoFor.

public PluggableTaskPluginInfo pluginInfoFor(GoPluginDescriptor descriptor) {
    final TaskPreference[] tp = { null };
    extension.doOnTask(descriptor.id(), new Action<Task>() {

        @Override
        public void execute(Task task, GoPluginDescriptor pluginDescriptor) {
            tp[0] = new TaskPreference(task);
        }
    });
    TaskConfig config = tp[0].getConfig();
    TaskView view = tp[0].getView();
    if (config == null) {
        throw new RuntimeException(format("Plugin[%s] returned null task configuration", descriptor.id()));
    }
    if (view == null) {
        throw new RuntimeException(format("Plugin[%s] returned null task view", descriptor.id()));
    }
    String displayName = view.displayValue();
    PluggableInstanceSettings taskSettings = new PluggableInstanceSettings(configurations(config), new PluginView(view.template()));
    return new PluggableTaskPluginInfo(descriptor, displayName, taskSettings);
}
Also used : Task(com.thoughtworks.go.plugin.api.task.Task) TaskView(com.thoughtworks.go.plugin.api.task.TaskView) PluggableTaskPluginInfo(com.thoughtworks.go.plugin.domain.pluggabletask.PluggableTaskPluginInfo) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) PluginView(com.thoughtworks.go.plugin.domain.common.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)

Aggregations

PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)5 PluginView (com.thoughtworks.go.plugin.domain.common.PluginView)5 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)4 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)3 Test (org.junit.Test)3 PluggableTaskPluginInfo (com.thoughtworks.go.plugin.domain.pluggabletask.PluggableTaskPluginInfo)2 Task (com.thoughtworks.go.plugin.api.task.Task)1 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)1 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)1 ConfigRepoPluginInfo (com.thoughtworks.go.plugin.domain.configrepo.ConfigRepoPluginInfo)1 NotificationPluginInfo (com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo)1