Search in sources :

Example 6 with GoPluginExtension

use of com.thoughtworks.go.plugin.access.common.settings.GoPluginExtension in project gocd by gocd.

the class ServerInfoRequestProcessorTest method shouldRouteToTheRightExtensionBasedOnTheRequest_WhenAPluginHasMultipleExtensions.

@Test
public void shouldRouteToTheRightExtensionBasedOnTheRequest_WhenAPluginHasMultipleExtensions() throws Exception {
    GoPluginExtension anotherPluginExtension = mock(GoPluginExtension.class);
    processor = new ServerInfoRequestProcessor(processorRegistry, goConfigService, Arrays.asList(this.pluginExtension, anotherPluginExtension));
    DefaultGoApiRequest requestFromExtension1 = new DefaultGoApiRequest(GET_SERVER_ID, "1.0", new GoPluginIdentifier("extension1", Arrays.asList("1.0")));
    setupExpectationsFor(pluginExtension, pluginId, "extension1");
    setupExpectationsFor(anotherPluginExtension, pluginId, "extension2");
    processor.process(pluginDescriptor, requestFromExtension1);
    verify(pluginExtension).serverInfoJSON(pluginId, serverConfig.getServerId(), serverConfig.getSiteUrl().getUrl(), serverConfig.getSecureSiteUrl().getUrl());
    verify(anotherPluginExtension, never()).serverInfoJSON(anyString(), anyString(), anyString(), anyString());
    Mockito.reset(pluginExtension, anotherPluginExtension);
    DefaultGoApiRequest requestFromExtension2 = new DefaultGoApiRequest(GET_SERVER_ID, "1.0", new GoPluginIdentifier("extension2", Arrays.asList("1.0")));
    setupExpectationsFor(pluginExtension, pluginId, "extension1");
    setupExpectationsFor(anotherPluginExtension, pluginId, "extension2");
    processor.process(pluginDescriptor, requestFromExtension2);
    verify(pluginExtension, never()).serverInfoJSON(anyString(), anyString(), anyString(), anyString());
    verify(anotherPluginExtension).serverInfoJSON(pluginId, serverConfig.getServerId(), serverConfig.getSiteUrl().getUrl(), serverConfig.getSecureSiteUrl().getUrl());
    Mockito.reset(pluginExtension, anotherPluginExtension);
}
Also used : GoPluginExtension(com.thoughtworks.go.plugin.access.common.settings.GoPluginExtension) GoPluginIdentifier(com.thoughtworks.go.plugin.api.GoPluginIdentifier) DefaultGoApiRequest(com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest) Test(org.junit.Test)

Example 7 with GoPluginExtension

use of com.thoughtworks.go.plugin.access.common.settings.GoPluginExtension in project gocd by gocd.

the class PluginService method notifyPluginSettingsChange.

private void notifyPluginSettingsChange(PluginSettings pluginSettings) {
    String pluginId = pluginSettings.getPluginId();
    GoPluginExtension extension = findExtensionWhichCanHandleSettingsFor(pluginId);
    if (extension == null) {
        LOGGER.trace("No extension handles plugin settings for plugin: {}", pluginId);
        return;
    }
    try {
        extension.notifyPluginSettingsChange(pluginId, pluginSettings.getSettingsAsKeyValuePair());
    } catch (Exception e) {
        LOGGER.warn("Error notifying plugin - {} with settings change", pluginId, e);
    }
}
Also used : GoPluginExtension(com.thoughtworks.go.plugin.access.common.settings.GoPluginExtension)

Aggregations

GoPluginExtension (com.thoughtworks.go.plugin.access.common.settings.GoPluginExtension)7 Test (org.junit.Test)4 PluginSettingsConfiguration (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration)3 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)3 GoPluginIdentifier (com.thoughtworks.go.plugin.api.GoPluginIdentifier)2 DefaultGoApiRequest (com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest)2 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)2 PluginSettings (com.thoughtworks.go.server.domain.PluginSettings)2 NullPlugin (com.thoughtworks.go.domain.NullPlugin)1 Plugin (com.thoughtworks.go.domain.Plugin)1 Username (com.thoughtworks.go.server.domain.Username)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1