Search in sources :

Example 31 with GoPluginDescriptor

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

the class NotificationPluginRegistrarTest method shouldRegisterPluginOnPluginLoad.

@Test
public void shouldRegisterPluginOnPluginLoad() {
    NotificationPluginRegistrar notificationPluginRegistrar = new NotificationPluginRegistrar(pluginManager, notificationExtension, notificationPluginRegistry);
    notificationPluginRegistrar.pluginLoaded(new GoPluginDescriptor(PLUGIN_ID_1, null, null, null, null, true));
    verify(notificationPluginRegistry).registerPlugin(PLUGIN_ID_1);
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 32 with GoPluginDescriptor

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

the class NotificationPluginRegistrarTest method shouldRegisterPluginInterestsOnPluginLoad.

@Test
public void shouldRegisterPluginInterestsOnPluginLoad() {
    NotificationPluginRegistrar notificationPluginRegistrar = new NotificationPluginRegistrar(pluginManager, notificationExtension, notificationPluginRegistry);
    notificationPluginRegistrar.pluginLoaded(new GoPluginDescriptor(PLUGIN_ID_1, null, null, null, null, true));
    verify(notificationPluginRegistry).registerPluginInterests(PLUGIN_ID_1, asList(PIPELINE_STATUS, STAGE_STATUS, JOB_STATUS));
    notificationPluginRegistrar.pluginLoaded(new GoPluginDescriptor(PLUGIN_ID_2, null, null, null, null, true));
    verify(notificationPluginRegistry).registerPluginInterests(PLUGIN_ID_2, asList(PIPELINE_STATUS));
    notificationPluginRegistrar.pluginLoaded(new GoPluginDescriptor(PLUGIN_ID_3, null, null, null, null, true));
    verify(notificationPluginRegistry).registerPluginInterests(PLUGIN_ID_3, asList(STAGE_STATUS));
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 33 with GoPluginDescriptor

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

the class SCMMetadataLoaderTest method setUp.

@Before
public void setUp() throws Exception {
    pluginDescriptor = new GoPluginDescriptor("plugin-id", "1.0", null, null, null, true);
    pluginManager = mock(PluginManager.class);
    scmExtension = mock(SCMExtension.class);
    metadataLoader = new SCMMetadataLoader(scmExtension, pluginManager);
    SCMMetadataStore.getInstance().removeMetadata(pluginDescriptor.id());
}
Also used : PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Before(org.junit.Before)

Example 34 with GoPluginDescriptor

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

the class DefaultPluginManagerTest method shouldAllowRegistrationOfPluginChangeListeners.

@Test
public void shouldAllowRegistrationOfPluginChangeListeners() throws Exception {
    GoPlugginOSGiFrameworkStub frameworkStub = new GoPlugginOSGiFrameworkStub();
    PluginManager pluginManager = new DefaultPluginManager(monitor, registry, frameworkStub, jarChangeListener, null, pluginWriter, pluginValidator, systemEnvironment);
    String pluginId1 = "test-plugin-id-1";
    String pluginId2 = "test-plugin-id-2";
    GoPluginDescriptor descriptor1 = mock(GoPluginDescriptor.class);
    when(descriptor1.id()).thenReturn(pluginId1);
    GoPluginDescriptor descriptor2 = mock(GoPluginDescriptor.class);
    when(descriptor2.id()).thenReturn(pluginId2);
    final int[] pluginLoaded = new int[] { 0 };
    final int[] pluginUnloaded = new int[] { 0 };
    PluginChangeListener someInterfaceListener = new PluginChangeListener() {

        @Override
        public void pluginLoaded(GoPluginDescriptor pluginDescriptor) {
            pluginLoaded[0]++;
        }

        @Override
        public void pluginUnLoaded(GoPluginDescriptor pluginDescriptor) {
            pluginUnloaded[0]++;
        }
    };
    pluginManager.addPluginChangeListener(someInterfaceListener);
    frameworkStub.pluginChangeListener.pluginLoaded(descriptor1);
    frameworkStub.pluginChangeListener.pluginLoaded(descriptor2);
    frameworkStub.pluginChangeListener.pluginUnLoaded(descriptor1);
    frameworkStub.pluginChangeListener.pluginUnLoaded(descriptor2);
    assertThat(pluginLoaded[0], is(2));
    assertThat(pluginUnloaded[0], is(2));
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Test(org.junit.Test)

Example 35 with GoPluginDescriptor

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

the class FelixGoPluginOSGiFrameworkIntegrationTest method shouldNotifyListenersWhenPluginUnLoaded.

@Test
public void shouldNotifyListenersWhenPluginUnLoaded() {
    PluginChangeListener pluginChangeListener = mock(PluginChangeListener.class);
    pluginOSGiFramework.addPluginChangeListener(pluginChangeListener);
    GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(null, null, null, null, descriptorBundleDir, true);
    Bundle bundle = pluginOSGiFramework.loadPlugin(pluginDescriptor);
    pluginDescriptor.setBundle(bundle);
    pluginOSGiFramework.unloadPlugin(pluginDescriptor);
    verify(pluginChangeListener).pluginUnLoaded(pluginDescriptor);
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Aggregations

GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)214 Test (org.junit.jupiter.api.Test)114 Test (org.junit.Test)53 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)20 File (java.io.File)19 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)16 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)14 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)12 Capabilities (com.thoughtworks.go.plugin.domain.elastic.Capabilities)12 Before (org.junit.Before)12 AnalyticsPluginInfo (com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo)11 GoPluginBundleDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginBundleDescriptor)11 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)11 Bundle (org.osgi.framework.Bundle)10 GoPlugin (com.thoughtworks.go.plugin.api.GoPlugin)9 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)9 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)8 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)8 ArrayList (java.util.ArrayList)8 InvocationOnMock (org.mockito.invocation.InvocationOnMock)8