@Test public void shouldConstructSCMConfiguration() throws Exception { SCMPropertyConfiguration scmPropertyConfiguration = new SCMPropertyConfiguration(); scmPropertyConfiguration.add(new SCMProperty("k1", "v1").with(Property.SECURE, Boolean.TRUE)); SCMConfigurations scmConfigurations = new SCMConfigurations(scmPropertyConfiguration); assertThat(scmConfigurations.list().size(), is(1)); SCMConfiguration scmConfiguration = scmConfigurations.list().get(0); assertThat(scmConfiguration.getKey(), is("k1")); assertThat(scmConfiguration.getValue(), is("v1")); assertThat(scmConfiguration.getOption(SCMConfiguration.REQUIRED), is(true)); assertThat(scmConfiguration.getOption(SCMConfiguration.PART_OF_IDENTITY), is(true)); assertThat(scmConfiguration.getOption(SCMConfiguration.SECURE), is(true)); assertThat(scmConfiguration.getOption(SCMConfiguration.DISPLAY_NAME), is("")); assertThat(scmConfiguration.getOption(SCMConfiguration.DISPLAY_ORDER), is(0)); } }
@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"); }
@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")); }
SCMPropertyConfiguration scmConfiguration = new SCMPropertyConfiguration(); scmConfiguration.add(new SCMProperty("k1")); scmConfiguration.add(new SCMProperty("k2").with(REQUIRED, false).with(PART_OF_IDENTITY, false)); SCMMetadataStore.getInstance().addMetadataFor(pluginId, new SCMConfigurations(scmConfiguration), null);
SCMPropertyConfiguration scmConfiguration = new SCMPropertyConfiguration(); scmConfiguration.add(new SCMProperty("SCM-KEY1")); scmConfiguration.add(new SCMProperty("SCM-KEY2").with(REQUIRED, false).with(PART_OF_IDENTITY, false)); scmConfiguration.add(new SCMProperty("SCM-KEY3").with(REQUIRED, false).with(PART_OF_IDENTITY, false).with(SECURE, true)); SCMMetadataStore.getInstance().addMetadataFor("plugin-1", new SCMConfigurations(scmConfiguration), null);