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());
}
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);
}
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());
}
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());
}
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)));
}
Aggregations