Search in sources :

Example 16 with PluginView

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

the class ElasticAgentPluginInfoBuilderTest method pluginInfoFor_ShouldProvideEPluginInfoForAPlugin.

@Test
public void pluginInfoFor_ShouldProvideEPluginInfoForAPlugin() throws Exception {
    GoPluginDescriptor.About about = new GoPluginDescriptor.About("Plugin Descriptor Validator", "1.0.1", "12.4", "Validates its own plugin descriptor", new GoPluginDescriptor.Vendor("ThoughtWorks Go Team", "www.thoughtworks.com"), Arrays.asList("Linux", "Windows", "Mac OS X"));
    GoPluginDescriptor plugin = new GoPluginDescriptor("docker-plugin", "1.0", about, null, null, false);
    PluginProfileMetadataKeys metadataKeys = new PluginProfileMetadataKeys(Arrays.asList(new PluginProfileMetadataKey("password", new PluginProfileMetadata(true, true))));
    Image image = new Image("image/png", Base64.getEncoder().encodeToString("some-base64-encoded-data".getBytes(UTF_8)));
    ;
    String view = "some html view";
    ElasticPluginConfigMetadataStore store = mock(ElasticPluginConfigMetadataStore.class);
    when(store.find("docker-plugin")).thenReturn(plugin);
    when(store.getProfileMetadata(plugin)).thenReturn(metadataKeys);
    when(store.getIcon(plugin)).thenReturn(image);
    when(store.getProfileView(plugin)).thenReturn(view);
    ElasticAgentPluginInfoBuilder builder = new ElasticAgentPluginInfoBuilder(store);
    ElasticPluginInfo pluginInfo = builder.pluginInfoFor(plugin.id());
    PluggableInstanceSettings settings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(metadataKeys), new PluginView(view));
    assertEquals(new ElasticPluginInfo(plugin, settings, image), pluginInfo);
}
Also used : PluginProfileMetadataKeys(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys) ElasticPluginInfo(com.thoughtworks.go.server.ui.plugins.ElasticPluginInfo) Image(com.thoughtworks.go.plugin.access.common.models.Image) ElasticPluginConfigMetadataStore(com.thoughtworks.go.plugin.access.elastic.ElasticPluginConfigMetadataStore) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginProfileMetadataKey(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey) PluginProfileMetadata(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata) Test(org.junit.Test)

Example 17 with PluginView

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

the class ElasticAgentViewViewModelBuilderTest method shouldBeAbleToFetchPluginInfoForSinglePlugin.

@Test
public void shouldBeAbleToFetchPluginInfoForSinglePlugin() throws Exception {
    when(elasticPluginConfigMetadataStore.find(dockerPlugin.id())).thenReturn(dockerPlugin);
    Image image = new Image("image/png", Base64.getEncoder().encodeToString("some-base64-encoded-data".getBytes(UTF_8)));
    ;
    when(elasticPluginConfigMetadataStore.getIcon(dockerPlugin)).thenReturn(image);
    when(elasticPluginConfigMetadataStore.getProfileView(dockerPlugin)).thenReturn("html");
    PluginProfileMetadataKey pluginProfileMetadataKey = new PluginProfileMetadataKey("foo", new PluginProfileMetadata(true, true));
    PluginProfileMetadataKeys pluginProfileMetadataKeys = new PluginProfileMetadataKeys(Collections.singletonList(pluginProfileMetadataKey));
    when(elasticPluginConfigMetadataStore.getProfileMetadata(dockerPlugin)).thenReturn(pluginProfileMetadataKeys);
    PluginInfo pluginInfo = builder.pluginInfoFor(dockerPlugin.id());
    assertThat(pluginInfo.getImage(), is(image));
    assertThat(pluginInfo.getPluggableInstanceSettings().getView(), is(new PluginView("html")));
    Map<String, Object> metadata = new HashMap<>();
    metadata.put(REQUIRED_OPTION, true);
    metadata.put(SECURE_OPTION, true);
    assertEquals(pluginInfo.getPluggableInstanceSettings().getConfigurations(), Arrays.asList(new PluginConfiguration("foo", metadata, null)));
}
Also used : PluginProfileMetadataKeys(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) PluginProfileMetadataKey(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey) Image(com.thoughtworks.go.plugin.access.common.models.Image) PluginProfileMetadata(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata) Test(org.junit.Test)

Example 18 with PluginView

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

the class SCMViewModelBuilderTest method shouldBeAbleToFetchAPluginInfoForAGivenIdWithViewTemplate.

@Test
public void shouldBeAbleToFetchAPluginInfoForAGivenIdWithViewTemplate() {
    when(manager.getPluginDescriptorFor("github.pr")).thenReturn(githubPR);
    PluginInfo pluginInfo = builder.pluginInfoFor("github.pr");
    PluginView view = pluginInfo.getPluggableInstanceSettings().getView();
    assertThat(view.getTemplate(), is("scm view template"));
}
Also used : PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Test(org.junit.Test)

Aggregations

PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)18 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)15 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)11 Test (org.junit.Test)11 Image (com.thoughtworks.go.plugin.access.common.models.Image)9 PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)8 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)7 PluginProfileMetadata (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata)5 PluginProfileMetadataKey (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey)5 PluginProfileMetadataKeys (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys)5 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)4 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)4 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)4 AuthorizationPluginInfo (com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo)3 ElasticPluginInfo (com.thoughtworks.go.server.ui.plugins.ElasticPluginInfo)3 PluggableTaskPluginInfo (com.thoughtworks.go.server.ui.plugins.PluggableTaskPluginInfo)3 AuthorizationPluginConfigMetadataStore (com.thoughtworks.go.plugin.access.authorization.AuthorizationPluginConfigMetadataStore)2 ElasticPluginConfigMetadataStore (com.thoughtworks.go.plugin.access.elastic.ElasticPluginConfigMetadataStore)2 JsonBasedPluggableTask (com.thoughtworks.go.plugin.access.pluggabletask.JsonBasedPluggableTask)2 PluggableTaskConfigStore (com.thoughtworks.go.plugin.access.pluggabletask.PluggableTaskConfigStore)2