use of com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse in project gocd by gocd.
the class ArtifactExtensionTestBase 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"));
}
use of com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse in project gocd by gocd.
the class ArtifactExtensionTestBase method shouldValidateArtifactStoreConfig.
@Test
public void shouldValidateArtifactStoreConfig() {
String responseBody = "[{\"message\":\"ACCESS_KEY must not be blank.\",\"key\":\"ACCESS_KEY\"}]";
when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ARTIFACT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(new DefaultGoPluginApiResponse(SUCCESS_RESPONSE_CODE, responseBody));
ValidationResult validationResult = artifactExtension.validateArtifactStoreConfig(PLUGIN_ID, Collections.singletonMap("ACCESS_KEY", ""));
final GoPluginApiRequest request = requestArgumentCaptor.getValue();
assertThat(request.extension(), is(ARTIFACT_EXTENSION));
assertThat(request.requestName(), is(REQUEST_STORE_CONFIG_VALIDATE));
assertThat(request.requestBody(), is("{\"ACCESS_KEY\":\"\"}"));
assertThat(validationResult.isSuccessful(), is(false));
assertThat(validationResult.getErrors(), containsInAnyOrder(new ValidationError("ACCESS_KEY", "ACCESS_KEY must not be blank.")));
}
use of com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse in project gocd by gocd.
the class ArtifactExtensionTestBase method shouldValidatePluggableArtifactConfig.
@Test
public void shouldValidatePluggableArtifactConfig() {
String responseBody = "[{\"message\":\"Filename must not be blank.\",\"key\":\"Filename\"}]";
when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ARTIFACT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(new DefaultGoPluginApiResponse(SUCCESS_RESPONSE_CODE, responseBody));
ValidationResult validationResult = artifactExtension.validatePluggableArtifactConfig(PLUGIN_ID, Collections.singletonMap("Filename", ""));
final GoPluginApiRequest request = requestArgumentCaptor.getValue();
assertThat(request.extension(), is(ARTIFACT_EXTENSION));
assertThat(request.requestName(), is(REQUEST_PUBLISH_ARTIFACT_VALIDATE));
assertThat(request.requestBody(), is("{\"Filename\":\"\"}"));
assertThat(validationResult.isSuccessful(), is(false));
assertThat(validationResult.getErrors(), containsInAnyOrder(new ValidationError("Filename", "Filename must not be blank.")));
}
Aggregations