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