Search in sources :

Example 1 with GoPluginApiRequest

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

the class ElasticAgentExtensionV1Test method assertExtensionRequest.

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

Example 2 with GoPluginApiRequest

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

the class ElasticAgentExtensionV2Test method assertExtensionRequest.

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

Example 3 with GoPluginApiRequest

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

the class ArtifactExtensionTest method shouldGetFetchArtifactViewFromPlugin.

@Test
public void shouldGetFetchArtifactViewFromPlugin() {
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ARTIFACT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(new DefaultGoPluginApiResponse(SUCCESS_RESPONSE_CODE, "{ \"template\": \"fetch-artifact-view\"}"));
    String view = artifactExtension.getFetchArtifactView(PLUGIN_ID);
    final GoPluginApiRequest request = requestArgumentCaptor.getValue();
    assertThat(request.extension(), is(ARTIFACT_EXTENSION));
    assertThat(request.requestName(), is(REQUEST_FETCH_ARTIFACT_VIEW));
    assertNull(request.requestBody());
    assertThat(view, is("fetch-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 4 with GoPluginApiRequest

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

the class ArtifactExtensionTest method shouldGetArtifactStoreMetadataFromPlugin.

@Test
public void shouldGetArtifactStoreMetadataFromPlugin() {
    String responseBody = "[{\"key\":\"BUCKET_NAME\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"AWS_ACCESS_KEY\",\"metadata\":{\"required\":true,\"secure\":true}}]";
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ARTIFACT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
    final List<PluginConfiguration> response = artifactExtension.getArtifactStoreMetadata(PLUGIN_ID);
    final GoPluginApiRequest request = requestArgumentCaptor.getValue();
    assertThat(request.extension(), is(ARTIFACT_EXTENSION));
    assertThat(request.requestName(), is(REQUEST_STORE_CONFIG_METADATA));
    assertNull(request.requestBody());
    assertThat(response.size(), is(2));
    assertThat(response, containsInAnyOrder(new PluginConfiguration("BUCKET_NAME", new Metadata(true, false)), new PluginConfiguration("AWS_ACCESS_KEY", new Metadata(true, true))));
}
Also used : GoPluginApiRequest(com.thoughtworks.go.plugin.api.request.GoPluginApiRequest) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Test(org.junit.Test)

Example 5 with GoPluginApiRequest

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

the class ArtifactExtensionTest method shouldGetPluggableArtifactMetadataFromPlugin.

@Test
public void shouldGetPluggableArtifactMetadataFromPlugin() {
    String responseBody = "[{\"key\":\"FILENAME\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"VERSION\",\"metadata\":{\"required\":true,\"secure\":true}}]";
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ARTIFACT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
    final List<PluginConfiguration> response = artifactExtension.getPublishArtifactMetadata(PLUGIN_ID);
    final GoPluginApiRequest request = requestArgumentCaptor.getValue();
    assertThat(request.extension(), is(ARTIFACT_EXTENSION));
    assertThat(request.requestName(), is(REQUEST_PUBLISH_ARTIFACT_METADATA));
    assertNull(request.requestBody());
    assertThat(response.size(), is(2));
    assertThat(response, containsInAnyOrder(new PluginConfiguration("FILENAME", new Metadata(true, false)), new PluginConfiguration("VERSION", new Metadata(true, true))));
}
Also used : GoPluginApiRequest(com.thoughtworks.go.plugin.api.request.GoPluginApiRequest) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Test(org.junit.Test)

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