public String template(String pluginId) { if (isEmpty(pluginId) || !hasPreferenceFor(pluginId)) { return null; } SCMView scmView = preferenceFor(pluginId).getScmView(); if (scmView == null) { return null; } return scmView.template(); }
public SCMPluginInfo pluginInfoFor(GoPluginDescriptor descriptor) { SCMPropertyConfiguration scmConfiguration = extension.getSCMConfiguration(descriptor.id()); SCMView scmView = extension.getSCMView(descriptor.id()); PluggableInstanceSettings pluginSettingsAndView = getPluginSettingsAndView(descriptor, extension); if (scmConfiguration == null) { throw new RuntimeException(format("Plugin[%s] returned null scm configuration", descriptor.id())); } if (scmView == null) { throw new RuntimeException(format("Plugin[%s] returned null scm view", descriptor.id())); } PluggableInstanceSettings scmSettings = new PluggableInstanceSettings(scmPluginConfigurations(scmConfiguration), new PluginView(scmView.template())); return new SCMPluginInfo(descriptor, scmView.displayValue(), scmSettings, pluginSettingsAndView); }
@Test public void shouldBuildSCMViewFromResponse() { String jsonResponse = "{\"displayValue\":\"MySCMPlugin\", \"template\":\"<html>junk</html>\"}"; SCMView view = messageHandler.responseMessageForSCMView(jsonResponse); assertThat(view.displayValue(), is("MySCMPlugin")); assertThat(view.template(), is("<html>junk</html>")); }
@Test public void shouldFetchSCMMetadataForPluginsWhichImplementSCMExtensionPoint() { SCMPropertyConfiguration scmPropertyConfiguration = new SCMPropertyConfiguration(); scmPropertyConfiguration.add(new SCMProperty("k1").with(SCMProperty.REQUIRED, true).with(SCMProperty.PART_OF_IDENTITY, false)); when(scmExtension.getSCMConfiguration(pluginDescriptor.id())).thenReturn(scmPropertyConfiguration); when(scmExtension.getSCMView(pluginDescriptor.id())).thenReturn(createSCMView("display-value", "template")); metadataLoader.fetchSCMMetaData(pluginDescriptor); SCMConfigurations configurationMetadata = SCMMetadataStore.getInstance().getConfigurationMetadata(pluginDescriptor.id()); assertThat(configurationMetadata.size(), is(1)); SCMConfiguration scmConfiguration = configurationMetadata.get("k1"); assertThat(scmConfiguration.getKey(), is("k1")); assertThat(scmConfiguration.getOption(SCMProperty.REQUIRED), is(true)); assertThat(scmConfiguration.getOption(SCMProperty.PART_OF_IDENTITY), is(false)); SCMView viewMetadata = SCMMetadataStore.getInstance().getViewMetadata(pluginDescriptor.id()); assertThat(viewMetadata.displayValue(), is("display-value")); assertThat(viewMetadata.template(), is("template")); }