use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration in project gocd by gocd.
the class AuthenticationExtensionTest method shouldTalkToPluginToGetPluginSettingsConfiguration.
@Test
public void shouldTalkToPluginToGetPluginSettingsConfiguration() throws Exception {
PluginSettingsConfiguration deserializedResponse = new PluginSettingsConfiguration();
when(pluginSettingsJSONMessageHandler.responseMessageForPluginSettingsConfiguration(RESPONSE_BODY)).thenReturn(deserializedResponse);
PluginSettingsConfiguration response = authenticationExtension.getPluginSettingsConfiguration(PLUGIN_ID);
assertRequest(requestArgumentCaptor.getValue(), AuthenticationExtension.EXTENSION_NAME, "1.0", PluginSettingsConstants.REQUEST_PLUGIN_SETTINGS_CONFIGURATION, null);
verify(pluginSettingsJSONMessageHandler).responseMessageForPluginSettingsConfiguration(RESPONSE_BODY);
assertSame(response, deserializedResponse);
}
use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration in project gocd by gocd.
the class PluginService method validatePluginSettingsFor.
public void validatePluginSettingsFor(PluginSettings pluginSettings) {
String pluginId = pluginSettings.getPluginId();
PluginSettingsConfiguration configuration = pluginSettings.toPluginSettingsConfiguration();
ValidationResult result = null;
boolean anyExtensionSupportsPluginId = false;
for (GoPluginExtension extension : extensions) {
if (extension.canHandlePlugin(pluginId)) {
result = extension.validatePluginSettings(pluginId, configuration);
anyExtensionSupportsPluginId = true;
}
}
if (!anyExtensionSupportsPluginId)
throw new IllegalArgumentException(String.format("Plugin '%s' is not supported by any extension point", pluginId));
if (!result.isSuccessful()) {
for (ValidationError error : result.getErrors()) {
pluginSettings.populateErrorMessageFor(error.getKey(), error.getMessage());
}
}
}
use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration in project gocd by gocd.
the class TaskExtensionTest method shouldTalkToPluginToGetPluginSettingsConfiguration.
@Test
public void shouldTalkToPluginToGetPluginSettingsConfiguration() throws Exception {
extension.registerHandler("1.0", pluginSettingsJSONMessageHandler);
extension.messageHandlerMap.put("1.0", jsonMessageHandler);
String responseBody = "expected-response";
PluginSettingsConfiguration deserializedResponse = new PluginSettingsConfiguration();
when(pluginSettingsJSONMessageHandler.responseMessageForPluginSettingsConfiguration(responseBody)).thenReturn(deserializedResponse);
when(pluginManager.isPluginOfType(TaskExtension.TASK_EXTENSION, pluginId)).thenReturn(true);
when(pluginManager.submitTo(eq(pluginId), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
PluginSettingsConfiguration response = extension.getPluginSettingsConfiguration(pluginId);
assertRequest(requestArgumentCaptor.getValue(), TaskExtension.TASK_EXTENSION, "1.0", PluginSettingsConstants.REQUEST_PLUGIN_SETTINGS_CONFIGURATION, null);
verify(pluginSettingsJSONMessageHandler).responseMessageForPluginSettingsConfiguration(responseBody);
assertSame(response, deserializedResponse);
}
use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration in project gocd by gocd.
the class PackageRepositoryExtensionTest method shouldTalkToPluginToGetPluginSettingsConfiguration.
@Test
public void shouldTalkToPluginToGetPluginSettingsConfiguration() throws Exception {
extension.registerHandler("1.0", pluginSettingsJSONMessageHandler);
extension.messageHandlerMap.put("1.0", jsonMessageHandler);
String responseBody = "expected-response";
PluginSettingsConfiguration deserializedResponse = new PluginSettingsConfiguration();
when(pluginSettingsJSONMessageHandler.responseMessageForPluginSettingsConfiguration(responseBody)).thenReturn(deserializedResponse);
when(pluginManager.isPluginOfType(EXTENSION_NAME, PLUGIN_ID)).thenReturn(true);
when(pluginManager.submitTo(eq(PLUGIN_ID), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
PluginSettingsConfiguration response = extension.getPluginSettingsConfiguration(PLUGIN_ID);
assertRequest(requestArgumentCaptor.getValue(), EXTENSION_NAME, "1.0", PluginSettingsConstants.REQUEST_PLUGIN_SETTINGS_CONFIGURATION, null);
verify(pluginSettingsJSONMessageHandler).responseMessageForPluginSettingsConfiguration(responseBody);
assertSame(response, deserializedResponse);
}
use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration in project gocd by gocd.
the class SCMExtensionTest method shouldTalkToPluginToGetPluginSettingsConfiguration.
@Test
public void shouldTalkToPluginToGetPluginSettingsConfiguration() throws Exception {
PluginSettingsConfiguration deserializedResponse = new PluginSettingsConfiguration();
when(pluginSettingsJSONMessageHandler.responseMessageForPluginSettingsConfiguration(responseBody)).thenReturn(deserializedResponse);
PluginSettingsConfiguration response = scmExtension.getPluginSettingsConfiguration(PLUGIN_ID);
assertRequest(requestArgumentCaptor.getValue(), SCMExtension.EXTENSION_NAME, "1.0", PluginSettingsConstants.REQUEST_PLUGIN_SETTINGS_CONFIGURATION, null);
verify(pluginSettingsJSONMessageHandler).responseMessageForPluginSettingsConfiguration(responseBody);
assertSame(response, deserializedResponse);
}
Aggregations