Search in sources :

Example 6 with PluginConfiguration

use of com.thoughtworks.go.server.ui.plugins.PluginConfiguration in project gocd by gocd.

the class PluggableTaskViewModelBuilder method configurations.

private List<PluginConfiguration> configurations(TaskConfig config) {
    ArrayList<PluginConfiguration> pluginConfigurations = new ArrayList<>();
    for (Property property : config.list()) {
        Map<String, Object> metaData = new HashMap<>();
        metaData.put(REQUIRED_OPTION, property.getOption(Property.REQUIRED));
        metaData.put(SECURE_OPTION, property.getOption(Property.SECURE));
        pluginConfigurations.add(new PluginConfiguration(property.getKey(), metaData));
    }
    return pluginConfigurations;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) Property(com.thoughtworks.go.plugin.api.config.Property)

Example 7 with PluginConfiguration

use of com.thoughtworks.go.server.ui.plugins.PluginConfiguration in project gocd by gocd.

the class SCMViewModelBuilder method configurations.

private List<PluginConfiguration> configurations(SCMConfigurations scmConfigurations) {
    List<PluginConfiguration> pluginConfigurations = new ArrayList<>();
    for (SCMConfiguration configuration : scmConfigurations.list()) {
        Map<String, Object> metaData = new HashMap<>();
        metaData.put(REQUIRED_OPTION, configuration.getOption(Property.REQUIRED));
        metaData.put(SECURE_OPTION, configuration.getOption(Property.SECURE));
        metaData.put(PART_OF_IDENTITY_OPTION, configuration.getOption(Property.PART_OF_IDENTITY));
        pluginConfigurations.add(new PluginConfiguration(configuration.getKey(), metaData));
    }
    return pluginConfigurations;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration)

Example 8 with PluginConfiguration

use of com.thoughtworks.go.server.ui.plugins.PluginConfiguration in project gocd by gocd.

the class SCMViewModelBuilderTest method shouldBeAbleToFetchAPluginInfoForAGivenIdWithConfigurations.

@Test
public void shouldBeAbleToFetchAPluginInfoForAGivenIdWithConfigurations() {
    when(manager.getPluginDescriptorFor("github.pr")).thenReturn(githubPR);
    PluginInfo pluginInfo = builder.pluginInfoFor("github.pr");
    HashMap expectedMetadata = new HashMap<String, Object>() {

        {
            put("required", true);
            put("secure", false);
            put("part_of_identity", true);
        }
    };
    List<PluginConfiguration> configurations = pluginInfo.getPluggableInstanceSettings().getConfigurations();
    assertThat(configurations.size(), is(2));
    PluginConfiguration configuration1 = configurations.get(0);
    assertThat(configuration1.getKey(), is("key1"));
    assertNull(configuration1.getType());
    assertThat(configuration1.getMetadata(), Is.<Map<String, Object>>is(expectedMetadata));
    PluginConfiguration configuration2 = configurations.get(1);
    assertThat(configuration2.getKey(), is("key2"));
    assertNull(configuration2.getType());
    assertThat(configuration1.getMetadata(), Is.<Map<String, Object>>is(expectedMetadata));
}
Also used : HashMap(java.util.HashMap) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Test(org.junit.Test)

Example 9 with PluginConfiguration

use of com.thoughtworks.go.server.ui.plugins.PluginConfiguration in project gocd by gocd.

the class PluggableTaskViewModelBuilderTest method shouldBeAbleToFetchAPluginInfoForAGivenIdWithConfigurations.

@Test
public void shouldBeAbleToFetchAPluginInfoForAGivenIdWithConfigurations() {
    when(manager.getPluginDescriptorFor("xunit.convertor")).thenReturn(xunitConvertor);
    PluginInfo pluginInfo = builder.pluginInfoFor("xunit.convertor");
    HashMap expectedMetadata = new HashMap<String, Object>() {

        {
            put("required", false);
            put("secure", false);
        }
    };
    List<PluginConfiguration> configurations = pluginInfo.getPluggableInstanceSettings().getConfigurations();
    assertThat(configurations.size(), is(2));
    PluginConfiguration configuration1 = configurations.get(0);
    assertThat(configuration1.getKey(), is("key1"));
    assertNull(configuration1.getType());
    assertThat(configuration1.getMetadata(), Is.<Map<String, Object>>is(expectedMetadata));
    PluginConfiguration configuration2 = configurations.get(1);
    assertThat(configuration2.getKey(), is("key2"));
    assertNull(configuration2.getType());
    assertThat(configuration1.getMetadata(), Is.<Map<String, Object>>is(expectedMetadata));
}
Also used : HashMap(java.util.HashMap) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Test(org.junit.Test)

Example 10 with PluginConfiguration

use of com.thoughtworks.go.server.ui.plugins.PluginConfiguration in project gocd by gocd.

the class PackageViewModelBuilderTest method shouldBeAbleToFetchAPluginInfoForAGivenIdWithConfigurations.

@Test
public void shouldBeAbleToFetchAPluginInfoForAGivenIdWithConfigurations() {
    when(manager.getPluginDescriptorFor("yum.poller")).thenReturn(yumPoller);
    PluginInfo pluginInfo = builder.pluginInfoFor("yum.poller");
    HashMap expectedMetadata = new HashMap<String, Object>() {

        {
            put("required", true);
            put("secure", false);
            put("part_of_identity", true);
            put("display_order", 0);
            put("display_name", "");
        }
    };
    List<PluginConfiguration> configurations = pluginInfo.getPluggableInstanceSettings().getConfigurations();
    assertThat(configurations.size(), is(3));
    PluginConfiguration configuration2 = configurations.get(0);
    assertThat(configuration2.getKey(), is("key1"));
    assertThat(configuration2.getType(), is("package"));
    assertThat(configuration2.getMetadata(), Is.<Map<String, Object>>is(expectedMetadata));
    PluginConfiguration configuration3 = configurations.get(1);
    assertThat(configuration3.getKey(), is("key2"));
    assertThat(configuration3.getType(), is("package"));
    assertThat(configuration3.getMetadata(), Is.<Map<String, Object>>is(expectedMetadata));
    PluginConfiguration configuration1 = configurations.get(2);
    assertThat(configuration1.getKey(), is("key1"));
    assertThat(configuration1.getType(), is("repository"));
    assertThat(configuration1.getMetadata(), Is.<Map<String, Object>>is(expectedMetadata));
}
Also used : HashMap(java.util.HashMap) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Test(org.junit.Test)

Aggregations

PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)17 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)9 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)8 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)8 HashMap (java.util.HashMap)6 Image (com.thoughtworks.go.plugin.access.common.models.Image)5 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)4 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)2 Property (com.thoughtworks.go.plugin.api.config.Property)2 PluginProfileMetadata (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata)1 PluginProfileMetadataKey (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey)1 PluginProfileMetadataKeys (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys)1 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)1 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)1 SCMPreference (com.thoughtworks.go.plugin.access.scm.SCMPreference)1 AuthorizationPluginInfo (com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo)1 ElasticPluginInfo (com.thoughtworks.go.server.ui.plugins.ElasticPluginInfo)1