Search in sources :

Example 16 with SonarRuntime

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

the class WebhookCallerImplTest method newSender.

private WebhookCaller newSender(boolean validateWebhook) {
    SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse("6.2"), SonarQubeSide.SERVER, SonarEdition.COMMUNITY);
    when(configuration.getBoolean(SONAR_VALIDATE_WEBHOOKS_PROPERTY)).thenReturn(Optional.of(validateWebhook));
    WebhookCustomDns webhookCustomDns = new WebhookCustomDns(configuration, networkInterfaceProvider);
    return new WebhookCallerImpl(system, new OkHttpClientProvider().provide(new MapSettings().asConfig(), runtime), webhookCustomDns);
}
Also used : MapSettings(org.sonar.api.config.internal.MapSettings) OkHttpClientProvider(org.sonar.server.util.OkHttpClientProvider) SonarRuntime(org.sonar.api.SonarRuntime)

Example 17 with SonarRuntime

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

the class StartupMetadataProviderTest method load_from_database_if_compute_engine_of_startup_leader_server.

@Test
public void load_from_database_if_compute_engine_of_startup_leader_server() {
    SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.COMPUTE_ENGINE, SonarEdition.COMMUNITY);
    testLoadingFromDatabase(runtime, true);
}
Also used : SonarRuntime(org.sonar.api.SonarRuntime) Test(org.junit.Test)

Example 18 with SonarRuntime

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

the class StartupMetadataProviderTest method load_from_database_if_compute_engine_of_startup_follower_server.

@Test
public void load_from_database_if_compute_engine_of_startup_follower_server() {
    SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.COMPUTE_ENGINE, SonarEdition.COMMUNITY);
    testLoadingFromDatabase(runtime, false);
}
Also used : SonarRuntime(org.sonar.api.SonarRuntime) Test(org.junit.Test)

Example 19 with SonarRuntime

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

the class StartupMetadataProviderTest method fail_to_load_from_database_if_properties_are_not_persisted.

@Test
public void fail_to_load_from_database_if_properties_are_not_persisted() {
    SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.COMPUTE_ENGINE, SonarEdition.COMMUNITY);
    when(webServer.isStartupLeader()).thenReturn(false);
    assertThatThrownBy(() -> underTest.provide(system, runtime, webServer, dbTester.getDbClient())).isInstanceOf(IllegalStateException.class).hasMessage("Property sonar.core.startTime is missing in database");
}
Also used : SonarRuntime(org.sonar.api.SonarRuntime) Test(org.junit.Test)

Example 20 with SonarRuntime

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

the class SonarRuntimeImplTest method sonarLint_environment.

@Test
public void sonarLint_environment() {
    SonarRuntime apiVersion = SonarRuntimeImpl.forSonarLint(A_VERSION);
    assertThat(apiVersion.getApiVersion()).isEqualTo(A_VERSION);
    assertThat(apiVersion.getProduct()).isEqualTo(SonarProduct.SONARLINT);
    try {
        apiVersion.getSonarQubeSide();
        Assertions.fail("Expected exception");
    } catch (Exception e) {
        assertThat(e).isInstanceOf(UnsupportedOperationException.class);
    }
}
Also used : SonarRuntime(org.sonar.api.SonarRuntime) 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