use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class DefaultPluginJarChangeListenerTest method shouldNotThrowExceptionIfThePluginImplementsDescriptorAwareIsNotAvailable.
@Test
public void shouldNotThrowExceptionIfThePluginImplementsDescriptorAwareIsNotAvailable() throws Exception {
String pluginJarFileName = "descriptor-aware-test-plugin.jar";
File pluginJarFile = new File(PLUGIN_DIR, pluginJarFileName);
copyPluginToTheDirectory(PLUGIN_DIR, pluginJarFileName);
GoPluginDescriptor descriptor = new GoPluginDescriptor("some.old.id", "1.0", new GoPluginDescriptor.About(null, null, null, null, null, null), null, new File(pluginJarFileName), false);
when(systemEnvironment.getOperatingSystemFamilyName()).thenReturn("Windows");
when(goPluginDescriptorBuilder.build(pluginJarFile, true)).thenReturn(descriptor);
when(osgiFramework.hasReferenceFor(PluginDescriptorAware.class, descriptor.id())).thenReturn(false);
doThrow(new GoPluginFrameworkException("Failed to find service reference")).when(osgiFramework).doOnAllForPlugin(eq(PluginDescriptorAware.class), eq(descriptor.id()), Matchers.<Action<PluginDescriptorAware>>anyObject());
listener = new DefaultPluginJarChangeListener(registry, osgiManifestGenerator, osgiFramework, goPluginDescriptorBuilder, systemEnvironment);
listener.pluginJarAdded(new PluginFileDetails(pluginJarFile, true));
verify(registry, times(1)).loadPlugin(descriptor);
verify(osgiFramework, times(1)).loadPlugin(descriptor);
verify(osgiFramework, times(1)).hasReferenceFor(PluginDescriptorAware.class, descriptor.id());
verify(osgiFramework, never()).doOnAllForPlugin(eq(PluginDescriptorAware.class), eq(descriptor.id()), Matchers.<Action<PluginDescriptorAware>>anyObject());
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class PackageViewModelBuilderTest method setUp.
@Before
public void setUp() {
initMocks(this);
builder = new PackageViewModelBuilder(manager);
yumPoller = new GoPluginDescriptor("yum.poller", "version1", new GoPluginDescriptor.About("Yum Poller", "1.0", null, null, null, null), null, null, false);
npmPoller = new GoPluginDescriptor("npm.poller", "version1", new GoPluginDescriptor.About("NPM Poller", "2.0", null, null, null, null), null, null, false);
PackageConfigurations packageConfigurations = new PackageConfigurations();
packageConfigurations.add(new PackageConfiguration("key1"));
packageConfigurations.add(new PackageConfiguration("key2"));
PackageConfigurations repositoryConfigurations = new PackageConfigurations();
repositoryConfigurations.add(new PackageConfiguration("key1"));
PackageMetadataStore.getInstance().addMetadataFor(yumPoller.id(), packageConfigurations);
PackageMetadataStore.getInstance().addMetadataFor(npmPoller.id(), new PackageConfigurations());
RepositoryMetadataStore.getInstance().addMetadataFor(yumPoller.id(), repositoryConfigurations);
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class PluggableTaskPluginInfoBuilderTest method allPluginInfos_ShouldReturnAListOfAllPluginInfos.
@Test
public void allPluginInfos_ShouldReturnAListOfAllPluginInfos() throws Exception {
GoPluginDescriptor.About about = new GoPluginDescriptor.About("Plugin Descriptor Validator", "1.0.1", "12.4", "Validates its own plugin descriptor", new GoPluginDescriptor.Vendor("ThoughtWorks Go Team", "www.thoughtworks.com"), Arrays.asList("Linux", "Windows", "Mac OS X"));
GoPluginDescriptor plugin = new GoPluginDescriptor("docker-plugin", "1.0", about, null, null, false);
PluginManager pluginManager = mock(PluginManager.class);
PluggableTaskConfigStore packageMetadataStore = mock(PluggableTaskConfigStore.class);
when(packageMetadataStore.pluginIds()).thenReturn(Collections.singleton(plugin.id()));
when(pluginManager.getPluginDescriptorFor(plugin.id())).thenReturn(plugin);
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";
}
};
TaskConfig taskConfig = new TaskConfig();
taskConfig.add(new TaskConfigProperty("key1", null));
taskConfig.add(new TaskConfigProperty("key2", null));
when(jsonBasedPluggableTask.config()).thenReturn(taskConfig);
when(jsonBasedPluggableTask.view()).thenReturn(taskView);
TaskPreference taskPreference = new TaskPreference(jsonBasedPluggableTask);
when(packageMetadataStore.preferenceFor(plugin.id())).thenReturn(taskPreference);
PluggableTaskPluginInfoBuilder builder = new PluggableTaskPluginInfoBuilder(pluginManager, packageMetadataStore);
Collection<PluggableTaskPluginInfo> pluginInfos = builder.allPluginInfos();
PluggableTaskPluginInfo expectedPluginInfo = new PluggableTaskPluginInfo(plugin, taskView.displayValue(), new PluggableInstanceSettings(configurations(taskConfig), new PluginView(taskView.template())));
assertEquals(Arrays.asList(expectedPluginInfo), pluginInfos);
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class SCMPluginInfoBuilderTest method allPluginInfos_ShouldReturnAListOfAllPluginInfos.
@Test
public void allPluginInfos_ShouldReturnAListOfAllPluginInfos() throws Exception {
GoPluginDescriptor.About about = new GoPluginDescriptor.About("Plugin Descriptor Validator", "1.0.1", "12.4", "Validates its own plugin descriptor", new GoPluginDescriptor.Vendor("ThoughtWorks Go Team", "www.thoughtworks.com"), Arrays.asList("Linux", "Windows", "Mac OS X"));
GoPluginDescriptor plugin = new GoPluginDescriptor("docker-plugin", "1.0", about, null, null, false);
PluginManager pluginManager = mock(PluginManager.class);
SCMMetadataStore scmMetadataStore = mock(SCMMetadataStore.class);
when(scmMetadataStore.getPlugins()).thenReturn(Collections.singletonList(plugin.id()));
when(pluginManager.getPluginDescriptorFor(plugin.id())).thenReturn(plugin);
SCMConfigurations configurations = new SCMConfigurations();
configurations.add(new SCMConfiguration("key1"));
configurations.add(new SCMConfiguration("key2"));
SCMView view = new SCMView() {
@Override
public String displayValue() {
return "SCM Display Value";
}
@Override
public String template() {
return "scm view template";
}
};
SCMPreference scmPreference = new SCMPreference(configurations, view);
when(scmMetadataStore.preferenceFor(plugin.id())).thenReturn(scmPreference);
SCMPluginInfoBuilder builder = new SCMPluginInfoBuilder(pluginManager, scmMetadataStore);
Collection<SCMPluginInfo> pluginInfos = builder.allPluginInfos();
SCMPluginInfo expectedPluginInfo = new SCMPluginInfo(plugin, view.displayValue(), new PluggableInstanceSettings(configurations(configurations), new PluginView(view.template())));
assertEquals(Arrays.asList(expectedPluginInfo), pluginInfos);
assertEquals(Arrays.asList(expectedPluginInfo), pluginInfos);
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class ElasticAgentViewViewModelBuilderTest method setUp.
@Before
public void setUp() {
initMocks(this);
builder = new ElasticAgentViewViewModelBuilder(elasticPluginConfigMetadataStore);
dockerPlugin = 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);
awsPlugin = new GoPluginDescriptor("cd.go.elastic-agent.aws", "1.0", new GoPluginDescriptor.About("GoCD AWS Elastic Agent Plugin", "1.0", null, null, null, null), null, null, false);
}
Aggregations