use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class DefaultPluginInfoFinderTest method getDescriptor.
private GoPluginDescriptor getDescriptor(String pluginID) {
GoPluginDescriptor.Vendor vendor = new GoPluginDescriptor.Vendor("vendor-name", "vendor-url");
GoPluginDescriptor.About about = new GoPluginDescriptor.About("author", "1.0", "17.12", "some description", vendor, Collections.emptyList());
return new GoPluginDescriptor(pluginID, "1.0", about, "/path/to/plugin", new File("/path/to/bundle"), false);
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class TaskViewServiceTest method shouldGetViewModelsForPluggedInTasks_ButOnlyForExistingPlugins.
@Test
public void shouldGetViewModelsForPluggedInTasks_ButOnlyForExistingPlugins() throws Exception {
String plugin1 = "task-plugin-1";
String plugin2 = "task-plugin-2";
when(pluginManager.getPluginDescriptorFor(plugin1)).thenReturn(new GoPluginDescriptor(plugin1, "1", null, null, null, false));
when(pluginManager.getPluginDescriptorFor(plugin2)).thenReturn(new GoPluginDescriptor(plugin2, "1", null, null, null, false));
storeTaskPreferences(plugin1, "key_1", "key_2");
storeTaskPreferences(plugin2, "key_3", "key_4");
when(registry.implementersOf(Task.class)).thenReturn(Arrays.<Class<? extends Task>>asList(ExecTask.class, PluggableTask.class));
PluggableTask expectedPluggableTaskForPlugin1 = new PluggableTask(new PluginConfiguration(plugin1, "1"), new Configuration(create("key_1"), create("key_2")));
PluggableTask expectedPluggableTaskForPlugin2 = new PluggableTask(new PluginConfiguration(plugin2, "1"), new Configuration(create("key_3"), create("key_4")));
when(registry.getViewModelFor(new ExecTask(), "new")).thenReturn(viewModel(new ExecTask()));
when(registry.getViewModelFor(expectedPluggableTaskForPlugin1, "new")).thenReturn(viewModel(expectedPluggableTaskForPlugin1));
when(registry.getViewModelFor(expectedPluggableTaskForPlugin2, "new")).thenReturn(viewModel(expectedPluggableTaskForPlugin2));
List<PluggableViewModel> viewModels = taskViewService.getTaskViewModels();
assertThat(viewModels.size(), is(3));
assertThat(viewModels.get(0).getModel(), instanceOf(ExecTask.class));
assertThat(viewModels.get(1).getModel(), instanceOf(PluggableTask.class));
assertThat(viewModels.get(2).getModel(), instanceOf(PluggableTask.class));
assertThat(viewModels.get(1).getModel(), is(expectedPluggableTaskForPlugin1));
assertThat(viewModels.get(2).getModel(), is(expectedPluggableTaskForPlugin2));
verify(registry).getViewModelFor(expectedPluggableTaskForPlugin1, "new");
verify(registry).getViewModelFor(expectedPluggableTaskForPlugin2, "new");
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class TaskViewServiceTest method shouldStoreDefaultValuesGivenForPropertiesInAPluginWhenInitializingANewTaskPlugin.
@Test
public void shouldStoreDefaultValuesGivenForPropertiesInAPluginWhenInitializingANewTaskPlugin() throws Exception {
String plugin = "task-plugin";
when(pluginManager.getPluginDescriptorFor(plugin)).thenReturn(new GoPluginDescriptor(plugin, "1", null, null, null, false));
Property taskConfigProperty1 = new TaskConfigProperty("key1", null);
Property taskConfigProperty2 = new TaskConfigProperty("key2", null);
Property taskConfigProperty3 = new TaskConfigProperty("key3", null);
storeTaskPreferences(plugin, taskConfigProperty1.withDefault("default1"), taskConfigProperty2.withDefault("default2"), taskConfigProperty3);
when(registry.implementersOf(Task.class)).thenReturn(Arrays.<Class<? extends Task>>asList(PluggableTask.class));
PluggableTask pluggableTask = (PluggableTask) taskViewService.taskInstanceFor(new PluggableTask(new PluginConfiguration(plugin, "1"), new Configuration()).getTaskType());
assertThat(pluggableTask.getConfiguration().getProperty("key1").getValue(), is("default1"));
assertThat(pluggableTask.getConfiguration().getProperty("key2").getValue(), is("default2"));
assertNull(pluggableTask.getConfiguration().getProperty("key3").getValue());
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class TaskViewServiceTest method shouldFetchPluggableTasksWithSecureConfigurations.
@Test
public void shouldFetchPluggableTasksWithSecureConfigurations() throws Exception {
String plugin = "task-plugin";
when(pluginManager.getPluginDescriptorFor(plugin)).thenReturn(new GoPluginDescriptor(plugin, "1", null, null, null, false));
Property taskConfigProperty = new TaskConfigProperty("key1", null).with(Property.SECURE, true);
storeTaskPreferences(plugin, taskConfigProperty);
when(registry.implementersOf(Task.class)).thenReturn(Arrays.<Class<? extends Task>>asList(PluggableTask.class));
PluggableTask pluggableTask = (PluggableTask) taskViewService.taskInstanceFor(new PluggableTask(new PluginConfiguration(plugin, "1"), null).getTaskType());
assertTrue(pluggableTask.getConfiguration().first().isSecure());
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class ElasticAgentMetadataLoaderTest method onPluginLoaded_shouldAddPluginInfoToMetadataStore.
@Test
public void onPluginLoaded_shouldAddPluginInfoToMetadataStore() throws Exception {
GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
ElasticAgentMetadataLoader metadataLoader = new ElasticAgentMetadataLoader(pluginManager, metadataStore, infoBuilder, extension);
ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(descriptor, null, null, null, null);
when(extension.canHandlePlugin(descriptor.id())).thenReturn(true);
when(infoBuilder.pluginInfoFor(descriptor)).thenReturn(pluginInfo);
metadataLoader.pluginLoaded(descriptor);
verify(metadataStore).setPluginInfo(pluginInfo);
}
Aggregations