@Test public void shouldThrowAnExceptionIfScmViewReturnedByPluginIsNull() { GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false); when(extension.getSCMView("plugin1")).thenReturn(null); thrown.expectMessage("Plugin[plugin1] returned null scm view"); new SCMPluginInfoBuilder(extension).pluginInfoFor(descriptor); } }
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 shouldThrowAnExceptionIfScmConfigReturnedByPluginIsNull() { GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false); when(extension.getSCMConfiguration("plugin1")).thenReturn(null); thrown.expectMessage("Plugin[plugin1] returned null scm configuration"); new SCMPluginInfoBuilder(extension).pluginInfoFor(descriptor); }
@Test public void shouldBuildPluginInfo() throws Exception { GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false); SCMPluginInfo pluginInfo = new SCMPluginInfoBuilder(extension).pluginInfoFor(descriptor); List<PluginConfiguration> scmConfigurations = Arrays.asList( new PluginConfiguration("username", new MetadataWithPartOfIdentity(true, false, true)), new PluginConfiguration("password", new MetadataWithPartOfIdentity(true, true, false)) ); PluginView pluginView = new PluginView("some html"); List<PluginConfiguration> pluginSettings = Arrays.asList(new PluginConfiguration("k1", new Metadata(true, false))); assertThat(pluginInfo.getDescriptor(), is(descriptor)); assertThat(pluginInfo.getExtensionName(), is("scm")); assertThat(pluginInfo.getDisplayName(), is("some scm plugin")); assertThat(pluginInfo.getScmSettings(), is(new PluggableInstanceSettings(scmConfigurations, pluginView))); assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(pluginSettings, new PluginView("settings view")))); }