Search in sources :

Example 1 with PluginManager

use of com.thoughtworks.go.plugin.infra.PluginManager in project gocd by gocd.

the class SCMPluginInfoBuilderTest method pluginInfoFor_ShouldReturnNullWhenPluginIsNotFound.

@Test
public void pluginInfoFor_ShouldReturnNullWhenPluginIsNotFound() throws Exception {
    PluginManager pluginManager = mock(PluginManager.class);
    SCMMetadataStore scmMetadataStore = mock(SCMMetadataStore.class);
    SCMPluginInfoBuilder builder = new SCMPluginInfoBuilder(pluginManager, scmMetadataStore);
    SCMPluginInfo pluginInfo = builder.pluginInfoFor("docker-plugin");
    assertEquals(null, pluginInfo);
}
Also used : PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) SCMPluginInfo(com.thoughtworks.go.server.ui.plugins.SCMPluginInfo) Test(org.junit.Test)

Example 2 with PluginManager

use of com.thoughtworks.go.plugin.infra.PluginManager in project gocd by gocd.

the class PluggableTaskPluginInfoBuilderTest method pluginInfoFor_ShouldReturnNullWhenPluginIsNotFound.

@Test
public void pluginInfoFor_ShouldReturnNullWhenPluginIsNotFound() throws Exception {
    PluginManager pluginManager = mock(PluginManager.class);
    PluggableTaskConfigStore packageMetadataStore = mock(PluggableTaskConfigStore.class);
    PluggableTaskPluginInfoBuilder builder = new PluggableTaskPluginInfoBuilder(pluginManager, packageMetadataStore);
    PluggableTaskPluginInfo pluginInfo = builder.pluginInfoFor("docker-plugin");
    assertEquals(null, pluginInfo);
}
Also used : PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) PluggableTaskPluginInfo(com.thoughtworks.go.server.ui.plugins.PluggableTaskPluginInfo) PluggableTaskConfigStore(com.thoughtworks.go.plugin.access.pluggabletask.PluggableTaskConfigStore) Test(org.junit.Test)

Example 3 with PluginManager

use of com.thoughtworks.go.plugin.infra.PluginManager in project gocd by gocd.

the class PluggableTaskPluginInfoBuilderTest method allPluginInfos_ShouldReturnAListOfAllPluginInfos.

@Test
public void allPluginInfos_ShouldReturnAListOfAllPluginInfos() 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);
    Collection<PluggableTaskPluginInfo> pluginInfos = builder.allPluginInfos();
    PluggableTaskPluginInfo expectedPluginInfo = new PluggableTaskPluginInfo(plugin, taskView.displayValue(), new PluggableInstanceSettings(configurations(taskConfig), new PluginView(taskView.template())));
    assertEquals(Arrays.asList(expectedPluginInfo), pluginInfos);
}
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 4 with PluginManager

use of com.thoughtworks.go.plugin.infra.PluginManager in project gocd by gocd.

the class SCMPluginInfoBuilderTest method allPluginInfos_ShouldReturnAListOfAllPluginInfos.

@Test
public void allPluginInfos_ShouldReturnAListOfAllPluginInfos() 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);
    SCMMetadataStore scmMetadataStore = mock(SCMMetadataStore.class);
    when(scmMetadataStore.getPlugins()).thenReturn(Collections.singletonList(plugin.id()));
    when(pluginManager.getPluginDescriptorFor(plugin.id())).thenReturn(plugin);
    SCMConfigurations configurations = new SCMConfigurations();
    configurations.add(new SCMConfiguration("key1"));
    configurations.add(new SCMConfiguration("key2"));
    SCMView view = new SCMView() {

        @Override
        public String displayValue() {
            return "SCM Display Value";
        }

        @Override
        public String template() {
            return "scm view template";
        }
    };
    SCMPreference scmPreference = new SCMPreference(configurations, view);
    when(scmMetadataStore.preferenceFor(plugin.id())).thenReturn(scmPreference);
    SCMPluginInfoBuilder builder = new SCMPluginInfoBuilder(pluginManager, scmMetadataStore);
    Collection<SCMPluginInfo> pluginInfos = builder.allPluginInfos();
    SCMPluginInfo expectedPluginInfo = new SCMPluginInfo(plugin, view.displayValue(), new PluggableInstanceSettings(configurations(configurations), new PluginView(view.template())));
    assertEquals(Arrays.asList(expectedPluginInfo), pluginInfos);
    assertEquals(Arrays.asList(expectedPluginInfo), pluginInfos);
}
Also used : SCMPluginInfo(com.thoughtworks.go.server.ui.plugins.SCMPluginInfo) 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) Test(org.junit.Test)

