Search in sources :

Example 6 with MapSettings

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

the class IndexCreatorTest method create_index.

@Test
public void create_index() throws Exception {
    assertThat(mappings()).isEmpty();
    IndexDefinitions registry = new IndexDefinitions(new IndexDefinition[] { new FakeIndexDefinition() }, new MapSettings());
    registry.start();
    IndexCreator creator = new IndexCreator(es.client(), registry);
    creator.start();
    // check that index is created with related mapping
    ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = mappings();
    MappingMetaData mapping = mappings.get("fakes").get("fake");
    assertThat(mapping.type()).isEqualTo("fake");
    assertThat(mapping.getSourceAsMap()).isNotEmpty();
    assertThat(countMappingFields(mapping)).isEqualTo(2);
    assertThat(field(mapping, "updatedAt").get("type")).isEqualTo("date");
    assertThat(setting("fakes", "index.sonar_hash")).isNotEmpty();
    // of course do not delete indices on stop
    creator.stop();
    assertThat(mappings()).isNotEmpty();
}
Also used : MapSettings(org.sonar.api.config.MapSettings) ImmutableOpenMap(org.elasticsearch.common.collect.ImmutableOpenMap) MappingMetaData(org.elasticsearch.cluster.metadata.MappingMetaData) Test(org.junit.Test)

Example 7 with MapSettings

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

the class NewIndexTest method default_shards_and_replicas.

@Test
public void default_shards_and_replicas() {
    NewIndex index = new NewIndex("issues");
    index.configureShards(new MapSettings(), 5);
    assertThat(index.getSettings().get(IndexMetaData.SETTING_NUMBER_OF_SHARDS)).isEqualTo("5");
    assertThat(index.getSettings().get(IndexMetaData.SETTING_NUMBER_OF_REPLICAS)).isEqualTo("0");
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Example 8 with MapSettings

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

the class NewIndexTest method customize_number_of_shards.

@Test
public void customize_number_of_shards() {
    NewIndex index = new NewIndex("issues");
    MapSettings settings = new MapSettings();
    settings.setProperty("sonar.search.issues.shards", "3");
    index.configureShards(settings, 5);
    assertThat(index.getSettings().get(IndexMetaData.SETTING_NUMBER_OF_SHARDS)).isEqualTo("3");
    // keep default value
    assertThat(index.getSettings().get(IndexMetaData.SETTING_NUMBER_OF_REPLICAS)).isEqualTo("0");
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Example 9 with MapSettings

use of org.sonar.api.config.MapSettings 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 10 with MapSettings

use of org.sonar.api.config.MapSettings 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

MapSettings (org.sonar.api.config.MapSettings)98 Test (org.junit.Test)75 Settings (org.sonar.api.config.Settings)36 Before (org.junit.Before)20 URI (java.net.URI)13 Languages (org.sonar.api.resources.Languages)9 DefaultLanguagesRepository (org.sonar.scanner.repository.language.DefaultLanguagesRepository)9 LanguagesRepository (org.sonar.scanner.repository.language.LanguagesRepository)8 File (java.io.File)7 SensorStorage (org.sonar.api.batch.sensor.internal.SensorStorage)7 FileExclusions (org.sonar.api.scan.filesystem.FileExclusions)6 Properties (java.util.Properties)5 IndexedFile (org.sonar.api.batch.fs.IndexedFile)5 DefaultFileSystem (org.sonar.api.batch.fs.internal.DefaultFileSystem)5 DefaultIndexedFile (org.sonar.api.batch.fs.internal.DefaultIndexedFile)5 PropertyDefinitions (org.sonar.api.config.PropertyDefinitions)5 InputFile (org.sonar.api.batch.fs.InputFile)4 InputStream (java.io.InputStream)3 Description (org.hamcrest.Description)3 CoreProperties (org.sonar.api.CoreProperties)3