Search in sources :

Example 66 with GoPluginDescriptor

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

the class ElasticAgentMetadataLoaderTest method onPluginUnloded_shouldRemoveTheCorrespondingPluginInfoFromStore.

@Test
public void onPluginUnloded_shouldRemoveTheCorrespondingPluginInfoFromStore() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    ElasticAgentMetadataLoader metadataLoader = new ElasticAgentMetadataLoader(pluginManager, metadataStore, infoBuilder, extension);
    ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(descriptor, null, null, null, null);
    metadataStore.setPluginInfo(pluginInfo);
    metadataLoader.pluginUnLoaded(descriptor);
    verify(metadataStore).remove(descriptor.id());
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 67 with GoPluginDescriptor

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

the class AnalyticsMetadataLoaderTest method onPluginLoaded_shouldIgnoreNonAnalyticsPlugins.

@Test
public void onPluginLoaded_shouldIgnoreNonAnalyticsPlugins() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    AnalyticsMetadataLoader metadataLoader = new AnalyticsMetadataLoader(pluginManager, metadataStore, infoBuilder, extension);
    when(extension.canHandlePlugin(descriptor.id())).thenReturn(false);
    metadataLoader.pluginLoaded(descriptor);
    verifyZeroInteractions(infoBuilder);
    verifyZeroInteractions(metadataStore);
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 68 with GoPluginDescriptor

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

the class AnalyticsMetadataLoaderTest method onPluginUnLoaded_shouldNotifyPluginMetadataLoadListeners.

@Test
public void onPluginUnLoaded_shouldNotifyPluginMetadataLoadListeners() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    AnalyticsMetadataLoader metadataLoader = new AnalyticsMetadataLoader(pluginManager, metadataStore, infoBuilder, extension);
    AnalyticsPluginInfo pluginInfo = new AnalyticsPluginInfo(descriptor, null, null, null);
    PluginMetadataChangeListener pluginMetadataChangeListener = mock(PluginMetadataChangeListener.class);
    when(extension.canHandlePlugin(descriptor.id())).thenReturn(true);
    metadataStore.setPluginInfo(pluginInfo);
    metadataLoader.registerListeners(pluginMetadataChangeListener);
    metadataLoader.pluginUnLoaded(descriptor);
    InOrder inOrder = inOrder(metadataStore, pluginMetadataChangeListener);
    inOrder.verify(metadataStore).remove(descriptor.id());
    inOrder.verify(pluginMetadataChangeListener).onPluginMetadataRemove(descriptor.id());
}
Also used : AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) PluginMetadataChangeListener(com.thoughtworks.go.plugin.access.common.PluginMetadataChangeListener) InOrder(org.mockito.InOrder) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 69 with GoPluginDescriptor

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

the class AnalyticsMetadataLoaderTest method onPluginLoad_shouldNotifyPluginMetadataLoadListeners.

@Test
public void onPluginLoad_shouldNotifyPluginMetadataLoadListeners() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    AnalyticsMetadataLoader metadataLoader = new AnalyticsMetadataLoader(pluginManager, metadataStore, infoBuilder, extension);
    PluginMetadataChangeListener pluginMetadataChangeListener = mock(PluginMetadataChangeListener.class);
    AnalyticsPluginInfo pluginInfo = new AnalyticsPluginInfo(descriptor, null, null, null);
    when(extension.canHandlePlugin(descriptor.id())).thenReturn(true);
    when(infoBuilder.pluginInfoFor(descriptor)).thenReturn(pluginInfo);
    metadataLoader.registerListeners(pluginMetadataChangeListener);
    metadataLoader.pluginLoaded(descriptor);
    InOrder inOrder = inOrder(metadataStore, pluginMetadataChangeListener);
    inOrder.verify(metadataStore).setPluginInfo(pluginInfo);
    inOrder.verify(pluginMetadataChangeListener).onPluginMetadataCreate(descriptor.id());
}
Also used : PluginMetadataChangeListener(com.thoughtworks.go.plugin.access.common.PluginMetadataChangeListener) AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) InOrder(org.mockito.InOrder) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 70 with GoPluginDescriptor

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

the class AnalyticsPluginInfoBuilderTest method shouldBuildPluginInfoWithPluginSettingsConfiguration.

@Test
public void shouldBuildPluginInfoWithPluginSettingsConfiguration() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    PluginSettingsConfiguration value = new PluginSettingsConfiguration();
    value.add(new PluginSettingsProperty("username", null).with(Property.REQUIRED, true).with(Property.SECURE, false));
    value.add(new PluginSettingsProperty("password", null).with(Property.REQUIRED, true).with(Property.SECURE, true));
    stub(extension.getPluginSettingsConfiguration("plugin1")).toReturn(value);
    stub(extension.getPluginSettingsView("plugin1")).toReturn("some-html");
    AnalyticsPluginInfo pluginInfo = new AnalyticsPluginInfoBuilder(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("analytics"));
    assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(pluginConfigurations, pluginView)));
}
Also used : AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginSettingsConfiguration(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration) PluginSettingsProperty(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty) Test(org.junit.Test)

Aggregations

GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)197 Test (org.junit.Test)155 File (java.io.File)17 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)16 TinyBundle (org.ops4j.pax.tinybundles.core.TinyBundle)15 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)14 Before (org.junit.Before)14 AnalyticsPluginInfo (com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo)12 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)12 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)11 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)11 GoPlugin (com.thoughtworks.go.plugin.api.GoPlugin)10 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)9 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)9 InvocationOnMock (org.mockito.invocation.InvocationOnMock)9 Answer (org.mockito.stubbing.Answer)9 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)8 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)8 ArrayList (java.util.ArrayList)8 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)7