use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class PluginDownloaderTest method read_download_folder.
@Test
public void read_download_folder() throws Exception {
pluginDownloader.start();
assertThat(pluginDownloader.getDownloadedPluginFilenames()).hasSize(0);
copyFileToDirectory(TestProjectUtils.jarOf("test-base-plugin"), downloadDir);
assertThat(pluginDownloader.getDownloadedPlugins()).hasSize(1);
PluginInfo info = pluginDownloader.getDownloadedPlugins().iterator().next();
assertThat(info.getKey()).isEqualTo("testbase");
assertThat(info.getName()).isEqualTo("Base Plugin");
assertThat(info.getVersion()).isEqualTo(Version.create("0.1-SNAPSHOT"));
assertThat(info.getMainClass()).isEqualTo("BasePlugin");
}
use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class InstalledActionTest method category_is_returned_when_in_additional_fields.
@Test
public void category_is_returned_when_in_additional_fields() throws Exception {
logInAsSystemAdministrator();
String jarFilename = getClass().getSimpleName() + "/" + "some.jar";
when(pluginRepository.getPluginInfos()).thenReturn(of(new PluginInfo("plugKey").setName("plugName").setDescription("desc_it").setVersion(Version.create("1.0")).setLicense("license_hey").setOrganizationName("org_name").setOrganizationUrl("org_url").setHomepageUrl("homepage_url").setIssueTrackerUrl("issueTracker_url").setImplementationBuild("sou_rev_sha1").setJarFile(new File(getClass().getResource(jarFilename).toURI()))));
UpdateCenter updateCenter = mock(UpdateCenter.class);
when(updateCenterMatrixFactory.getUpdateCenter(false)).thenReturn(Optional.of(updateCenter));
when(updateCenter.findAllCompatiblePlugins()).thenReturn(Arrays.asList(Plugin.factory("plugKey").setCategory("cat_1")));
when(request.paramAsStrings(Param.FIELDS)).thenReturn(singletonList("category"));
underTest.handle(request, response);
assertJson(response.outputAsString()).isSimilarTo("{" + " \"plugins\":" + " [" + " {" + " \"key\": \"plugKey\"," + " \"name\": \"plugName\"," + " \"description\": \"desc_it\"," + " \"version\": \"1.0\"," + " \"category\":\"cat_1\"," + " \"license\": \"license_hey\"," + " \"organizationName\": \"org_name\"," + " \"organizationUrl\": \"org_url\"," + " \"homepageUrl\": \"homepage_url\"," + " \"issueTrackerUrl\": \"issueTracker_url\"," + " \"implementationBuild\": \"sou_rev_sha1\"" + " }" + " ]" + "}");
}
use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class InstalledActionTest method empty_fields_are_not_serialized_to_json.
@Test
public void empty_fields_are_not_serialized_to_json() throws Exception {
logInAsSystemAdministrator();
when(pluginRepository.getPluginInfos()).thenReturn(of(new PluginInfo("").setName("")));
underTest.handle(request, response);
assertThat(response.outputAsString()).doesNotContain("name").doesNotContain("key");
}
use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class GeneratePluginIndexTest method shouldWriteIndex.
@Test
public void shouldWriteIndex() throws IOException {
PluginRepository repository = mock(PluginRepository.class);
PluginInfo sqale = newInfo("sqale");
PluginInfo checkstyle = newInfo("checkstyle");
when(repository.getPluginInfos()).thenReturn(Arrays.asList(sqale, checkstyle));
new GeneratePluginIndex(fileSystem, repository).start();
List<String> lines = FileUtils.readLines(index);
assertThat(lines.size(), Is.is(2));
assertThat(lines.get(0), containsString("sqale"));
assertThat(lines.get(1), containsString("checkstyle"));
}
use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class ServerPluginRepository method loadPreInstalledPlugins.
/**
* Load the plugins that are located in extensions/plugins. Blacklisted plugins are
* deleted.
*/
private void loadPreInstalledPlugins() {
for (File file : listJarFiles(fs.getInstalledPluginsDir())) {
PluginInfo info = PluginInfo.create(file);
registerPluginInfo(info);
}
}
Aggregations