Search in sources :

Example 36 with Configuration

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

the class ConfigurationRepositoryTest method project_settings_override_global_settings.

@Test
public void project_settings_override_global_settings() {
    globalSettings.setProperty("key", "value1");
    ComponentDto project = db.components().insertPrivateProject();
    insertProjectProperty(project, "key", "value2");
    analysisMetadataHolder.setProject(Project.from(project));
    Configuration config = underTest.getConfiguration();
    assertThat(config.get("key")).hasValue("value2");
}
Also used : Configuration(org.sonar.api.config.Configuration) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 37 with Configuration

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

the class ConfigurationRepositoryTest method get_project_settings_from_db.

@Test
public void get_project_settings_from_db() {
    ComponentDto project = db.components().insertPrivateProject();
    analysisMetadataHolder.setProject(Project.from(project));
    insertProjectProperty(project, "key", "value");
    Configuration config = underTest.getConfiguration();
    assertThat(config.get("key")).hasValue("value");
}
Also used : Configuration(org.sonar.api.config.Configuration) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 38 with Configuration

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

the class ConfigurationRepositoryTest method get_project_settings_from_global_settings.

@Test
public void get_project_settings_from_global_settings() {
    analysisMetadataHolder.setProject(PROJECT);
    globalSettings.setProperty("key", "value");
    Configuration config = underTest.getConfiguration();
    assertThat(config.get("key")).hasValue("value");
}
Also used : Configuration(org.sonar.api.config.Configuration) Test(org.junit.Test)

Example 39 with Configuration

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

the class ProjectConfigurationLoaderImplTest method return_configuration_with_just_global_settings_when_no_component_settings.

@Test
public void return_configuration_with_just_global_settings_when_no_component_settings() {
    String key = randomAlphanumeric(3);
    String value = randomAlphanumeric(4);
    String componentDbKey = randomAlphanumeric(5);
    String componentUuid = randomAlphanumeric(6);
    globalSettings.setProperty(key, value);
    when(propertiesDao.selectProjectProperties(dbSession, componentDbKey)).thenReturn(emptyList());
    ComponentDto component = newComponentDto(componentDbKey, componentUuid);
    Map<String, Configuration> configurations = underTest.loadProjectConfigurations(dbSession, singleton(component));
    assertThat(configurations).containsOnlyKeys(componentUuid);
    assertThat(configurations.get(componentUuid).get(key)).contains(value);
}
Also used : Configuration(org.sonar.api.config.Configuration) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 40 with Configuration

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

the class ProjectConfigurationLoaderImplTest method returns_single_configuration_for_single_project_load.

@Test
public void returns_single_configuration_for_single_project_load() {
    String key = randomAlphanumeric(3);
    String value = randomAlphanumeric(4);
    String componentDbKey = randomAlphanumeric(5);
    String componentUuid = randomAlphanumeric(6);
    globalSettings.setProperty(key, value);
    when(propertiesDao.selectProjectProperties(dbSession, componentDbKey)).thenReturn(emptyList());
    ComponentDto component = newComponentDto(componentDbKey, componentUuid);
    Configuration configuration = underTest.loadProjectConfiguration(dbSession, component);
    assertThat(configuration.get(key)).hasValue(value);
}
Also used : Configuration(org.sonar.api.config.Configuration) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Aggregations

Configuration (org.sonar.api.config.Configuration)47 Test (org.junit.Test)40 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)14 ComponentDto (org.sonar.db.component.ComponentDto)12 QGChangeEvent (org.sonar.server.qualitygate.changeevent.QGChangeEvent)7 MapSettings (org.sonar.api.config.internal.MapSettings)5 SnapshotDto (org.sonar.db.component.SnapshotDto)4 PropertyDefinitions (org.sonar.api.config.PropertyDefinitions)3 Encryption (org.sonar.api.config.internal.Encryption)3 Metric (org.sonar.api.measures.Metric)3 DefaultBranchImpl (org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl)3 HashSet (java.util.HashSet)2 DbClient (org.sonar.db.DbClient)2 BranchDto (org.sonar.db.component.BranchDto)2 LiveMeasureDto (org.sonar.db.measure.LiveMeasureDto)2 MetricDto (org.sonar.db.metric.MetricDto)2 ProjectDto (org.sonar.db.project.ProjectDto)2 EvaluatedQualityGate (org.sonar.server.qualitygate.EvaluatedQualityGate)2 QualityGate (org.sonar.server.qualitygate.QualityGate)2 File (java.io.File)1