Search in sources :

Example 1 with SonarRuntime

use of org.sonar.api.SonarRuntime in project sonarqube by SonarSource.

the class XooPluginTest method provide_extensions_for_5_5.

@Test
public void provide_extensions_for_5_5() {
    SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse("5.5"), SonarQubeSide.SCANNER);
    Plugin.Context context = new Plugin.Context(runtime);
    new XooPlugin().define(context);
    assertThat(context.getExtensions()).hasSize(47).contains(CpdTokenizerSensor.class);
}
Also used : SonarRuntime(org.sonar.api.SonarRuntime) Plugin(org.sonar.api.Plugin) Test(org.junit.Test)

Example 2 with SonarRuntime

use of org.sonar.api.SonarRuntime in project sonarlint-core by SonarSource.

the class DefaultServerTest method coverageUnusedMethods.

@Test
public void coverageUnusedMethods() {
    SonarRuntime runtime = mock(SonarRuntime.class);
    when(runtime.getApiVersion()).thenReturn(Version.create(2, 2));
    DefaultServer metadata = new DefaultServer(new MapSettings(), runtime);
    assertThat(metadata.getStartedAt()).isNull();
    assertThat(metadata.getRootDir()).isNull();
    assertThat(metadata.getContextPath()).isNull();
    assertThat(metadata.isSecured()).isFalse();
    assertThat(metadata.isDev()).isFalse();
    assertThat(metadata.getPublicRootUrl()).isNull();
}
Also used : MapSettings(org.sonar.api.config.internal.MapSettings) SonarRuntime(org.sonar.api.SonarRuntime) Test(org.junit.Test)

Example 3 with SonarRuntime

use of org.sonar.api.SonarRuntime in project sonar-java by SonarSource.

the class JavaPluginTest method sonarLint_6_7_extensions.

@Test
public void sonarLint_6_7_extensions() {
    SonarRuntime runtime = SonarRuntimeImpl.forSonarLint(VERSION_6_7);
    Plugin.Context context = new Plugin.Context(runtime);
    javaPlugin.define(context);
    assertThat(context.getExtensions()).hasSize(14);
}
Also used : SonarRuntime(org.sonar.api.SonarRuntime) Plugin(org.sonar.api.Plugin) Test(org.junit.Test)

Example 4 with SonarRuntime

use of org.sonar.api.SonarRuntime in project sonar-go by SonarSource.

the class GoPluginTest method count_extension_points.

@Test
void count_extension_points() {
    SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 7), SonarQubeSide.SCANNER);
    Plugin.Context context = new Plugin.Context(runtime);
    Plugin underTest = new GoPlugin();
    underTest.define(context);
    assertThat(context.getExtensions()).hasSize(6);
}
Also used : SonarRuntime(org.sonar.api.SonarRuntime) Plugin(org.sonar.api.Plugin) Test(org.junit.jupiter.api.Test)

Example 5 with SonarRuntime

use of org.sonar.api.SonarRuntime in project sonarqube by SonarSource.

the class XooPluginTest method provide_extensions_for_sonar_lint.

@Test
public void provide_extensions_for_sonar_lint() {
    SonarRuntime runtime = SonarRuntimeImpl.forSonarLint(Version.parse("5.4"));
    Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(runtime).build();
    new XooPlugin().define(context);
    assertThat(getExtensions(context)).isNotEmpty().doesNotContain(MeasureSensor.class);
}
Also used : SonarRuntime(org.sonar.api.SonarRuntime) Plugin(org.sonar.api.Plugin) Test(org.junit.Test)

Aggregations

SonarRuntime (org.sonar.api.SonarRuntime)21 Test (org.junit.Test)18 Plugin (org.sonar.api.Plugin)7 CheckFactory (org.sonar.api.batch.rule.CheckFactory)4 DefaultActiveRules (org.sonar.api.batch.rule.internal.DefaultActiveRules)4 DefaultSensorDescriptor (org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor)3 MapSettings (org.sonar.api.config.internal.MapSettings)3 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 Test (org.junit.jupiter.api.Test)1 InputFile (org.sonar.api.batch.fs.InputFile)1 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)1 ActiveRules (org.sonar.api.batch.rule.ActiveRules)1 NewActiveRule (org.sonar.api.batch.rule.internal.NewActiveRule)1 Settings (org.sonar.api.config.Settings)1 NoSonarFilter (org.sonar.api.issue.NoSonarFilter)1 FileLinesContext (org.sonar.api.measures.FileLinesContext)1 FileLinesContextFactory (org.sonar.api.measures.FileLinesContextFactory)1 RulesDefinition (org.sonar.api.server.rule.RulesDefinition)1 HtmlRulesDefinition (org.sonar.plugins.html.rules.HtmlRulesDefinition)1