@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(PLUGGABLE_TASK_EXTENSION, pluginId)).thenReturn(true); when(pluginManager.submitTo(eq(pluginId), eq(PLUGGABLE_TASK_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody)); PluginSettingsConfiguration response = extension.getPluginSettingsConfiguration(pluginId); assertRequest(requestArgumentCaptor.getValue(), PLUGGABLE_TASK_EXTENSION, "1.0", PluginSettingsConstants.REQUEST_PLUGIN_SETTINGS_CONFIGURATION, null); verify(pluginSettingsJSONMessageHandler).responseMessageForPluginSettingsConfiguration(responseBody); assertSame(response, deserializedResponse); }
@Test public void shouldNotFetchPluginSettingsMetadataForTaskPlugin() throws Exception { PluginSettingsConfiguration configuration = new PluginSettingsConfiguration(); configuration.add(new PluginSettingsProperty("k1").with(Property.REQUIRED, true).with(Property.SECURE, false)); GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(UUID.randomUUID().toString(), "1.0", null, null, null, true); setupSettingsResponses(taskExtension, pluginDescriptor.id(), configuration, "template"); metadataLoader.fetchPluginSettingsMetaData(pluginDescriptor); verify(taskExtension, never()).getPluginSettingsConfiguration(pluginDescriptor.id()); verify(taskExtension, never()).getPluginSettingsView(pluginDescriptor.id()); assertThat(PluginSettingsMetadataStore.getInstance().configuration(pluginDescriptor.id()), is(nullValue())); }