Search in sources :

Example 26 with Settings

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

the class DefaultDatabaseTest method shouldGuessDialectFromUrl.

@Test
public void shouldGuessDialectFromUrl() {
    Settings settings = new MapSettings();
    settings.setProperty("sonar.jdbc.url", "jdbc:postgresql://localhost/sonar");
    DefaultDatabase database = new DefaultDatabase(logbackHelper, settings);
    database.initSettings();
    assertThat(database.getDialect().getId()).isEqualTo(PostgreSql.ID);
}
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 27 with Settings

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

the class PurgeConfigurationTest method do_not_delete_directory_by_default.

@Test
public void do_not_delete_directory_by_default() {
    Settings settings = new MapSettings();
    settings.setProperty(PurgeConstants.PROPERTY_CLEAN_DIRECTORY, false);
    settings.setProperty(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES, 5);
    Date now = new Date();
    PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings, new IdUuidPair(42L, "any-uuid"), Collections.emptyList());
    assertThat(underTest.scopesWithoutHistoricalData()).contains(Scopes.FILE).doesNotContain(Scopes.DIRECTORY);
    assertThat(underTest.maxLiveDateOfClosedIssues(now)).isEqualTo(DateUtils.addDays(now, -5));
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Date(java.util.Date) Test(org.junit.Test)

Example 28 with Settings

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

the class PurgeConfigurationTest method delete_directory_if_in_settings.

@Test
public void delete_directory_if_in_settings() {
    Settings settings = new MapSettings();
    settings.setProperty(PurgeConstants.PROPERTY_CLEAN_DIRECTORY, true);
    PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings, new IdUuidPair(42L, "any-uuid"), Collections.emptyList());
    assertThat(underTest.scopesWithoutHistoricalData()).contains(Scopes.DIRECTORY, Scopes.FILE);
}
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 29 with Settings

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

the class ProjectSettingsFactory method newProjectSettings.

public Settings newProjectSettings(String projectKey) {
    Settings projectSettings = new ProjectSettings(globalSettings);
    dbClient.propertiesDao().selectProjectProperties(projectKey).forEach(property -> projectSettings.setProperty(property.getKey(), property.getValue()));
    return projectSettings;
}
Also used : Settings(org.sonar.api.config.Settings)

Example 30 with Settings

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

the class ProjectSettingsFactoryTest method return_project_settings.

@Test
public void return_project_settings() {
    when(dbClient.propertiesDao().selectProjectProperties(PROJECT_KEY)).thenReturn(newArrayList(new PropertyDto().setKey("1").setValue("val1"), new PropertyDto().setKey("2").setValue("val2"), new PropertyDto().setKey("3").setValue("val3")));
    Settings projectSettings = underTest.newProjectSettings(PROJECT_KEY);
    assertThat(projectSettings.getString("1")).isEqualTo("val1");
    assertThat(projectSettings.getString("2")).isEqualTo("val2");
    assertThat(projectSettings.getString("3")).isEqualTo("val3");
}
Also used : PropertyDto(org.sonar.db.property.PropertyDto) 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