use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.
the class RegisterPluginsTest method addPlugin.
private ServerPlugin addPlugin(String key, PluginType type, @Nullable String basePlugin) throws IOException {
File file = createPluginFile(key);
PluginFilesAndMd5.FileAndMd5 jar = new PluginFilesAndMd5.FileAndMd5(file);
PluginInfo info = new PluginInfo(key).setBasePlugin(basePlugin).setJarFile(file);
ServerPlugin serverPlugin = new ServerPlugin(info, type, null, jar, null, null);
serverPluginRepository.addPlugin(serverPlugin);
return serverPlugin;
}
use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.
the class InstalledActionTest method newInstalledPluginWithCompression.
private ServerPlugin newInstalledPluginWithCompression(PluginInfo plugin) throws IOException {
FileAndMd5 jar = new FileAndMd5(temp.newFile());
FileAndMd5 compressedJar = new FileAndMd5(temp.newFile());
return new ServerPlugin(plugin, PluginType.BUNDLED, null, jar, compressedJar, null);
}
use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.
the class InstalledActionTest method commercial_plugins_from_SonarSource_has_flag_editionBundled_true_based_on_jar_info.
@Test
@UseDataProvider("editionBundledLicenseValues")
public void commercial_plugins_from_SonarSource_has_flag_editionBundled_true_based_on_jar_info(String license) throws Exception {
String jarFilename = getClass().getSimpleName() + "/" + "some.jar";
Random random = new Random();
String organization = random.nextBoolean() ? "SonarSource" : "SONARSOURCE";
String pluginKey = "plugKey";
File jar = new File(getClass().getResource(jarFilename).toURI());
when(serverPluginRepository.getPlugins()).thenReturn(asList(new ServerPlugin(new PluginInfo(pluginKey).setName("plugName").setVersion(Version.create("1.0")).setLicense(license).setOrganizationName(organization).setImplementationBuild("sou_rev_sha1"), PluginType.BUNDLED, null, new FileAndMd5(jar), new FileAndMd5(jar), null)));
db.pluginDbTester().insertPlugin(p -> p.setKee(pluginKey), p -> p.setType(Type.BUNDLED), p -> p.setFileHash("abcdplugKey"), p -> p.setUpdatedAt(111111L));
// ensure flag editionBundled is computed from jar info by enabling datacenter with other organization and license values
UpdateCenter updateCenter = mock(UpdateCenter.class);
when(updateCenterMatrixFactory.getUpdateCenter(false)).thenReturn(Optional.of(updateCenter));
when(updateCenter.findAllCompatiblePlugins()).thenReturn(singletonList(Plugin.factory(pluginKey).setOrganization("foo").setLicense("bar").setCategory("cat_1")));
String response = tester.newRequest().execute().getInput();
verifyZeroInteractions(updateCenterMatrixFactory);
assertJson(response).isSimilarTo("{" + " \"plugins\":" + " [" + " {" + " \"key\": \"plugKey\"," + " \"name\": \"plugName\"," + " \"license\": \"" + license + "\"," + " \"organizationName\": \"" + organization + "\"," + " \"editionBundled\": true" + " }" + " ]" + "}");
}
use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.
the class DownloadActionTest method newCompressedPlugin.
private ServerPlugin newCompressedPlugin() throws IOException {
FileAndMd5 jar = new FileAndMd5(temp.newFile());
FileAndMd5 compressedJar = new FileAndMd5(temp.newFile());
return new ServerPlugin(new PluginInfo("foo"), PluginType.BUNDLED, null, jar, compressedJar, null);
}
Aggregations