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;
}
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;
}
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));
}
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));
}
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));
}
Aggregations