Search in sources :

Example 11 with PluginInfo

use of com.thoughtworks.go.server.ui.plugins.PluginInfo in project gocd by gocd.

the class PluggableTaskViewModelBuilderTest method shouldBeAbleToFetchAPluginInfoForAGivenIdWithConfigurations.

@Test
public void shouldBeAbleToFetchAPluginInfoForAGivenIdWithConfigurations() {
    when(manager.getPluginDescriptorFor("xunit.convertor")).thenReturn(xunitConvertor);
    PluginInfo pluginInfo = builder.pluginInfoFor("xunit.convertor");
    HashMap expectedMetadata = new HashMap<String, Object>() {

        {
            put("required", false);
            put("secure", false);
        }
    };
    List<PluginConfiguration> configurations = pluginInfo.getPluggableInstanceSettings().getConfigurations();
    assertThat(configurations.size(), is(2));
    PluginConfiguration configuration1 = configurations.get(0);
    assertThat(configuration1.getKey(), is("key1"));
    assertNull(configuration1.getType());
    assertThat(configuration1.getMetadata(), Is.<Map<String, Object>>is(expectedMetadata));
    PluginConfiguration configuration2 = configurations.get(1);
    assertThat(configuration2.getKey(), is("key2"));
    assertNull(configuration2.getType());
    assertThat(configuration1.getMetadata(), Is.<Map<String, Object>>is(expectedMetadata));
}
Also used : HashMap(java.util.HashMap) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Test(org.junit.Test)

Example 12 with PluginInfo

use of com.thoughtworks.go.server.ui.plugins.PluginInfo in project gocd by gocd.

the class NotificationViewModelBuilderTest method shouldBeAbleToFetchAllPluginInfos.

@Test
public void shouldBeAbleToFetchAllPluginInfos() {
    HashSet<String> pluginIds = new HashSet<>(Arrays.asList("email.notifier", "slack.notifier"));
    when(registry.getNotificationPlugins()).thenReturn(pluginIds);
    when(manager.getPluginDescriptorFor("email.notifier")).thenReturn(emailNotifier);
    when(manager.getPluginDescriptorFor("slack.notifier")).thenReturn(slackNotifier);
    List<PluginInfo> pluginInfos = builder.allPluginInfos();
    assertThat(pluginInfos.size(), is(2));
    PluginInfo pluginInfo = pluginInfos.get(0).getId().equals("email.notifier") ? pluginInfos.get(0) : pluginInfos.get(1);
    assertThat(pluginInfo.getId(), is("email.notifier"));
    assertThat(pluginInfo.getType(), is("notification"));
    assertThat(pluginInfo.getName(), is(emailNotifier.about().name()));
    assertThat(pluginInfo.getVersion(), is(emailNotifier.about().version()));
    assertNull(pluginInfo.getPluggableInstanceSettings());
}
Also used : PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with PluginInfo

use of com.thoughtworks.go.server.ui.plugins.PluginInfo in project gocd by gocd.

the class PackageViewModelBuilderTest method shouldBeAbleToFetchAPluginInfoForAGivenIdWithConfigurations.

@Test
public void shouldBeAbleToFetchAPluginInfoForAGivenIdWithConfigurations() {
    when(manager.getPluginDescriptorFor("yum.poller")).thenReturn(yumPoller);
    PluginInfo pluginInfo = builder.pluginInfoFor("yum.poller");
    HashMap expectedMetadata = new HashMap<String, Object>() {

        {
            put("required", true);
            put("secure", false);
            put("part_of_identity", true);
            put("display_order", 0);
            put("display_name", "");
        }
    };
    List<PluginConfiguration> configurations = pluginInfo.getPluggableInstanceSettings().getConfigurations();
    assertThat(configurations.size(), is(3));
    PluginConfiguration configuration2 = configurations.get(0);
    assertThat(configuration2.getKey(), is("key1"));
    assertThat(configuration2.getType(), is("package"));
    assertThat(configuration2.getMetadata(), Is.<Map<String, Object>>is(expectedMetadata));
    PluginConfiguration configuration3 = configurations.get(1);
    assertThat(configuration3.getKey(), is("key2"));
    assertThat(configuration3.getType(), is("package"));
    assertThat(configuration3.getMetadata(), Is.<Map<String, Object>>is(expectedMetadata));
    PluginConfiguration configuration1 = configurations.get(2);
    assertThat(configuration1.getKey(), is("key1"));
    assertThat(configuration1.getType(), is("repository"));
    assertThat(configuration1.getMetadata(), Is.<Map<String, Object>>is(expectedMetadata));
}
Also used : HashMap(java.util.HashMap) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Test(org.junit.Test)

Example 14 with PluginInfo

use of com.thoughtworks.go.server.ui.plugins.PluginInfo in project gocd by gocd.

the class PackageViewModelBuilderTest method shouldBeAbleToFetchAPluginInfoForAGivenId.

@Test
public void shouldBeAbleToFetchAPluginInfoForAGivenId() {
    when(manager.getPluginDescriptorFor("yum.poller")).thenReturn(yumPoller);
    PluginInfo pluginInfo = builder.pluginInfoFor("yum.poller");
    assertThat(pluginInfo.getId(), is("yum.poller"));
    assertThat(pluginInfo.getType(), is("package-repository"));
    assertThat(pluginInfo.getName(), is(yumPoller.about().name()));
    assertThat(pluginInfo.getVersion(), is(yumPoller.about().version()));
    assertNull(pluginInfo.getPluggableInstanceSettings().getView());
}
Also used : PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Test(org.junit.Test)

Example 15 with PluginInfo

use of com.thoughtworks.go.server.ui.plugins.PluginInfo in project gocd by gocd.

the class AuthenticationViewModelBuilder method allPluginInfos.

public List<PluginInfo> allPluginInfos() {
    List<PluginInfo> pluginInfos = new ArrayList<>();
    for (String pluginId : registry.getAuthenticationPlugins()) {
        GoPluginDescriptor descriptor = pluginManager.getPluginDescriptorFor(pluginId);
        pluginInfos.add(new PluginInfo(descriptor, AuthenticationExtension.EXTENSION_NAME, null, null, null));
    }
    return pluginInfos;
}
Also used : ArrayList(java.util.ArrayList) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)

Aggregations

PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)32 Test (org.junit.Test)20 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)9 PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)9 ArrayList (java.util.ArrayList)9 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)7 Image (com.thoughtworks.go.plugin.access.common.models.Image)5 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)5 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)4 HashSet (java.util.HashSet)4 HashMap (java.util.HashMap)3 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)2 SCMPreference (com.thoughtworks.go.plugin.access.scm.SCMPreference)2 PluginProfileMetadata (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata)1 PluginProfileMetadataKey (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey)1 PluginProfileMetadataKeys (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys)1