Search in sources :

Example 41 with MapSettings

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

the class QualityGateLoadingStepTest method execute_sets_default_QualityGate_when_project_has_no_settings.

@Test
public void execute_sets_default_QualityGate_when_project_has_no_settings() {
    ReportComponent root = ReportComponent.builder(Component.Type.PROJECT, 1).setKey(PROJECT_KEY).addChildren(ReportComponent.builder(Component.Type.FILE, 2).build()).build();
    treeRootHolder.setRoot(root);
    when(settingsRepository.getSettings(root)).thenReturn(new MapSettings());
    underTest.execute();
    verifyNoQualityGate();
    // verify only project is processed
    verify(settingsRepository).getSettings(root);
    verifyNoMoreInteractions(settingsRepository);
}
Also used : MapSettings(org.sonar.api.config.MapSettings) ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent) Test(org.junit.Test)

Example 42 with MapSettings

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

the class QualityGateLoadingStepTest method execute_sets_QualityGate_if_it_can_be_found_by_service.

@Test
public void execute_sets_QualityGate_if_it_can_be_found_by_service() {
    QualityGate qualityGate = new QualityGate(465, "name", Collections.<Condition>emptyList());
    treeRootHolder.setRoot(PROJECT_ALONE);
    when(settingsRepository.getSettings(PROJECT_ALONE)).thenReturn(new MapSettings().setProperty("sonar.qualitygate", 10));
    when(qualityGateService.findById(10)).thenReturn(Optional.of(qualityGate));
    underTest.execute();
    assertThat(mutableQualityGateHolder.getQualityGate().get()).isSameAs(qualityGate);
}
Also used : MapSettings(org.sonar.api.config.MapSettings) QualityGate(org.sonar.server.computation.task.projectanalysis.qualitygate.QualityGate) Test(org.junit.Test)

Example 43 with MapSettings

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

the class EsTester method before.

@Override
protected void before() throws Throwable {
    truncateIndices();
    if (!indexDefinitions.isEmpty()) {
        container = new ComponentContainer();
        container.addSingleton(new MapSettings());
        container.addSingletons(indexDefinitions);
        container.addSingleton(client);
        container.addSingleton(IndexDefinitions.class);
        container.addSingleton(IndexCreator.class);
        container.startComponents();
    }
}
Also used : MapSettings(org.sonar.api.config.MapSettings) ComponentContainer(org.sonar.core.platform.ComponentContainer)

Example 44 with MapSettings

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

the class IndexCreatorTest method recreate_index_on_definition_changes.

@Test
public void recreate_index_on_definition_changes() throws Exception {
    assertThat(mappings()).isEmpty();
    // v1
    IndexDefinitions registry = new IndexDefinitions(new IndexDefinition[] { new FakeIndexDefinition() }, new MapSettings());
    registry.start();
    IndexCreator creator = new IndexCreator(es.client(), registry);
    creator.start();
    creator.stop();
    String hashV1 = setting("fakes", "index.sonar_hash");
    assertThat(hashV1).isNotEmpty();
    // v2
    registry = new IndexDefinitions(new IndexDefinition[] { new FakeIndexDefinitionV2() }, new MapSettings());
    registry.start();
    creator = new IndexCreator(es.client(), registry);
    creator.start();
    ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = mappings();
    MappingMetaData mapping = mappings.get("fakes").get("fake");
    assertThat(countMappingFields(mapping)).isEqualTo(3);
    assertThat(field(mapping, "updatedAt").get("type")).isEqualTo("date");
    assertThat(field(mapping, "newField").get("type")).isEqualTo("integer");
    String hashV2 = setting("fakes", "index.sonar_hash");
    assertThat(hashV2).isNotEqualTo(hashV1);
    creator.stop();
}
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 45 with MapSettings

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

the class NewIndexTest method customize_number_of_shards_and_replicas.

@Test
public void customize_number_of_shards_and_replicas() {
    NewIndex index = new NewIndex("issues");
    MapSettings settings = new MapSettings();
    settings.setProperty("sonar.search.issues.shards", "3");
    settings.setProperty("sonar.search.issues.replicas", "1");
    index.configureShards(settings, 5);
    assertThat(index.getSettings().get(IndexMetaData.SETTING_NUMBER_OF_SHARDS)).isEqualTo("3");
    assertThat(index.getSettings().get(IndexMetaData.SETTING_NUMBER_OF_REPLICAS)).isEqualTo("1");
}
Also used : 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