Search in sources :

Example 1 with ElasticPluginConfigMetadataStore

use of com.thoughtworks.go.plugin.access.elastic.ElasticPluginConfigMetadataStore in project gocd by gocd.

the class ElasticAgentPluginInfoBuilderTest method allPluginInfos_ShouldReturnAListOfAllPluginInfos.

@Test
public void allPluginInfos_ShouldReturnAListOfAllPluginInfos() 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.getPlugins()).thenReturn(Arrays.asList(plugin));
    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);
    Collection<ElasticPluginInfo> pluginInfos = builder.allPluginInfos();
    PluggableInstanceSettings settings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(metadataKeys), new PluginView(view));
    assertEquals(Arrays.asList(new ElasticPluginInfo(plugin, settings, image)), pluginInfos);
}
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 2 with ElasticPluginConfigMetadataStore

use of com.thoughtworks.go.plugin.access.elastic.ElasticPluginConfigMetadataStore 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 3 with ElasticPluginConfigMetadataStore

use of com.thoughtworks.go.plugin.access.elastic.ElasticPluginConfigMetadataStore in project gocd by gocd.

the class ElasticAgentPluginInfoBuilderTest method pluginInfoFor_ShouldReturnNullWhenPluginIsNotFound.

@Test
public void pluginInfoFor_ShouldReturnNullWhenPluginIsNotFound() throws Exception {
    ElasticPluginConfigMetadataStore store = mock(ElasticPluginConfigMetadataStore.class);
    when(store.find("docker-plugin")).thenReturn(null);
    ElasticAgentPluginInfoBuilder builder = new ElasticAgentPluginInfoBuilder(store);
    ElasticPluginInfo pluginInfo = builder.pluginInfoFor("docker-plugin");
    assertEquals(null, pluginInfo);
}
Also used : ElasticPluginConfigMetadataStore(com.thoughtworks.go.plugin.access.elastic.ElasticPluginConfigMetadataStore) ElasticPluginInfo(com.thoughtworks.go.server.ui.plugins.ElasticPluginInfo) Test(org.junit.Test)

Aggregations

ElasticPluginConfigMetadataStore (com.thoughtworks.go.plugin.access.elastic.ElasticPluginConfigMetadataStore)3 ElasticPluginInfo (com.thoughtworks.go.server.ui.plugins.ElasticPluginInfo)3 Test (org.junit.Test)3 Image (com.thoughtworks.go.plugin.access.common.models.Image)2 PluginProfileMetadata (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata)2 PluginProfileMetadataKey (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey)2 PluginProfileMetadataKeys (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys)2 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)2 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)2 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)2