Example 5 with PluginManager

use of com.thoughtworks.go.plugin.infra.PluginManager in project gocd by gocd.

the class PackageRepositoryPluginInfoBuilderTest method allPluginInfos_ShouldReturnAListOfAllPluginInfos.

@Test
public void allPluginInfos_ShouldReturnAListOfAllPluginInfos() 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);
    PackageMetadataStore packageMetadataStore = mock(PackageMetadataStore.class);
    RepositoryMetadataStore repositoryMetadataStore = mock(RepositoryMetadataStore.class);
    when(packageMetadataStore.getPlugins()).thenReturn(Collections.singletonList(plugin.id()));
    when(pluginManager.getPluginDescriptorFor(plugin.id())).thenReturn(plugin);
    PackageConfigurations packageConfigurations = new PackageConfigurations();
    packageConfigurations.add(new com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration("key1"));
    packageConfigurations.add(new com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration("key2"));
    PackageConfigurations repoConfigurations = new PackageConfigurations();
    repoConfigurations.add(new com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration("key1"));
    repoConfigurations.add(new com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration("key2"));
    when(packageMetadataStore.getMetadata(plugin.id())).thenReturn(packageConfigurations);
    when(repositoryMetadataStore.getMetadata(plugin.id())).thenReturn(repoConfigurations);
    PackageRepositoryPluginInfoBuilder builder = new PackageRepositoryPluginInfoBuilder(pluginManager, packageMetadataStore, repositoryMetadataStore);
    Collection<PackageRepositoryPluginInfo> pluginInfos = builder.allPluginInfos();
    PackageRepositoryPluginInfo expectedPluginInfo = new PackageRepositoryPluginInfo(plugin, new PluggableInstanceSettings(configurations(packageConfigurations)), new PluggableInstanceSettings(configurations(repoConfigurations)));
    assertEquals(Arrays.asList(expectedPluginInfo), pluginInfos);
}
Also used : RepositoryMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore) PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) PackageMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.PackageMetadataStore) PackageRepositoryPluginInfo(com.thoughtworks.go.server.ui.plugins.PackageRepositoryPluginInfo) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.Test)

Aggregations

PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)27 Test (org.junit.Test)17 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)16 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)6 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)5 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)5 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)4 Test (org.junit.jupiter.api.Test)4 AuthenticationPluginRegistry (com.thoughtworks.go.plugin.access.authentication.AuthenticationPluginRegistry)3 NotificationPluginRegistry (com.thoughtworks.go.plugin.access.notification.NotificationPluginRegistry)3 PackageMetadataStore (com.thoughtworks.go.plugin.access.packagematerial.PackageMetadataStore)3 RepositoryMetadataStore (com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore)3 PluggableTaskConfigStore (com.thoughtworks.go.plugin.access.pluggabletask.PluggableTaskConfigStore)3 Task (com.thoughtworks.go.plugin.api.task.Task)3 AuthenticationPluginInfo (com.thoughtworks.go.server.ui.plugins.AuthenticationPluginInfo)3 NotificationPluginInfo (com.thoughtworks.go.server.ui.plugins.NotificationPluginInfo)3 PackageRepositoryPluginInfo (com.thoughtworks.go.server.ui.plugins.PackageRepositoryPluginInfo)3 PluggableTaskPluginInfo (com.thoughtworks.go.server.ui.plugins.PluggableTaskPluginInfo)3 SCMPluginInfo (com.thoughtworks.go.server.ui.plugins.SCMPluginInfo)3 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3