use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class WebhookQGChangeEventListenerTest method onIssueChanges_calls_webhook_on_main_branch.
@Test
@UseDataProvider("newQGorNot")
public void onIssueChanges_calls_webhook_on_main_branch(@Nullable EvaluatedQualityGate newQualityGate) {
ProjectAndBranch mainBranch = insertMainBranch();
SnapshotDto analysis = insertAnalysisTask(mainBranch);
Configuration configuration = mock(Configuration.class);
QGChangeEvent qualityGateEvent = newQGChangeEvent(mainBranch, analysis, configuration, newQualityGate);
mockWebhookEnabled(qualityGateEvent.getProject());
underTest.onIssueChanges(qualityGateEvent, CHANGED_ISSUES_ARE_IGNORED);
verifyWebhookCalled(mainBranch, analysis, qualityGateEvent.getProject());
}
use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class IndexDefinitionHashTest method hash_changes_if_number_of_shards_changes.
@Test
public void hash_changes_if_number_of_shards_changes() {
Index index = Index.simple("foo");
IndexMainType mainType = IndexMainType.main(index, "bar");
Configuration emptySettings = new MapSettings().asConfig();
SettingsConfiguration defaultNbOfShards = SettingsConfiguration.newBuilder(emptySettings).build();
SettingsConfiguration specifiedDefaultNbOfShards = SettingsConfiguration.newBuilder(emptySettings).setDefaultNbOfShards(5).build();
SettingsConfiguration specifyDefaultNbOfShards = SettingsConfiguration.newBuilder(new MapSettings().setProperty("sonar.search." + index.getName() + ".shards", 1).asConfig()).setDefaultNbOfShards(1).build();
SettingsConfiguration specifiedNbOfShards = SettingsConfiguration.newBuilder(new MapSettings().setProperty("sonar.search." + index.getName() + ".shards", 10).asConfig()).setDefaultNbOfShards(5).build();
assertThat(hashOf(new TestNewIndex(mainType, defaultNbOfShards))).isEqualTo(hashOf(new TestNewIndex(mainType, defaultNbOfShards))).isEqualTo(hashOf(new TestNewIndex(mainType, specifyDefaultNbOfShards))).isNotEqualTo(hashOf(new TestNewIndex(mainType, specifiedDefaultNbOfShards))).isNotEqualTo(hashOf(new TestNewIndex(mainType, specifiedNbOfShards)));
assertThat(hashOf(new TestNewIndex(mainType, specifiedDefaultNbOfShards))).isEqualTo(hashOf(new TestNewIndex(mainType, specifiedDefaultNbOfShards))).isNotEqualTo(hashOf(new TestNewIndex(mainType, specifyDefaultNbOfShards)));
}
use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class ConfigurationProviderTest method getStringArray_on_unknown_or_non_multivalue_properties_ignores_subsequent_commas_differently_from_Settings.
@Test
@UseDataProvider("subsequentCommas2")
public void getStringArray_on_unknown_or_non_multivalue_properties_ignores_subsequent_commas_differently_from_Settings(String subsequentCommas, String[] expected) {
settings.setProperty(nonDeclaredKey, subsequentCommas);
settings.setProperty(nonMultivalueKey, subsequentCommas);
Configuration configuration = underTest.provide(settings);
getStringArrayBehaviorDiffers(configuration, nonDeclaredKey, expected);
getStringArrayBehaviorDiffers(configuration, nonMultivalueKey, expected);
}
use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class ConfigurationProviderTest method getStringArray_on_unknown_or_non_multivalue_properties_ignores_empty_fields_same_as_settings.
@Test
@UseDataProvider("emptyFields1")
public void getStringArray_on_unknown_or_non_multivalue_properties_ignores_empty_fields_same_as_settings(String emptyFields, String[] expected) {
settings.setProperty(nonDeclaredKey, emptyFields);
settings.setProperty(nonMultivalueKey, emptyFields);
Configuration configuration = underTest.provide(settings);
getStringArrayBehaviorIsTheSame(configuration, nonDeclaredKey, expected);
getStringArrayBehaviorIsTheSame(configuration, nonMultivalueKey, expected);
}
use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class ConfigurationRepositoryTest method project_settings_are_cached_to_avoid_db_access.
@Test
public void project_settings_are_cached_to_avoid_db_access() {
ComponentDto project = db.components().insertPrivateProject();
insertProjectProperty(project, "key", "value");
analysisMetadataHolder.setProject(Project.from(project));
Configuration config = underTest.getConfiguration();
assertThat(config.get("key")).hasValue("value");
db.executeUpdateSql("delete from properties");
db.commit();
assertThat(config.get("key")).hasValue("value");
}
Aggregations