Search in sources :

Example 21 with PluginManager

use of com.thoughtworks.go.plugin.infra.PluginManager in project gocd by gocd.

the class PluginsZipTest method setUp.

@Before
public void setUp() throws Exception {
    pluginManager = mock(PluginManager.class);
    temporaryFolder.create();
    systemEnvironment = mock(SystemEnvironment.class);
    File bundledPluginsDir = temporaryFolder.newFolder("plugins-bundled");
    expectedZipPath = temporaryFolder.newFile("go-plugins-all.zip").getAbsolutePath();
    externalPluginsDir = temporaryFolder.newFolder("plugins-external");
    when(systemEnvironment.get(PLUGIN_GO_PROVIDED_PATH)).thenReturn(bundledPluginsDir.getAbsolutePath());
    when(systemEnvironment.get(PLUGIN_EXTERNAL_PROVIDED_PATH)).thenReturn(externalPluginsDir.getAbsolutePath());
    when(systemEnvironment.get(ALL_PLUGINS_ZIP_PATH)).thenReturn(expectedZipPath);
    pluginsZip = spy(new PluginsZip(systemEnvironment, pluginManager));
    File bundledTask1Jar = new File(bundledPluginsDir, "bundled-task-1.jar");
    FileUtils.writeStringToFile(bundledTask1Jar, "Bundled1", UTF_8);
    File bundledAuth2Jar = new File(bundledPluginsDir, "bundled-auth-2.jar");
    FileUtils.writeStringToFile(bundledAuth2Jar, "Bundled2", UTF_8);
    File bundledscm3Jar = new File(bundledPluginsDir, "bundled-scm-3.jar");
    FileUtils.writeStringToFile(bundledscm3Jar, "Bundled3", UTF_8);
    File bundledPackageMaterialJar = new File(bundledPluginsDir, "bundled-package-material-4.jar");
    FileUtils.writeStringToFile(bundledPackageMaterialJar, "Bundled4", UTF_8);
    File externalTask1Jar = new File(externalPluginsDir, "external-task-1.jar");
    FileUtils.writeStringToFile(externalTask1Jar, "External1", UTF_8);
    File externalElastic1Jar = new File(externalPluginsDir, "external-elastic-agent-2.jar");
    FileUtils.writeStringToFile(externalElastic1Jar, "External2", UTF_8);
    File externalscm3Jar = new File(externalPluginsDir, "external-scm-3.jar");
    FileUtils.writeStringToFile(externalscm3Jar, "External3", UTF_8);
    File externalPackageMaterialJar = new File(externalPluginsDir, "external-package-material-4.jar");
    FileUtils.writeStringToFile(externalPackageMaterialJar, "External3", UTF_8);
    bundledTaskPlugin = new GoPluginDescriptor("bundled-task-1", "1.0", null, bundledTask1Jar.getAbsolutePath(), null, true);
    bundledAuthPlugin = new GoPluginDescriptor("bundled-auth-2", "1.0", null, bundledAuth2Jar.getAbsolutePath(), null, true);
    bundledSCMPlugin = new GoPluginDescriptor("bundled-scm-3", "1.0", null, bundledscm3Jar.getAbsolutePath(), null, true);
    bundledPackageMaterialPlugin = new GoPluginDescriptor("bundled-package-material-4", "1.0", null, bundledPackageMaterialJar.getAbsolutePath(), null, true);
    externalTaskPlugin = new GoPluginDescriptor("external-task-1", "1.0", null, externalTask1Jar.getAbsolutePath(), null, false);
    externalElasticAgentPlugin = new GoPluginDescriptor("external-elastic-agent-2", "1.0", null, externalElastic1Jar.getAbsolutePath(), null, false);
    externalSCMPlugin = new GoPluginDescriptor("external-scm-3", "1.0", null, externalscm3Jar.getAbsolutePath(), null, false);
    externalPackageMaterialPlugin = new GoPluginDescriptor("external-package-material-4", "1.0", null, externalPackageMaterialJar.getAbsolutePath(), null, false);
    when(pluginManager.plugins()).thenReturn(Arrays.asList(bundledTaskPlugin, bundledAuthPlugin, bundledSCMPlugin, bundledPackageMaterialPlugin, externalTaskPlugin, externalElasticAgentPlugin, externalSCMPlugin, externalPackageMaterialPlugin));
    when(pluginManager.isPluginOfType("task", "bundled-task-1")).thenReturn(true);
    when(pluginManager.isPluginOfType("task", "external-task-1")).thenReturn(true);
    when(pluginManager.isPluginOfType("package-repository", "bundled-package-material-4")).thenReturn(true);
    when(pluginManager.isPluginOfType("scm", "bundled-scm-3")).thenReturn(true);
    when(pluginManager.isPluginOfType("scm", "external-scm-3")).thenReturn(true);
    when(pluginManager.isPluginOfType("package-repository", "external-package-material-4")).thenReturn(true);
}
Also used : PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) File(java.io.File) ZipFile(java.util.zip.ZipFile) Before(org.junit.Before)

Example 22 with PluginManager

use of com.thoughtworks.go.plugin.infra.PluginManager in project gocd by gocd.

the class PackageMaterialMetadataLoaderTest method setUp.

