Search in sources :

Example 1 with MapSettings

use of org.sonarsource.sonarlint.core.analysis.sonarapi.MapSettings in project sonarlint-core by SonarSource.

the class SensorOptimizerTests method prepare.

@BeforeEach
void prepare() throws Exception {
    fs = new SonarLintFileSystem(mock(AnalysisConfiguration.class), inputFileCache);
    settings = new MapSettings(Map.of());
    optimizer = new SensorOptimizer(fs, mock(ActiveRules.class), settings.asConfig());
}
Also used : MapSettings(org.sonarsource.sonarlint.core.analysis.sonarapi.MapSettings) SonarLintFileSystem(org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.SonarLintFileSystem) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with MapSettings

use of org.sonarsource.sonarlint.core.analysis.sonarapi.MapSettings in project sonarlint-core by SonarSource.

the class SensorOptimizerTests method should_optimize_on_settings.

@Test
void should_optimize_on_settings() {
    var descriptor = new DefaultSensorDescriptor().onlyWhenConfiguration(c -> c.hasKey("sonar.foo.reportPath"));
    assertThat(optimizer.shouldExecute(descriptor)).isFalse();
    settings = new MapSettings(Map.of("sonar.foo.reportPath", "foo"));
    optimizer = new SensorOptimizer(fs, mock(ActiveRules.class), settings.asConfig());
    assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
Also used : MapSettings(org.sonarsource.sonarlint.core.analysis.sonarapi.MapSettings) DefaultSensorDescriptor(org.sonarsource.sonarlint.core.analysis.sonarapi.DefaultSensorDescriptor) Test(org.junit.jupiter.api.Test)

Example 3 with MapSettings

use of org.sonarsource.sonarlint.core.analysis.sonarapi.MapSettings in project sonarlint-core by SonarSource.

the class DefaultServerTests method coverageUnusedMethods.

@Test
void coverageUnusedMethods() {
    var runtime = mock(SonarRuntime.class);
    when(runtime.getApiVersion()).thenReturn(Version.create(2, 2));
    var metadata = new DefaultServer(new MapSettings(Map.of()), runtime);
    assertThat(metadata.getStartedAt()).isNull();
    assertThat(metadata.getContextPath()).isNull();
    assertThat(metadata.isSecured()).isFalse();
    assertThat(metadata.getPublicRootUrl()).isNull();
}
Also used : MapSettings(org.sonarsource.sonarlint.core.analysis.sonarapi.MapSettings) Test(org.junit.jupiter.api.Test)

Aggregations

MapSettings (org.sonarsource.sonarlint.core.analysis.sonarapi.MapSettings)3 Test (org.junit.jupiter.api.Test)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1 SonarLintFileSystem (org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.SonarLintFileSystem)1 DefaultSensorDescriptor (org.sonarsource.sonarlint.core.analysis.sonarapi.DefaultSensorDescriptor)1