use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class FelixGoPluginOSGiFrameworkIntegrationTest method shouldNotifyListenersWhenPluginLoaded.
@Test
public void shouldNotifyListenersWhenPluginLoaded() {
PluginChangeListener pluginChangeListener = mock(PluginChangeListener.class);
pluginOSGiFramework.addPluginChangeListener(pluginChangeListener);
GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(null, null, null, null, descriptorBundleDir, true);
pluginOSGiFramework.loadPlugin(pluginDescriptor);
verify(pluginChangeListener).pluginLoaded(pluginDescriptor);
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class FelixGoPluginOSGiFrameworkTest method shouldMarkThePluginAsInvalidIfAnyExceptionOccursAfterLoad.
@Test
public void shouldMarkThePluginAsInvalidIfAnyExceptionOccursAfterLoad() throws BundleException {
final Bundle bundle = mock(Bundle.class);
spy.addPluginChangeListener(new PluginChangeListener() {
@Override
public void pluginLoaded(GoPluginDescriptor pluginDescriptor) {
throw new RuntimeException("some error");
}
@Override
public void pluginUnLoaded(GoPluginDescriptor pluginDescriptor) {
}
});
when(bundleContext.installBundle(any(String.class))).thenReturn(bundle);
final GoPluginDescriptor goPluginDescriptor = new GoPluginDescriptor(TEST_SYMBOLIC_NAME, "1.0", null, "location", new File(""), false);
spy.start();
try {
spy.loadPlugin(goPluginDescriptor);
fail("should throw exception");
} catch (Exception e) {
assertTrue(goPluginDescriptor.getStatus().isInvalid());
}
}
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());
}
Aggregations