@Test public void shouldNotifyPluginSettingsChange() throws Exception { String supportedVersion = "3.0"; Map<String, String> settings = Collections.singletonMap("foo", "bar"); ArgumentCaptor<GoPluginApiRequest> requestArgumentCaptor = ArgumentCaptor.forClass(GoPluginApiRequest.class); when(pluginManager.resolveExtensionVersion(eq("pluginId"), eq(NOTIFICATION_EXTENSION), anyList())).thenReturn(supportedVersion); when(pluginManager.isPluginOfType(NOTIFICATION_EXTENSION, "pluginId")).thenReturn(true); when(pluginManager.submitTo(eq("pluginId"), eq(NOTIFICATION_EXTENSION), requestArgumentCaptor.capture())).thenReturn(new DefaultGoPluginApiResponse(SUCCESS_RESPONSE_CODE, "")); NotificationExtension extension = new NotificationExtension(pluginManager); extension.notifyPluginSettingsChange("pluginId", settings); assertRequest(requestArgumentCaptor.getValue(), NOTIFICATION_EXTENSION, supportedVersion, REQUEST_NOTIFY_PLUGIN_SETTINGS_CHANGE, "{\"foo\":\"bar\"}"); }
@Test public void shouldNotifyPluginSettingsChange() throws Exception { String supportedVersion = "4.0"; Map<String, String> settings = Collections.singletonMap("foo", "bar"); ArgumentCaptor<GoPluginApiRequest> requestArgumentCaptor = ArgumentCaptor.forClass(GoPluginApiRequest.class); when(pluginManager.resolveExtensionVersion(eq("pluginId"), eq(NOTIFICATION_EXTENSION), anyList())).thenReturn(supportedVersion); when(pluginManager.isPluginOfType(NOTIFICATION_EXTENSION, "pluginId")).thenReturn(true); when(pluginManager.submitTo(eq("pluginId"), eq(NOTIFICATION_EXTENSION), requestArgumentCaptor.capture())).thenReturn(new DefaultGoPluginApiResponse(SUCCESS_RESPONSE_CODE, "")); NotificationExtension extension = new NotificationExtension(pluginManager); extension.notifyPluginSettingsChange("pluginId", settings); assertRequest(requestArgumentCaptor.getValue(), NOTIFICATION_EXTENSION, supportedVersion, REQUEST_NOTIFY_PLUGIN_SETTINGS_CHANGE, "{\"foo\":\"bar\"}"); }
@Before public void setUp() throws Exception { initMocks(this); notificationExtension = new NotificationExtension(pluginManager); notificationExtension.getPluginSettingsMessageHandlerMap().put(apiVersion(), pluginSettingsJSONMessageHandler()); notificationExtension.getMessageHandlerMap().put(apiVersion(), jsonMessageHandler()); pluginSettingsConfiguration = new PluginSettingsConfiguration(); requestArgumentCaptor = ArgumentCaptor.forClass(GoPluginApiRequest.class); when(pluginManager.resolveExtensionVersion(PLUGIN_ID, NOTIFICATION_EXTENSION, NotificationExtension.goSupportedVersions)).thenReturn(apiVersion()); when(pluginManager.isPluginOfType(NOTIFICATION_EXTENSION, PLUGIN_ID)).thenReturn(true); when(pluginManager.submitTo(eq(PLUGIN_ID), eq(NOTIFICATION_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(RESPONSE_BODY)); }