Search in sources :

Example 1 with PluginSettingsJsonMessageHandler2_0

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

the class AbstractExtensionTest method shouldNotifySettingsChangeForPluginWhichSupportsNotification.

@Test
public void shouldNotifySettingsChangeForPluginWhichSupportsNotification() throws Exception {
    String supportedVersion = "2.0";
    Map<String, String> settings = Collections.singletonMap("foo", "bar");
    ArgumentCaptor<GoPluginApiRequest> requestArgumentCaptor = ArgumentCaptor.forClass(GoPluginApiRequest.class);
    extension.registerHandler(supportedVersion, new PluginSettingsJsonMessageHandler2_0());
    when(pluginManager.resolveExtensionVersion(pluginId, extensionName, goSupportedVersions)).thenReturn(supportedVersion);
    when(pluginManager.submitTo(eq(pluginId), eq(extensionName), requestArgumentCaptor.capture())).thenReturn(new DefaultGoPluginApiResponse(SUCCESS_RESPONSE_CODE, ""));
    extension.notifyPluginSettingsChange(pluginId, settings);
    assertRequest(requestArgumentCaptor.getValue(), extensionName, supportedVersion, REQUEST_NOTIFY_PLUGIN_SETTINGS_CHANGE, "{\"foo\":\"bar\"}");
}
Also used : GoPluginApiRequest(com.thoughtworks.go.plugin.api.request.GoPluginApiRequest) PluginSettingsJsonMessageHandler2_0(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsJsonMessageHandler2_0) DefaultGoPluginApiResponse(com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

PluginSettingsJsonMessageHandler2_0 (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsJsonMessageHandler2_0)1 GoPluginApiRequest (com.thoughtworks.go.plugin.api.request.GoPluginApiRequest)1 DefaultGoPluginApiResponse (com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1