Search in sources :

Example 26 with GoPluginApiRequest

use of com.thoughtworks.go.plugin.api.request.GoPluginApiRequest in project gocd by gocd.

the class ArtifactExtensionTest method shouldGetCapabilities.

@Test
public void shouldGetCapabilities() {
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ARTIFACT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success("{}"));
    artifactExtension.getCapabilities(PLUGIN_ID);
    final GoPluginApiRequest request = requestArgumentCaptor.getValue();
    assertThat(request.extension(), is(ARTIFACT_EXTENSION));
    assertThat(request.requestName(), is(REQUEST_GET_CAPABILITIES));
    assertNull(request.requestBody());
}
Also used : GoPluginApiRequest(com.thoughtworks.go.plugin.api.request.GoPluginApiRequest) Test(org.junit.Test)

Example 27 with GoPluginApiRequest

use of com.thoughtworks.go.plugin.api.request.GoPluginApiRequest in project gocd by gocd.

the class ArtifactExtensionTest method shouldGetPluggableArtifactViewFromPlugin.

@Test
public void shouldGetPluggableArtifactViewFromPlugin() {
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ARTIFACT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(new DefaultGoPluginApiResponse(SUCCESS_RESPONSE_CODE, "{ \"template\": \"pluggable-artifact-view\"}"));
    String view = artifactExtension.getPublishArtifactView(PLUGIN_ID);
    final GoPluginApiRequest request = requestArgumentCaptor.getValue();
    assertThat(request.extension(), is(ARTIFACT_EXTENSION));
    assertThat(request.requestName(), is(REQUEST_PUBLISH_ARTIFACT_VIEW));
    assertNull(request.requestBody());
    assertThat(view, is("pluggable-artifact-view"));
}
Also used : GoPluginApiRequest(com.thoughtworks.go.plugin.api.request.GoPluginApiRequest) DefaultGoPluginApiResponse(com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse) Test(org.junit.Test)

Example 28 with GoPluginApiRequest

use of com.thoughtworks.go.plugin.api.request.GoPluginApiRequest in project gocd by gocd.

the class ElasticAgentExtensionTest method assertExtensionRequest.

private void assertExtensionRequest(String extensionVersion, String requestName, String requestBody) {
    final GoPluginApiRequest request = requestArgumentCaptor.getValue();
    assertThat(request.requestName(), is(requestName));
    assertThat(request.extensionVersion(), is(extensionVersion));
    assertThat(request.extension(), is(ELASTIC_AGENT_EXTENSION));
    assertThatJson(requestBody).isEqualTo(request.requestBody());
}
Also used : GoPluginApiRequest(com.thoughtworks.go.plugin.api.request.GoPluginApiRequest)

Example 29 with GoPluginApiRequest

use of com.thoughtworks.go.plugin.api.request.GoPluginApiRequest in project gocd by gocd.

the class AbstractExtensionTest method shouldNotifySettingsChangeForPluginWhichSupportsNotification.

@Test
public void shouldNotifySettingsChangeForPluginWhichSupportsNotification() throws Exception {
    String supportedVersion = "2.0";
    Map<String, String> settings = Collections.singletonMap("foo", "bar");
    ArgumentCaptor<GoPluginApiRequest> requestArgumentCaptor = ArgumentCaptor.forClass(GoPluginApiRequest.class);
    extension.registerHandler(supportedVersion, new PluginSettingsJsonMessageHandler2_0());
    when(pluginManager.resolveExtensionVersion(pluginId, extensionName, goSupportedVersions)).thenReturn(supportedVersion);
    when(pluginManager.submitTo(eq(pluginId), eq(extensionName), requestArgumentCaptor.capture())).thenReturn(new DefaultGoPluginApiResponse(SUCCESS_RESPONSE_CODE, ""));
    extension.notifyPluginSettingsChange(pluginId, settings);
    assertRequest(requestArgumentCaptor.getValue(), extensionName, supportedVersion, REQUEST_NOTIFY_PLUGIN_SETTINGS_CHANGE, "{\"foo\":\"bar\"}");
}
Also used : GoPluginApiRequest(com.thoughtworks.go.plugin.api.request.GoPluginApiRequest) PluginSettingsJsonMessageHandler2_0(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsJsonMessageHandler2_0) DefaultGoPluginApiResponse(com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse) Test(org.junit.jupiter.api.Test)

Example 30 with GoPluginApiRequest

use of com.thoughtworks.go.plugin.api.request.GoPluginApiRequest in project gocd by gocd.

the class ElasticAgentExtensionV5Test method assertExtensionRequest.

private void assertExtensionRequest(String extensionVersion, String requestName, String requestBody) {
    final GoPluginApiRequest request = requestArgumentCaptor.getValue();
    assertThat(request.requestName(), Matchers.is(requestName));
    assertThat(request.extensionVersion(), Matchers.is(extensionVersion));
    assertThat(request.extension(), Matchers.is(PluginConstants.ELASTIC_AGENT_EXTENSION));
    assertThatJson(requestBody).isEqualTo(request.requestBody());
}
Also used : GoPluginApiRequest(com.thoughtworks.go.plugin.api.request.GoPluginApiRequest)

Aggregations

GoPluginApiRequest (com.thoughtworks.go.plugin.api.request.GoPluginApiRequest)42 Test (org.junit.jupiter.api.Test)23 DefaultGoPluginApiResponse (com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse)15 Test (org.junit.Test)12 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)7 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)6 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)6 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)6 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 Answer (org.mockito.stubbing.Answer)4 ArtifactStore (com.thoughtworks.go.config.ArtifactStore)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ArtifactPlan (com.thoughtworks.go.domain.ArtifactPlan)2 PublishArtifactResponse (com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse)2 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)2 TaskConfigProperty (com.thoughtworks.go.plugin.api.task.TaskConfigProperty)2 GsonBuilder (com.google.gson.GsonBuilder)1 FetchPluggableArtifactTask (com.thoughtworks.go.config.FetchPluggableArtifactTask)1 PluginSettingsJsonMessageHandler2_0 (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsJsonMessageHandler2_0)1