Search in sources :

Example 26 with TaskPreference

use of com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference 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

TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)26 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)16 Test (org.junit.Test)14 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)12 Configuration (com.thoughtworks.go.domain.config.Configuration)11 TaskProperty (com.thoughtworks.go.domain.TaskProperty)8 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)8 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)8 TaskConfigProperty (com.thoughtworks.go.plugin.api.task.TaskConfigProperty)7 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)5 JsonBasedPluggableTask (com.thoughtworks.go.plugin.access.pluggabletask.JsonBasedPluggableTask)4 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)4 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)4 Before (org.junit.Before)4 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)3 Property (com.thoughtworks.go.plugin.api.config.Property)3 PluggableTaskPluginInfo (com.thoughtworks.go.server.ui.plugins.PluggableTaskPluginInfo)3 ArrayList (java.util.ArrayList)3 AntTask (com.thoughtworks.go.config.AntTask)2 PluggableTaskConfigStore (com.thoughtworks.go.plugin.access.pluggabletask.PluggableTaskConfigStore)2