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);
}
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);
}
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();
}
}
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();
}
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");
}
Aggregations