Search in sources :

Example 11 with AnalyticsPluginInfo

use of com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo in project gocd by gocd.

the class AnalyticsPluginInfoBuilderTest method shouldBuildPluginInfoWithImage.

@Test
public void shouldBuildPluginInfoWithImage() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    Image icon = new Image("content_type", "data", "hash");
    when(extension.getIcon(descriptor.id())).thenReturn(icon);
    AnalyticsPluginInfo pluginInfo = new AnalyticsPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    assertThat(pluginInfo.getImage(), is(icon));
}
Also used : AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 12 with AnalyticsPluginInfo

use of com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo in project gocd by gocd.

the class AnalyticsPluginInfoBuilder method pluginInfoFor.

public AnalyticsPluginInfo pluginInfoFor(GoPluginDescriptor descriptor) {
    Capabilities capabilities = capabilities(descriptor.id());
    PluggableInstanceSettings pluginSettingsAndView = getPluginSettingsAndView(descriptor, extension);
    Image image = image(descriptor.id());
    return new AnalyticsPluginInfo(descriptor, image, capabilities, pluginSettingsAndView);
}
Also used : AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Capabilities(com.thoughtworks.go.plugin.domain.analytics.Capabilities) Image(com.thoughtworks.go.plugin.domain.common.Image)

Example 13 with AnalyticsPluginInfo

use of com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo in project gocd by gocd.

the class AnalyticsMetadataStoreTest method shouldHandleUpdateAssetsPath.

@Test
public void shouldHandleUpdateAssetsPath() throws Exception {
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    AnalyticsPluginInfo pluginInfo = new AnalyticsPluginInfo(pluginDescriptor, null, null, null);
    when(pluginDescriptor.id()).thenReturn("plugin_id");
    store.setPluginInfo(pluginInfo);
    store.updateAssetsPath("plugin_id", "static_assets_path");
    assertThat(pluginInfo.getStaticAssetsPath(), is("static_assets_path"));
}
Also used : PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) Test(org.junit.Test)

Example 14 with AnalyticsPluginInfo

use of com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo in project gocd by gocd.

the class AnalyticsExtensionTest method shouldGetAnalytics.

@Test
public void shouldGetAnalytics() throws Exception {
    String responseBody = "{ \"view_path\": \"path/to/view\", \"data\": \"{}\" }";
    AnalyticsPluginInfo pluginInfo = new AnalyticsPluginInfo(new GoPluginDescriptor(PLUGIN_ID, null, null, null, null, false), null, null, null);
    pluginInfo.setStaticAssetsPath("/assets/root");
    metadataStore.setPluginInfo(pluginInfo);
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ANALYTICS_EXTENSION), requestArgumentCaptor.capture())).thenReturn(new DefaultGoPluginApiResponse(SUCCESS_RESPONSE_CODE, responseBody));
    AnalyticsData pipelineAnalytics = analyticsExtension.getAnalytics(PLUGIN_ID, "pipeline", "pipeline_with_highest_wait_time", Collections.singletonMap("pipeline_name", "test_pipeline"));
    String expectedRequestBody = "{" + "\"type\": \"pipeline\"," + "\"id\": \"pipeline_with_highest_wait_time\"," + " \"params\": {\"pipeline_name\": \"test_pipeline\"}}";
    assertRequest(requestArgumentCaptor.getValue(), PluginConstants.ANALYTICS_EXTENSION, "1.0", REQUEST_GET_ANALYTICS, expectedRequestBody);
    assertThat(pipelineAnalytics.getData(), is("{}"));
    assertThat(pipelineAnalytics.getViewPath(), is("path/to/view"));
    assertThat(pipelineAnalytics.getFullViewPath(), is("/assets/root/path/to/view"));
}
Also used : AnalyticsData(com.thoughtworks.go.plugin.domain.analytics.AnalyticsData) AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) DefaultGoPluginApiResponse(com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 15 with AnalyticsPluginInfo

use of com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo in project gocd by gocd.

the class AnalyticsMetadataLoaderTest method onPluginLoaded_shouldAddPluginInfoToMetadataStore.

@Test
public void onPluginLoaded_shouldAddPluginInfoToMetadataStore() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    AnalyticsMetadataLoader metadataLoader = new AnalyticsMetadataLoader(pluginManager, metadataStore, infoBuilder, extension);
    AnalyticsPluginInfo pluginInfo = new AnalyticsPluginInfo(descriptor, null, null, null);
    when(extension.canHandlePlugin(descriptor.id())).thenReturn(true);
    when(infoBuilder.pluginInfoFor(descriptor)).thenReturn(pluginInfo);
    metadataLoader.pluginLoaded(descriptor);
    verify(metadataStore).setPluginInfo(pluginInfo);
}
Also used : AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Aggregations

AnalyticsPluginInfo (com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo)18 Test (org.junit.Test)14 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)12 Capabilities (com.thoughtworks.go.plugin.domain.analytics.Capabilities)4 PluginMetadataChangeListener (com.thoughtworks.go.plugin.access.common.PluginMetadataChangeListener)2 InOrder (org.mockito.InOrder)2 PluginSettingsConfiguration (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration)1 PluginSettingsProperty (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty)1 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)1 DefaultGoPluginApiResponse (com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse)1 AnalyticsData (com.thoughtworks.go.plugin.domain.analytics.AnalyticsData)1 SupportedAnalytics (com.thoughtworks.go.plugin.domain.analytics.SupportedAnalytics)1 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)1 CombinedPluginInfo (com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo)1 Image (com.thoughtworks.go.plugin.domain.common.Image)1 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)1 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)1 Path (java.nio.file.Path)1