Search in sources :

Example 6 with NodeJsHelper

use of org.sonarsource.sonarlint.core.NodeJsHelper in project sonarlint-core by SonarSource.

the class ConnectedIssueMediumTests method prepare.

@BeforeAll
static void prepare(@TempDir Path slHome) throws Exception {
    var storage = newStorage(SERVER_ID).withJSPlugin().withJavaPlugin().withProject("test-project").withProject(JAVA_MODULE_KEY, project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule("java:S106", "MAJOR").withActiveRule("java:S1220", "MINOR").withActiveRule("java:S1481", "BLOCKER"))).withProject("stale_module", ProjectStorageFixture.ProjectStorageBuilder::stale).create(slHome);
    var nodeJsHelper = new NodeJsHelper();
    nodeJsHelper.detect(null);
    var config = ConnectedGlobalConfiguration.builder().setConnectionId(SERVER_ID).setSonarLintUserHome(slHome).setStorageRoot(storage.getPath()).setLogOutput(createNoOpLogOutput()).addEnabledLanguages(Language.JAVA, Language.JS).setNodeJs(nodeJsHelper.getNodeJsPath(), nodeJsHelper.getNodeJsVersion()).setModulesProvider(() -> List.of(new ClientModuleInfo("key", mock(ClientModuleFileSystem.class)))).build();
    sonarlint = new ConnectedSonarLintEngineImpl(config);
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ConnectedSonarLintEngineImpl(org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl) MockWebServerExtensionWithProtobuf(org.sonarsource.sonarlint.core.MockWebServerExtensionWithProtobuf) Language(org.sonarsource.sonarlint.core.commons.Language) ConnectedAnalysisConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration) TestUtils(testutils.TestUtils) StringUtils(org.apache.commons.lang3.StringUtils) ConnectedGlobalConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ConnectedGlobalConfiguration) StorageFixture.newStorage(org.sonarsource.sonarlint.core.mediumtest.fixtures.StorageFixture.newStorage) ArrayList(java.util.ArrayList) AfterAll(org.junit.jupiter.api.AfterAll) SonarLintModuleFileSystem(org.sonarsource.sonarlint.core.analysis.sonarapi.SonarLintModuleFileSystem) Rules(org.sonarqube.ws.Rules) IssueListener(org.sonarsource.sonarlint.core.client.api.common.analysis.IssueListener) ModuleFileListener(org.sonarsource.sonarlint.plugin.api.module.file.ModuleFileListener) BeforeAll(org.junit.jupiter.api.BeforeAll) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) OnDiskTestClientInputFile(testutils.OnDiskTestClientInputFile) ProjectStorageFixture(org.sonarsource.sonarlint.core.mediumtest.fixtures.ProjectStorageFixture) TestUtils.createNoOpIssueListener(testutils.TestUtils.createNoOpIssueListener) Path(java.nio.file.Path) ClientModuleFileSystem(org.sonarsource.sonarlint.core.analysis.api.ClientModuleFileSystem) MockWebServerExtension.httpClient(org.sonarsource.sonarlint.core.commons.testutils.MockWebServerExtension.httpClient) TestUtils.createNoOpLogOutput(testutils.TestUtils.createNoOpLogOutput) ClientFileSystemFixtures.anEmptyClientFileSystem(org.sonarsource.sonarlint.core.client.api.common.ClientFileSystemFixtures.anEmptyClientFileSystem) ClientModuleInfo(org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo) StorageException(org.sonarsource.sonarlint.core.client.api.exceptions.StorageException) Assertions.tuple(org.assertj.core.api.Assertions.tuple) ClientInputFile(org.sonarsource.sonarlint.core.analysis.api.ClientInputFile) ClientFileSystemFixtures.aClientFileSystemWith(org.sonarsource.sonarlint.core.client.api.common.ClientFileSystemFixtures.aClientFileSystemWith) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) ClientModuleFileEvent(org.sonarsource.sonarlint.core.analysis.api.ClientModuleFileEvent) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) ModuleFileEvent(org.sonarsource.sonarlint.plugin.api.module.file.ModuleFileEvent) List(java.util.List) Assertions.fail(org.assertj.core.api.Assertions.fail) SonarLintSide(org.sonarsource.api.sonarlint.SonarLintSide) Paths(java.nio.file.Paths) TempDir(org.junit.jupiter.api.io.TempDir) Issue(org.sonarsource.sonarlint.core.client.api.common.analysis.Issue) ComponentContainer(org.sonarsource.sonarlint.core.plugin.commons.pico.ComponentContainer) NodeJsHelper(org.sonarsource.sonarlint.core.NodeJsHelper) Mockito.mock(org.mockito.Mockito.mock) NodeJsHelper(org.sonarsource.sonarlint.core.NodeJsHelper) ClientModuleInfo(org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo) ConnectedSonarLintEngineImpl(org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl) ProjectStorageFixture(org.sonarsource.sonarlint.core.mediumtest.fixtures.ProjectStorageFixture) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

NodeJsHelper (org.sonarsource.sonarlint.core.NodeJsHelper)6 ConnectedSonarLintEngineImpl (org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl)5 BeforeAll (org.junit.jupiter.api.BeforeAll)4 HashMap (java.util.HashMap)3 ProjectStorageFixture (org.sonarsource.sonarlint.core.mediumtest.fixtures.ProjectStorageFixture)3 File (java.io.File)2 ClientModuleInfo (org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo)2 IOException (java.io.IOException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Random (java.util.Random)1 DefaultExecutor (org.apache.commons.exec.DefaultExecutor)1 FileUtils (org.apache.commons.io.FileUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.fail (org.assertj.core.api.Assertions.fail)1 Assertions.tuple (org.assertj.core.api.Assertions.tuple)1