@Override public String getTypeForDisplay() { String type = scmConfig == null ? null : SCMMetadataStore.getInstance().displayValue(scmConfig.getPluginConfiguration().getId()); return type == null ? "SCM" : type; }
@Override public String getTypeForDisplay() { String type = scmConfig == null ? null : SCMMetadataStore.getInstance().displayValue(scmConfig.getPluginConfiguration().getId()); return type == null ? "SCM" : type; }
public String getConfigForDisplay() { String pluginId = getPluginId(); SCMMetadataStore metadataStore = SCMMetadataStore.getInstance(); List<ConfigurationProperty> propertiesToBeUsedForDisplay = ConfigurationDisplayUtil.getConfigurationPropertiesToBeUsedForDisplay(metadataStore, pluginId, configuration); String prefix = metadataStore.hasPlugin(pluginId) ? "" : "WARNING! Plugin missing. "; return prefix + configuration.forDisplay(propertiesToBeUsedForDisplay); }
@PostConstruct public void applyPluginMetadata() { String pluginId = getPluginId(); for (ConfigurationProperty configurationProperty : configuration) { SCMMetadataStore scmMetadataStore = SCMMetadataStore.getInstance(); if (scmMetadataStore.getConfigurationMetadata(pluginId) != null) { boolean isSecureProperty = scmMetadataStore.hasOption(pluginId, configurationProperty.getConfigurationKey().getName(), SCMConfiguration.SECURE); configurationProperty.handleSecureValueConfiguration(isSecureProperty); } } }
@After public void tearDown() throws Exception { SCMMetadataStore.getInstance().clear(); } }
@Before public void setUp() { SCMMetadataStore.getInstance().clear(); }
@Before public void setUp() throws Exception { SCMMetadataStore.getInstance().clear(); }
@After public void tearDown() { SCMMetadataStore.getInstance().clear(); }
@Test public void shouldBeAbleToCheckIfPluginExists() throws Exception { SCMConfigurations scmConfigurations = new SCMConfigurations(); SCMView scmView = createSCMView(null, null); SCMMetadataStore.getInstance().addMetadataFor("plugin-id", scmConfigurations, scmView); assertThat(SCMMetadataStore.getInstance().hasPlugin("plugin-id"), is(true)); assertThat(SCMMetadataStore.getInstance().hasPlugin("some-plugin-which-does-not-exist"), is(false)); }
@Test public void shouldRemoveMetadataOnPluginUnLoadedCallback() throws Exception { SCMMetadataStore.getInstance().addMetadataFor(pluginDescriptor.id(), new SCMConfigurations(), createSCMView(null, null)); when(scmExtension.canHandlePlugin(pluginDescriptor.id())).thenReturn(true); metadataLoader.pluginUnLoaded(pluginDescriptor); assertThat(SCMMetadataStore.getInstance().getConfigurationMetadata(pluginDescriptor.id()), is(nullValue())); assertThat(SCMMetadataStore.getInstance().getViewMetadata(pluginDescriptor.id()), is(nullValue())); }
@Test public void shouldThrowExceptionWhenNullSCMConfigurationReturned() { when(scmExtension.getSCMConfiguration(pluginDescriptor.id())).thenReturn(null); try { metadataLoader.fetchSCMMetaData(pluginDescriptor); } catch (Exception e) { assertThat(e.getMessage(), is("Plugin[plugin-id] returned null SCM configuration")); } assertThat(SCMMetadataStore.getInstance().getConfigurationMetadata(pluginDescriptor.id()), nullValue()); }
@Before public void setUp() throws IOException { pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig("scm-id"); SCMMetadataStore.getInstance().clear(); }
@Test public void shouldCorrectlyGetTypeDisplay() { assertThat(pluggableSCMMaterialConfig.getTypeForDisplay(), is("SCM")); pluggableSCMMaterialConfig.setSCMConfig(SCMMother.create("scm-id")); assertThat(pluggableSCMMaterialConfig.getTypeForDisplay(), is("SCM")); SCMMetadataStore.getInstance().addMetadataFor("plugin", null, null); assertThat(pluggableSCMMaterialConfig.getTypeForDisplay(), is("SCM")); SCMView scmView = mock(SCMView.class); when(scmView.displayValue()).thenReturn("scm-name"); SCMMetadataStore.getInstance().addMetadataFor("plugin", null, scmView); assertThat(pluggableSCMMaterialConfig.getTypeForDisplay(), is("scm-name")); }
@Test public void shouldNotTryRemoveMetadataOnPluginUnLoadedCallback() throws Exception { SCMConfigurations scmConfigurations = new SCMConfigurations(); SCMView scmView = createSCMView(null, null); SCMMetadataStore.getInstance().addMetadataFor(pluginDescriptor.id(), scmConfigurations, scmView); when(scmExtension.canHandlePlugin(pluginDescriptor.id())).thenReturn(false); metadataLoader.pluginUnLoaded(pluginDescriptor); assertThat(SCMMetadataStore.getInstance().getConfigurationMetadata(pluginDescriptor.id()), is(scmConfigurations)); assertThat(SCMMetadataStore.getInstance().getViewMetadata(pluginDescriptor.id()), is(scmView)); }
@Test public void shouldThrowExceptionWhenNullSCMViewReturned() { when(scmExtension.getSCMConfiguration(pluginDescriptor.id())).thenReturn(new SCMPropertyConfiguration()); when(scmExtension.getSCMView(pluginDescriptor.id())).thenReturn(null); try { metadataLoader.fetchSCMMetaData(pluginDescriptor); } catch (Exception e) { assertThat(e.getMessage(), is("Plugin[plugin-id] returned null SCM view")); } assertThat(SCMMetadataStore.getInstance().getConfigurationMetadata(pluginDescriptor.id()), nullValue()); }
@Before public void setUp() throws Exception { pluginDescriptor = new GoPluginDescriptor("plugin-id", "1.0", null, null, null, true); pluginManager = mock(PluginManager.class); scmExtension = mock(SCMExtension.class); metadataLoader = new SCMMetadataLoader(scmExtension, pluginManager); SCMMetadataStore.getInstance().removeMetadata(pluginDescriptor.id()); }
@Before public void setup() throws Exception { SCMMetadataStore.getInstance().clear(); xmlLoader = new MagicalGoConfigXmlLoader(configCache, ConfigElementImplementationRegistryMother.withNoPlugins()); }
@Test public void shouldReturnSomethingMoreSaneForToString() throws Exception { PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial(); SCMMetadataStore.getInstance().addMetadataFor(material.getPluginId(), new SCMConfigurations(), null); assertThat(material.toString(), is("'PluggableSCMMaterial{[k1=v1, k2=v2]}'")); }
public void addConfigurations(List<ConfigurationProperty> configurations) { ConfigurationPropertyBuilder builder = new ConfigurationPropertyBuilder(); for (ConfigurationProperty property : configurations) { SCMConfigurations scmConfigurations = SCMMetadataStore.getInstance().getConfigurationMetadata(getPluginId()); if (isValidPluginConfiguration(property.getConfigKeyName(), scmConfigurations)) { configuration.add(builder.create(property.getConfigKeyName(), property.getConfigValue(), property.getEncryptedValue(), scmConfigurationFor(property.getConfigKeyName(), scmConfigurations).getOption(SCMConfiguration.SECURE))); } else { configuration.add(property); } } }
@Test public void shouldNotDisplayEmptyValuesInGetConfigForDisplay() throws Exception { SCMMetadataStore.getInstance().addMetadataFor("plugin-id", new SCMConfigurations(), null); Configuration configuration = new Configuration(create("rk1", false, ""), create("rk2", false, "some-non-empty-value"), create("rk3", false, null)); SCM scm = SCMMother.create("scm", "scm-name", "plugin-id", "1.0", configuration); assertThat(scm.getConfigForDisplay(), is("[rk2=some-non-empty-value]")); }