Search in sources :

Example 6 with ClientModuleInfo

use of org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo in project sonarlint-core by SonarSource.

the class ConnectedIssueMediumTests method declare_module_should_create_a_module_container_with_loaded_extensions.

@Test
void declare_module_should_create_a_module_container_with_loaded_extensions() throws Exception {
    sonarlint.declareModule(new ClientModuleInfo("key", aClientFileSystemWith(new OnDiskTestClientInputFile(Paths.get("main.py"), "main.py", false, StandardCharsets.UTF_8, null)))).get();
    ComponentContainer moduleContainer = sonarlint.getAnalysisEngine().getModuleRegistry().getContainerFor("key");
    assertThat(moduleContainer).isNotNull();
    assertThat(moduleContainer.getComponentsByType(SonarLintModuleFileSystem.class)).isNotEmpty();
}
Also used : OnDiskTestClientInputFile(testutils.OnDiskTestClientInputFile) ComponentContainer(org.sonarsource.sonarlint.core.plugin.commons.pico.ComponentContainer) ClientModuleInfo(org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo) Test(org.junit.jupiter.api.Test)

Example 7 with ClientModuleInfo

use of org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo in project sonarlint-core by SonarSource.

the class StandaloneIssueMediumTests method stop_module_should_stop_the_module_container.

@Test
void stop_module_should_stop_the_module_container() throws Exception {
    sonarlint.declareModule(new ClientModuleInfo("key", aClientFileSystemWith(new OnDiskTestClientInputFile(Paths.get("main.py"), "main.py", false, StandardCharsets.UTF_8, null)))).get();
    ComponentContainer moduleContainer = sonarlint.getAnalysisEngine().getModuleRegistry().getContainerFor("key");
    sonarlint.stopModule("key").get();
    assertThat(moduleContainer.getPicoContainer().getLifecycleState().isStarted()).isFalse();
}
Also used : OnDiskTestClientInputFile(testutils.OnDiskTestClientInputFile) ComponentContainer(org.sonarsource.sonarlint.core.plugin.commons.pico.ComponentContainer) ClientModuleInfo(org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo) Test(org.junit.jupiter.api.Test)

Example 8 with ClientModuleInfo

use of org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo 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)

Example 9 with ClientModuleInfo

use of org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo in project sonarlint-core by SonarSource.

the class LogMediumTests method prepare.

@BeforeEach
void prepare() throws IOException {
    logs = Multimaps.synchronizedListMultimap(LinkedListMultimap.create());
    var config = StandaloneGlobalConfiguration.builder().addPlugin(PluginLocator.getJavaScriptPluginPath()).setLogOutput(createLogOutput(logs)).setModulesProvider(() -> List.of(new ClientModuleInfo("key", mock(ClientModuleFileSystem.class)))).build();
    sonarlint = new StandaloneSonarLintEngineImpl(config);
}
Also used : ClientModuleInfo(org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with ClientModuleInfo

use of org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo in project sonarlint-core by SonarSource.

the class StandaloneNoPluginMediumTests method prepare.

@BeforeEach
void prepare() throws IOException {
    ClientLogOutput logOutput = (msg, level) -> logs.put(level, msg);
    sonarlint = new StandaloneSonarLintEngineImpl(StandaloneGlobalConfiguration.builder().setLogOutput(logOutput).setModulesProvider(() -> List.of(new ClientModuleInfo("key", mock(ClientModuleFileSystem.class)))).build());
}
Also used : LinkedListMultimap(com.google.common.collect.LinkedListMultimap) ClientLogOutput(org.sonarsource.sonarlint.core.commons.log.ClientLogOutput) BeforeEach(org.junit.jupiter.api.BeforeEach) ClientModuleInfo(org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo) ClientInputFile(org.sonarsource.sonarlint.core.analysis.api.ClientInputFile) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AnalysisResults(org.sonarsource.sonarlint.core.analysis.api.AnalysisResults) Language(org.sonarsource.sonarlint.core.commons.Language) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Multimap(com.google.common.collect.Multimap) TestUtils(testutils.TestUtils) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl) StandaloneAnalysisConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration) Test(org.junit.jupiter.api.Test) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) StandaloneGlobalConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration) TempDir(org.junit.jupiter.api.io.TempDir) ClientModuleFileSystem(org.sonarsource.sonarlint.core.analysis.api.ClientModuleFileSystem) StandaloneSonarLintEngine(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneSonarLintEngine) Mockito.mock(org.mockito.Mockito.mock) ClientLogOutput(org.sonarsource.sonarlint.core.commons.log.ClientLogOutput) ClientModuleInfo(org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ClientModuleInfo (org.sonarsource.sonarlint.core.analysis.api.ClientModuleInfo)12 Test (org.junit.jupiter.api.Test)10 OnDiskTestClientInputFile (testutils.OnDiskTestClientInputFile)7 ComponentContainer (org.sonarsource.sonarlint.core.plugin.commons.pico.ComponentContainer)5 ArrayList (java.util.ArrayList)4 StandaloneSonarLintEngineImpl (org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl)4 ClientInputFile (org.sonarsource.sonarlint.core.analysis.api.ClientInputFile)4 File (java.io.File)3 IOException (java.io.IOException)3 StandardCharsets (java.nio.charset.StandardCharsets)3 List (java.util.List)3 FileUtils (org.apache.commons.io.FileUtils)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 TempDir (org.junit.jupiter.api.io.TempDir)3 Mockito.mock (org.mockito.Mockito.mock)3 ClientModuleFileSystem (org.sonarsource.sonarlint.core.analysis.api.ClientModuleFileSystem)3 Language (org.sonarsource.sonarlint.core.commons.Language)3 Path (java.nio.file.Path)2 Paths (java.nio.file.Paths)2