@Test public void shouldTalkToPluginToGetPluginSettingsConfiguration() throws Exception { PluginSettingsConfiguration deserializedResponse = new PluginSettingsConfiguration(); when(pluginSettingsJSONMessageHandler.responseMessageForPluginSettingsConfiguration(responseBody)).thenReturn(deserializedResponse); PluginSettingsConfiguration response = scmExtension.getPluginSettingsConfiguration(PLUGIN_ID); assertRequest(requestArgumentCaptor.getValue(), SCM_EXTENSION, "1.0", PluginSettingsConstants.REQUEST_PLUGIN_SETTINGS_CONFIGURATION, null); verify(pluginSettingsJSONMessageHandler).responseMessageForPluginSettingsConfiguration(responseBody); assertSame(response, deserializedResponse); }
@Test public void shouldNotFailWhenAPluginWithMultipleExtensionsHasMoreThanOneExtensionRespondingWithSettings_BUT_OneIsValidAndOtherThrowsException() throws Exception { PluginSettingsConfiguration configuration = new PluginSettingsConfiguration(); configuration.add(new PluginSettingsProperty("k1").with(Property.REQUIRED, true).with(Property.SECURE, false)); String pluginID = "plugin-id"; GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(pluginID, "1.0", null, null, null, true); setupSettingsResponses(notificationExtension, pluginID, configuration, "view"); when(packageRepositoryExtension.canHandlePlugin(pluginID)).thenReturn(false); when(scmExtension.canHandlePlugin(pluginID)).thenReturn(true); when(scmExtension.getPluginSettingsConfiguration(pluginID)).thenThrow(new RuntimeException("Ouch!")); when(scmExtension.getPluginSettingsView(pluginID)).thenReturn("view"); metadataLoader.fetchPluginSettingsMetaData(pluginDescriptor); assertThat(PluginSettingsMetadataStore.getInstance().hasPlugin(pluginID), is(true)); verify(packageRepositoryExtension, never()).getPluginSettingsConfiguration(pluginID); verify(packageRepositoryExtension, never()).getPluginSettingsView(pluginID); }
@Before public void setUp() throws Exception { extension = mock(SCMExtension.class); SCMPropertyConfiguration value = new SCMPropertyConfiguration(); value.add(new SCMProperty("username", null).with(Property.REQUIRED, true).with(Property.SECURE, false).with(Property.PART_OF_IDENTITY, true).with(Property.DISPLAY_ORDER, 1)); value.add(new SCMProperty("password", null).with(Property.REQUIRED, true).with(Property.SECURE, true).with(Property.PART_OF_IDENTITY, false).with(Property.DISPLAY_ORDER, 2)); when(extension.getSCMConfiguration("plugin1")).thenReturn(value); when(extension.getSCMView("plugin1")).thenReturn(new SCMView() { @Override public String displayValue() { return "some scm plugin"; } @Override public String template() { return "some html"; } }); PluginSettingsConfiguration pluginSettingsConfiguration = new PluginSettingsConfiguration(); pluginSettingsConfiguration.add(new PluginSettingsProperty("k1", null).with(Property.REQUIRED, true).with(Property.SECURE, false).with(Property.DISPLAY_ORDER, 3)); when(extension.getPluginSettingsConfiguration("plugin1")).thenReturn(pluginSettingsConfiguration); when(extension.getPluginSettingsView("plugin1")).thenReturn("settings view"); }