Search in sources :

Example 1 with SCMPreference

use of com.thoughtworks.go.plugin.access.scm.SCMPreference in project gocd by gocd.

the class SCMViewModelBuilder method allPluginInfos.

public List<PluginInfo> allPluginInfos() {
    List<PluginInfo> pluginInfos = new ArrayList<>();
    for (String pluginId : SCMMetadataStore.getInstance().pluginIds()) {
        GoPluginDescriptor descriptor = pluginManager.getPluginDescriptorFor(pluginId);
        SCMPreference scmPreference = SCMMetadataStore.getInstance().preferenceFor(pluginId);
        pluginInfos.add(new PluginInfo(descriptor, SCMExtension.EXTENSION_NAME, scmPreference.getScmView().displayValue(), null, null));
    }
    return pluginInfos;
}
Also used : ArrayList(java.util.ArrayList) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)

Example 2 with SCMPreference

use of com.thoughtworks.go.plugin.access.scm.SCMPreference in project gocd by gocd.

the class SCMTest method shouldAddPropertyComingFromAttributesMapIfPresentInConfigStoreEvenIfItISNotPresentInCurrentConfiguration.

@Test
void shouldAddPropertyComingFromAttributesMapIfPresentInConfigStoreEvenIfItISNotPresentInCurrentConfiguration() {
    SCMConfigurations scmConfigurations = new SCMConfigurations();
    scmConfigurations.add(new SCMConfiguration("KEY1"));
    scmConfigurations.add(new SCMConfiguration("Key2"));
    SCMPreference scmPreference = mock(SCMPreference.class);
    when(scmPreference.getScmConfigurations()).thenReturn(scmConfigurations);
    SCMMetadataStore.getInstance().setPreferenceFor("plugin-id", scmPreference);
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    SCM scm = new SCM("scm-id", new PluginConfiguration("plugin-id", "1"), configuration);
    Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1", "Key2", "value2");
    scm.setConfigAttributes(attributeMap);
    assertThat(scm.getConfigAsMap().get("KEY1").get(SCM.VALUE_KEY)).isEqualTo("value1");
    assertThat(scm.getConfigAsMap().get("Key2").get(SCM.VALUE_KEY)).isEqualTo("value2");
}
Also used : SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.jupiter.api.Test)

Example 3 with SCMPreference

use of com.thoughtworks.go.plugin.access.scm.SCMPreference in project gocd by gocd.

the class SCMTest method shouldPopulateItselfFromConfigAttributesMap.

@Test
void shouldPopulateItselfFromConfigAttributesMap() {
    SCMConfigurations scmConfigurations = new SCMConfigurations();
    scmConfigurations.add(new SCMConfiguration("KEY1"));
    scmConfigurations.add(new SCMConfiguration("Key2"));
    SCMPreference scmPreference = mock(SCMPreference.class);
    when(scmPreference.getScmConfigurations()).thenReturn(scmConfigurations);
    SCMMetadataStore.getInstance().setPreferenceFor("plugin-id", scmPreference);
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"), ConfigurationPropertyMother.create("Key2"));
    SCM scm = new SCM("scm-id", new PluginConfiguration("plugin-id", "1"), configuration);
    Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1", "Key2", "value2");
    scm.setConfigAttributes(attributeMap);
    assertThat(scm.getConfigAsMap().get("KEY1").get(SCM.VALUE_KEY)).isEqualTo("value1");
    assertThat(scm.getConfigAsMap().get("Key2").get(SCM.VALUE_KEY)).isEqualTo("value2");
}
Also used : SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.jupiter.api.Test)

Example 4 with SCMPreference

use of com.thoughtworks.go.plugin.access.scm.SCMPreference in project gocd by gocd.

the class SCMViewModelBuilder method pluginInfoFor.

public PluginInfo pluginInfoFor(String pluginId) {
    if (!SCMMetadataStore.getInstance().hasPreferenceFor(pluginId)) {
        return null;
    }
    GoPluginDescriptor descriptor = pluginManager.getPluginDescriptorFor(pluginId);
    SCMPreference scmPreference = SCMMetadataStore.getInstance().preferenceFor(pluginId);
    List<PluginConfiguration> pluginConfigurations = configurations(scmPreference.getScmConfigurations());
    PluginView pluginView = new PluginView(scmPreference.getScmView().template());
    return new PluginInfo(descriptor, SCMExtension.EXTENSION_NAME, scmPreference.getScmView().displayValue(), new PluggableInstanceSettings(pluginConfigurations, pluginView));
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo)

Example 5 with SCMPreference

use of com.thoughtworks.go.plugin.access.scm.SCMPreference in project gocd by gocd.

