Search in sources :

Example 6 with NotificationPluginInfo

use of com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo in project gocd by gocd.

the class PluginServiceTest method shouldGetPluginInfoFromTheExtensionWhichImplementsPluginSettingsIfThePluginImplementsMultipleExtensions.

@Test
public void shouldGetPluginInfoFromTheExtensionWhichImplementsPluginSettingsIfThePluginImplementsMultipleExtensions() {
    String pluginId = "plugin-id-1";
    CombinedPluginInfo combinedPluginInfo = new CombinedPluginInfo();
    PluggableInstanceSettings pluginSettings = new PluggableInstanceSettings(Arrays.asList(new PluginConfiguration("key", new Metadata(false, false))));
    GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(pluginId, "1", null, "location", new File(""), false);
    NotificationPluginInfo notificationPluginInfo = new NotificationPluginInfo(pluginDescriptor, null);
    combinedPluginInfo.add(notificationPluginInfo);
    SCMPluginInfo scmPluginInfo = new SCMPluginInfo(pluginDescriptor, "display_name", new PluggableInstanceSettings(null), pluginSettings);
    combinedPluginInfo.add(scmPluginInfo);
    PluginSettingsMetadataStore.getInstance().addMetadataFor(pluginId, PluginConstants.SCM_EXTENSION, new PluginSettingsConfiguration(), "template-1");
    when(defaultPluginInfoFinder.pluginInfoFor(pluginId)).thenReturn(combinedPluginInfo);
    when(notificationExtension.canHandlePlugin(pluginId)).thenReturn(true);
    when(scmExtension.canHandlePlugin(pluginId)).thenReturn(true);
    PluginInfo pluginInfo = pluginService.pluginInfoForExtensionThatHandlesPluginSettings(pluginId);
    assertTrue(pluginInfo instanceof SCMPluginInfo);
    assertThat(pluginInfo, is(scmPluginInfo));
}
Also used : SCMPluginInfo(com.thoughtworks.go.plugin.domain.scm.SCMPluginInfo) NotificationPluginInfo(com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) SCMPluginInfo(com.thoughtworks.go.plugin.domain.scm.SCMPluginInfo) NotificationPluginInfo(com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) PluginSettingsConfiguration(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration) File(java.io.File) Test(org.junit.Test)

Example 7 with NotificationPluginInfo

use of com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo 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 8 with NotificationPluginInfo

use of com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo in project gocd by gocd.

the class CombinedPluginInfoTest method shouldGetAllIndividualExtensionInfos.

@Test
public void shouldGetAllIndividualExtensionInfos() throws Exception {
    NotificationPluginInfo notificationPluginInfo = new NotificationPluginInfo(null, null);
    PluggableTaskPluginInfo pluggableTaskPluginInfo = new PluggableTaskPluginInfo(null, null, null);
    CombinedPluginInfo pluginInfo = new CombinedPluginInfo(asList(pluggableTaskPluginInfo, notificationPluginInfo));
    assertThat(pluginInfo.getExtensionInfos(), containsInAnyOrder(notificationPluginInfo, pluggableTaskPluginInfo));
}
Also used : NotificationPluginInfo(com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo) PluggableTaskPluginInfo(com.thoughtworks.go.plugin.domain.pluggabletask.PluggableTaskPluginInfo) Test(org.junit.Test)

Example 9 with NotificationPluginInfo

use of com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo in project gocd by gocd.

the class PluginServiceTest method shouldReturnNullForGetPluginInfoIfDoesNotImplementPluginSettings_MultipleExtensionImpl.

@Test
public void shouldReturnNullForGetPluginInfoIfDoesNotImplementPluginSettings_MultipleExtensionImpl() {
    String pluginId = "plugin-id-1";
    CombinedPluginInfo combinedPluginInfo = new CombinedPluginInfo();
    PluggableInstanceSettings pluginSettings = new PluggableInstanceSettings(Arrays.asList(new PluginConfiguration("key", new Metadata(false, false))));
    GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(pluginId, "1", null, "location", new File(""), false);
    NotificationPluginInfo notificationPluginInfo = new NotificationPluginInfo(pluginDescriptor, null);
    combinedPluginInfo.add(notificationPluginInfo);
    SCMPluginInfo scmPluginInfo = new SCMPluginInfo(pluginDescriptor, "display_name", new PluggableInstanceSettings(null), pluginSettings);
    combinedPluginInfo.add(scmPluginInfo);
    when(notificationExtension.canHandlePlugin(pluginId)).thenReturn(true);
    when(scmExtension.canHandlePlugin(pluginId)).thenReturn(true);
    assertNull(pluginService.pluginInfoForExtensionThatHandlesPluginSettings(pluginId));
}
Also used : SCMPluginInfo(com.thoughtworks.go.plugin.domain.scm.SCMPluginInfo) NotificationPluginInfo(com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) Test(org.junit.Test)

Aggregations

NotificationPluginInfo (com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo)9 Test (org.junit.Test)9 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)5 PluggableTaskPluginInfo (com.thoughtworks.go.plugin.domain.pluggabletask.PluggableTaskPluginInfo)4 SCMPluginInfo (com.thoughtworks.go.plugin.domain.scm.SCMPluginInfo)2 File (java.io.File)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 PluginSettingsConfiguration (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration)1 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)1 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)1 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)1 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)1 PluginView (com.thoughtworks.go.plugin.domain.common.PluginView)1