use of org.sonarsource.sonarlint.core.client.api.connected.ConnectedGlobalConfiguration in project sonarlint-core by SonarSource.
the class ConnectedIssueExclusionsMediumTest method prepare.
@BeforeClass
public static void prepare() throws Exception {
Path slHome = temp.newFolder().toPath();
Path pluginCache = slHome.resolve("plugins");
/*
* This storage contains one server id "local" and two modules: "test-project" (with an empty QP) and "test-project-2" (with default QP)
*/
Path storage = Paths.get(ConnectedIssueExclusionsMediumTest.class.getResource("/sample-storage").toURI());
Path tmpStorage = slHome.resolve("storage");
FileUtils.copyDirectory(storage.toFile(), tmpStorage.toFile());
PluginCache cache = PluginCache.create(pluginCache);
PluginReferences.Builder builder = PluginReferences.newBuilder();
builder.addReference(PluginReference.newBuilder().setFilename(PluginLocator.SONAR_JAVA_PLUGIN_JAR).setHash(PluginLocator.SONAR_JAVA_PLUGIN_JAR_HASH).setKey("java").build());
cache.get(PluginLocator.SONAR_JAVA_PLUGIN_JAR, PluginLocator.SONAR_JAVA_PLUGIN_JAR_HASH, (filename, target) -> FileUtils.copyURLToFile(PluginLocator.getJavaPluginUrl(), target.toFile()));
ProtobufUtil.writeToFile(builder.build(), tmpStorage.resolve("local").resolve("global").resolve(StoragePaths.PLUGIN_REFERENCES_PB));
// update versions in test storage and create an empty stale module storage
writeModuleStatus(tmpStorage, "test-project", VersionUtils.getLibraryVersion());
writeModuleStatus(tmpStorage, JAVA_MODULE_KEY, VersionUtils.getLibraryVersion());
writeStatus(tmpStorage, VersionUtils.getLibraryVersion());
ConnectedGlobalConfiguration config = ConnectedGlobalConfiguration.builder().setServerId("local").setSonarLintUserHome(slHome).setStorageRoot(tmpStorage).setLogOutput(createNoOpLogOutput()).build();
sonarlint = new ConnectedSonarLintEngineImpl(config);
storagePaths = sonarlint.getGlobalContainer().getComponentByType(StoragePaths.class);
storageReader = sonarlint.getGlobalContainer().getComponentByType(StorageReader.class);
originalModuleConfig = storageReader.readModuleConfig(JAVA_MODULE_KEY);
baseDir = temp.newFolder();
}
Aggregations