the class PluginInfoBuilderTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    githubDescriptor = new GoPluginDescriptor("github.oauth", "version1", new GoPluginDescriptor.About("Github OAuth Plugin", "1.0", null, null, null, null), null, null, false);
    emailNotifier = new GoPluginDescriptor("email.notifier", "version1", new GoPluginDescriptor.About("Email Notifier", "1.0", null, null, null, null), null, null, false);
    yumPoller = new GoPluginDescriptor("yum.poller", "version1", new GoPluginDescriptor.About("Yum Poller", "1.0", null, null, null, null), null, null, false);
    xunitConvertor = new GoPluginDescriptor("xunit.convertor", "version1", new GoPluginDescriptor.About("Xunit Convertor", "1.0", null, null, null, null), null, null, false);
    githubPR = new GoPluginDescriptor("github.pr", "version1", new GoPluginDescriptor.About("Github PR", "1.0", null, null, null, null), null, null, false);
    dockerElasticAgentPlugin = new GoPluginDescriptor("cd.go.elastic-agent.docker", "1.0", new GoPluginDescriptor.About("GoCD Docker Elastic Agent Plugin", "1.0", null, null, null, null), null, null, false);
    ldapAuthPlugin = new GoPluginDescriptor("cd.go.authorization.ldap", "1.0", new GoPluginDescriptor.About("GoCD LDAP Plugin", "1.0", null, null, null, null), null, null, false);
    JsonBasedPluggableTask jsonBasedPluggableTask = mock(JsonBasedPluggableTask.class);
    TaskView taskView = new TaskView() {

        @Override
        public String displayValue() {
            return "task display value";
        }

        @Override
        public String template() {
            return "pluggable task view template";
        }
    };
    when(authenticationPluginRegistry.getAuthenticationPlugins()).thenReturn(new HashSet<>(Arrays.asList("github.oauth")));
    when(notificationPluginRegistry.getNotificationPlugins()).thenReturn(new HashSet<>(Arrays.asList("email.notifier")));
    when(elasticPluginConfigMetadataStore.getPlugins()).thenReturn(new ArrayList<>(Arrays.asList(dockerElasticAgentPlugin)));
    when(authorizationPluginConfigMetadataStore.getPlugins()).thenReturn(new ArrayList<>(Arrays.asList(ldapAuthPlugin)));
    when(jsonBasedPluggableTask.view()).thenReturn(taskView);
    when(manager.getPluginDescriptorFor("github.oauth")).thenReturn(githubDescriptor);
    when(manager.getPluginDescriptorFor("email.notifier")).thenReturn(emailNotifier);
    when(manager.getPluginDescriptorFor("yum.poller")).thenReturn(yumPoller);
    when(manager.getPluginDescriptorFor("xunit.convertor")).thenReturn(xunitConvertor);
    when(manager.getPluginDescriptorFor("github.pr")).thenReturn(githubPR);
    when(manager.getPluginDescriptorFor("cd.go.elastic-agent.docker")).thenReturn(dockerElasticAgentPlugin);
    when(manager.getPluginDescriptorFor(ldapAuthPlugin.id())).thenReturn(ldapAuthPlugin);
    MetadataStoreHelper.clear();
    PackageMetadataStore.getInstance().addMetadataFor(yumPoller.id(), new PackageConfigurations());
    PluggableTaskConfigStore.store().setPreferenceFor("xunit.convertor", new TaskPreference(jsonBasedPluggableTask));
    SCMMetadataStore.getInstance().setPreferenceFor("github.pr", new SCMPreference(new SCMConfigurations(), mock(SCMView.class)));
    pluginViewModelBuilder = new PluginInfoBuilder(authenticationPluginRegistry, notificationPluginRegistry, elasticPluginConfigMetadataStore, authorizationPluginConfigMetadataStore, manager);
}
Also used : TaskView(com.thoughtworks.go.plugin.api.task.TaskView) JsonBasedPluggableTask(com.thoughtworks.go.plugin.access.pluggabletask.JsonBasedPluggableTask) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Before(org.junit.Before)

Aggregations

SCMPreference (com.thoughtworks.go.plugin.access.scm.SCMPreference)8 SCMConfigurations (com.thoughtworks.go.plugin.access.scm.SCMConfigurations)6 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)5 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 Test (org.junit.jupiter.api.Test)4 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)2 Before (org.junit.Before)2 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)1 JsonBasedPluggableTask (com.thoughtworks.go.plugin.access.pluggabletask.JsonBasedPluggableTask)1 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)1 SCMView (com.thoughtworks.go.plugin.access.scm.SCMView)1 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)1 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)1 PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)1 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)1 ArrayList (java.util.ArrayList)1