Search in sources :

Example 16 with Settings

use of org.sonar.api.config.Settings in project sonarqube by SonarSource.

the class DefaultDatabaseTest method shouldGuessDefaultDriver.

@Test
public void shouldGuessDefaultDriver() {
    Settings settings = new MapSettings();
    settings.setProperty("sonar.jdbc.url", "jdbc:postgresql://localhost/sonar");
    DefaultDatabase database = new DefaultDatabase(logbackHelper, settings);
    database.initSettings();
    assertThat(database.getProperties().getProperty("sonar.jdbc.driverClassName")).isEqualTo("org.postgresql.Driver");
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Example 17 with Settings

use of org.sonar.api.config.Settings in project sonarqube by SonarSource.

the class DefaultDatabaseTest method shouldCompleteProperties.

@Test
public void shouldCompleteProperties() {
    Settings settings = new MapSettings();
    DefaultDatabase db = new DefaultDatabase(logbackHelper, settings) {

        @Override
        protected void doCompleteProperties(Properties properties) {
            properties.setProperty("sonar.jdbc.maxActive", "2");
        }
    };
    db.initSettings();
    Properties props = db.getProperties();
    assertThat(props.getProperty("sonar.jdbc.maxActive")).isEqualTo("2");
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Properties(java.util.Properties) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Example 18 with Settings

use of org.sonar.api.config.Settings in project sonarqube by SonarSource.

the class SettingsRepositoryTest method get_project_settings_from_db.

@Test
public void get_project_settings_from_db() {
    ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert()).setKey(ROOT.getKey());
    dbClient.componentDao().insert(session, project);
    dbClient.propertiesDao().saveProperty(session, new PropertyDto().setResourceId(project.getId()).setKey("key").setValue("value"));
    session.commit();
    Settings settings = underTest.getSettings(ROOT);
    assertThat(settings.getString("key")).isEqualTo("value");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) PropertyDto(org.sonar.db.property.PropertyDto) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Example 19 with Settings

use of org.sonar.api.config.Settings in project sonarqube by SonarSource.

the class NotificationDaemonTest method setUpMocks.

private void setUpMocks() {
    when(emailChannel.getKey()).thenReturn("email");
    when(gtalkChannel.getKey()).thenReturn("gtalk");
    when(commentOnIssueAssignedToMe.getKey()).thenReturn("CommentOnIssueAssignedToMe");
    when(commentOnIssueAssignedToMe.getType()).thenReturn("issue-changes");
    when(commentOnIssueCreatedByMe.getKey()).thenReturn("CommentOnIssueCreatedByMe");
    when(commentOnIssueCreatedByMe.getType()).thenReturn("issue-changes");
    when(qualityGateChange.getKey()).thenReturn("QGateChange");
    when(qualityGateChange.getType()).thenReturn("qgate-changes");
    when(manager.getFromQueue()).thenReturn(notification).thenReturn(null);
    Settings settings = new MapSettings().setProperty("sonar.notifications.delay", 1L);
    underTest = new NotificationDaemon(settings, manager, service);
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings)

Example 20 with Settings

use of org.sonar.api.config.Settings in project sonarqube by SonarSource.

the class NotificationDaemonTest method getDispatchers_empty.

@Test
public void getDispatchers_empty() {
    Settings settings = new MapSettings().setProperty("sonar.notifications.delay", 1L);
    service = new NotificationService(dbClient);
    assertThat(service.getDispatchers()).hasSize(0);
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Aggregations

Settings (org.sonar.api.config.Settings)52 MapSettings (org.sonar.api.config.MapSettings)43 Test (org.junit.Test)41 Before (org.junit.Before)5 Languages (org.sonar.api.resources.Languages)5 FileExclusions (org.sonar.api.scan.filesystem.FileExclusions)5 DefaultLanguagesRepository (org.sonar.scanner.repository.language.DefaultLanguagesRepository)5 LanguagesRepository (org.sonar.scanner.repository.language.LanguagesRepository)5 IndexedFile (org.sonar.api.batch.fs.IndexedFile)4 DefaultIndexedFile (org.sonar.api.batch.fs.internal.DefaultIndexedFile)4 File (java.io.File)3 String.format (java.lang.String.format)3 TransportClient (org.elasticsearch.client.transport.TransportClient)3 PropertyDto (org.sonar.db.property.PropertyDto)3 InetAddress (java.net.InetAddress)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Condition (org.assertj.core.api.Condition)2 TransportAddress (org.elasticsearch.common.transport.TransportAddress)2 Rule (org.junit.Rule)2 ExpectedException (org.junit.rules.ExpectedException)2