@Before
public void setUp() throws Exception {
    pluginDescriptor = new GoPluginDescriptor("plugin-id", "1.0", null, null, null, true);
    pluginManager = mock(PluginManager.class);
    packageRepositoryExtension = mock(PackageRepositoryExtension.class);
    metadataLoader = new PackageMaterialMetadataLoader(pluginManager, packageRepositoryExtension);
    RepositoryMetadataStore.getInstance().removeMetadata(pluginDescriptor.id());
    PackageMetadataStore.getInstance().removeMetadata(pluginDescriptor.id());
}
Also used : PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Before(org.junit.Before)

Example 23 with PluginManager

use of com.thoughtworks.go.plugin.infra.PluginManager in project gocd by gocd.

the class ElasticAgentExtensionTestForV1 method shouldSerializePluginSettingsToJSON.

@Test
public void shouldSerializePluginSettingsToJSON() throws Exception {
    String pluginId = "plugin_id";
    HashMap<String, String> pluginSettings = new HashMap<>();
    pluginSettings.put("key1", "val1");
    pluginSettings.put("key2", "val2");
    PluginManager pluginManager = mock(PluginManager.class);
    ElasticAgentExtension elasticAgentExtension = new ElasticAgentExtension(pluginManager);
    when(pluginManager.resolveExtensionVersion(pluginId, Arrays.asList("1.0", "2.0"))).thenReturn("1.0");
    String pluginSettingsJSON = elasticAgentExtension.pluginSettingsJSON(pluginId, pluginSettings);
    assertThat(pluginSettingsJSON, is("{\"key1\":\"val1\",\"key2\":\"val2\"}"));
}
Also used : PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 24 with PluginManager

use of com.thoughtworks.go.plugin.infra.PluginManager in project gocd by gocd.

the class ElasticAgentExtensionTestForV2 method shouldSerializePluginSettingsToJSON.

@Test
public void shouldSerializePluginSettingsToJSON() throws Exception {
    String pluginId = "plugin_id";
    HashMap<String, String> pluginSettings = new HashMap<>();
    pluginSettings.put("key1", "val1");
    pluginSettings.put("key2", "val2");
    PluginManager pluginManager = mock(PluginManager.class);
    ElasticAgentExtension elasticAgentExtension = new ElasticAgentExtension(pluginManager);
    when(pluginManager.resolveExtensionVersion(pluginId, Arrays.asList("1.0", "2.0"))).thenReturn("2.0");
    String pluginSettingsJSON = elasticAgentExtension.pluginSettingsJSON(pluginId, pluginSettings);
    assertThat(pluginSettingsJSON, is("{\"key1\":\"val1\",\"key2\":\"val2\"}"));
}
Also used : PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 25 with PluginManager

use of com.thoughtworks.go.plugin.infra.PluginManager in project gocd by gocd.

the class JsonBasedTaskExecutorTest method setup.

@BeforeEach
public void setup() {
    context = mock(TaskExecutionContext.class);
    pluginManager = mock(PluginManager.class);
    pluginId = "pluginId";
    response = mock(GoPluginApiResponse.class);
    handler = mock(JsonBasedTaskExtensionHandler.class);
    handlerHashMap.put("1.0", handler);
    final List<String> goSupportedVersions = asList("1.0");
    pluginRequestHelper = new PluginRequestHelper(pluginManager, goSupportedVersions, PLUGGABLE_TASK_EXTENSION);
    when(pluginManager.resolveExtensionVersion(pluginId, PLUGGABLE_TASK_EXTENSION, goSupportedVersions)).thenReturn(extensionVersion);
    when(response.responseCode()).thenReturn(DefaultGoApiResponse.SUCCESS_RESPONSE_CODE);
    when(pluginManager.isPluginOfType(PLUGGABLE_TASK_EXTENSION, pluginId)).thenReturn(true);
}
Also used : PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) PluginRequestHelper(com.thoughtworks.go.plugin.access.PluginRequestHelper) GoPluginApiResponse(com.thoughtworks.go.plugin.api.response.GoPluginApiResponse) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)27 Test (org.junit.Test)17 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)16 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)6 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)5 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)5 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)4 Test (org.junit.jupiter.api.Test)4 AuthenticationPluginRegistry (com.thoughtworks.go.plugin.access.authentication.AuthenticationPluginRegistry)3 NotificationPluginRegistry (com.thoughtworks.go.plugin.access.notification.NotificationPluginRegistry)3 PackageMetadataStore (com.thoughtworks.go.plugin.access.packagematerial.PackageMetadataStore)3 RepositoryMetadataStore (com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore)3 PluggableTaskConfigStore (com.thoughtworks.go.plugin.access.pluggabletask.PluggableTaskConfigStore)3 Task (com.thoughtworks.go.plugin.api.task.Task)3 AuthenticationPluginInfo (com.thoughtworks.go.server.ui.plugins.AuthenticationPluginInfo)3 NotificationPluginInfo (com.thoughtworks.go.server.ui.plugins.NotificationPluginInfo)3 PackageRepositoryPluginInfo (com.thoughtworks.go.server.ui.plugins.PackageRepositoryPluginInfo)3 PluggableTaskPluginInfo (com.thoughtworks.go.server.ui.plugins.PluggableTaskPluginInfo)3 SCMPluginInfo (com.thoughtworks.go.server.ui.plugins.SCMPluginInfo)3 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3