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);
}
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);
}
}
Aggregations