Search in sources :

Example 1 with AnalyticsData

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

the class AnalyticsMessageConverterV1Test method shouldBeAbleToGetAnalyticsDataFromValidJSONResponse.

@Test
public void shouldBeAbleToGetAnalyticsDataFromValidJSONResponse() {
    String response = "{\"data\":\"foo\", \"view_path\":\"bar.html\"}";
    AnalyticsData actual = converter.getAnalyticsFromResponseBody(response);
    assertEquals("foo", actual.getData());
    assertEquals("bar.html", actual.getViewPath());
}
Also used : AnalyticsData(com.thoughtworks.go.plugin.domain.analytics.AnalyticsData) Test(org.junit.Test)

Example 2 with AnalyticsData

use of com.thoughtworks.go.plugin.domain.analytics.AnalyticsData 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)

Aggregations

AnalyticsData (com.thoughtworks.go.plugin.domain.analytics.AnalyticsData)2 Test (org.junit.Test)2 DefaultGoPluginApiResponse (com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse)1 AnalyticsPluginInfo (com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo)1 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)1