Search in sources :

Example 6 with PropertyDefinitions

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

the class SettingsMonitor method attributes.

@Override
public SortedMap<String, Object> attributes() {
    PropertyDefinitions definitions = settings.getDefinitions();
    ImmutableSortedMap.Builder<String, Object> builder = ImmutableSortedMap.naturalOrder();
    for (Map.Entry<String, String> prop : settings.getProperties().entrySet()) {
        String key = prop.getKey();
        PropertyDefinition def = definitions.get(key);
        if (def == null || def.type() != PropertyType.PASSWORD) {
            builder.put(key, abbreviate(prop.getValue(), MAX_VALUE_LENGTH));
        }
    }
    return builder.build();
}
Also used : PropertyDefinitions(org.sonar.api.config.PropertyDefinitions) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) Map(java.util.Map) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) SortedMap(java.util.SortedMap) PropertyDefinition(org.sonar.api.config.PropertyDefinition)

Example 7 with PropertyDefinitions

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

the class RenameDeprecatedPropertyKeysTest method should_rename_deprecated_keys.

@Test
public void should_rename_deprecated_keys() {
    PropertiesDao dao = mock(PropertiesDao.class);
    PropertyDefinitions definitions = new PropertyDefinitions(FakeExtension.class);
    RenameDeprecatedPropertyKeys task = new RenameDeprecatedPropertyKeys(dao, definitions);
    task.start();
    verify(dao).renamePropertyKey("old_key", "new_key");
    verifyNoMoreInteractions(dao);
}
Also used : PropertyDefinitions(org.sonar.api.config.PropertyDefinitions) PropertiesDao(org.sonar.db.property.PropertiesDao) Test(org.junit.Test)

Example 8 with PropertyDefinitions

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

the class ThreadLocalSettingsTest method create.

private ThreadLocalSettings create(Map<String, String> systemProps) {
    Properties p = new Properties();
    p.putAll(systemProps);
    return new ThreadLocalSettings(new PropertyDefinitions(), p, dbSettingLoader);
}
Also used : PropertyDefinitions(org.sonar.api.config.PropertyDefinitions) Properties(java.util.Properties)

Example 9 with PropertyDefinitions

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

the class ComponentContainerTest method shouldDeclareExtensionWithoutAddingIt.

@Test
public void shouldDeclareExtensionWithoutAddingIt() {
    ComponentContainer container = new ComponentContainer();
    PluginInfo plugin = mock(PluginInfo.class);
    container.declareExtension(plugin, ComponentWithProperty.class);
    PropertyDefinitions propertyDefinitions = container.getComponentByType(PropertyDefinitions.class);
    assertThat(propertyDefinitions.get("foo")).isNotNull();
    assertThat(container.getComponentByType(ComponentWithProperty.class)).isNull();
}
Also used : PropertyDefinitions(org.sonar.api.config.PropertyDefinitions) Test(org.junit.Test)

Example 10 with PropertyDefinitions

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

the class GenericCoverageSensorTest method migrateOldProperties.

@Test
public void migrateOldProperties() {
    Settings settings = new MapSettings(new PropertyDefinitions(GenericCoverageSensor.properties()));
    settings.setProperty(GenericCoverageSensor.OLD_REPORT_PATH_PROPERTY_KEY, "old.xml");
    settings.setProperty(GenericCoverageSensor.OLD_COVERAGE_REPORT_PATHS_PROPERTY_KEY, "old1.xml,old2.xml");
    settings.setProperty(GenericCoverageSensor.OLD_IT_COVERAGE_REPORT_PATHS_PROPERTY_KEY, "old3.xml,old4.xml,old.xml");
    settings.setProperty(GenericCoverageSensor.OLD_OVERALL_COVERAGE_REPORT_PATHS_PROPERTY_KEY, "old5.xml,old6.xml");
    new GenericCoverageSensor(settings).execute();
    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Property 'sonar.genericcoverage.reportPath' is deprecated. Please use 'sonar.coverageReportPaths' instead.", "Property 'sonar.genericcoverage.reportPaths' is deprecated. Please use 'sonar.coverageReportPaths' instead.", "Property 'sonar.genericcoverage.itReportPaths' is deprecated. Please use 'sonar.coverageReportPaths' instead.", "Property 'sonar.genericcoverage.overallReportPaths' is deprecated. Please use 'sonar.coverageReportPaths' instead.");
    assertThat(settings.getStringArray(GenericCoverageSensor.REPORT_PATHS_PROPERTY_KEY)).containsOnly("old.xml", "old1.xml", "old2.xml", "old3.xml", "old4.xml", "old5.xml", "old6.xml");
}
Also used : MapSettings(org.sonar.api.config.MapSettings) PropertyDefinitions(org.sonar.api.config.PropertyDefinitions) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Aggregations

PropertyDefinitions (org.sonar.api.config.PropertyDefinitions)14 Test (org.junit.Test)8 MapSettings (org.sonar.api.config.MapSettings)5 Before (org.junit.Before)4 Settings (org.sonar.api.config.Settings)2 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 File (java.io.File)1 Map (java.util.Map)1 Properties (java.util.Properties)1 SortedMap (java.util.SortedMap)1 SensorContextTester (org.sonar.api.batch.sensor.internal.SensorContextTester)1 PropertyDefinition (org.sonar.api.config.PropertyDefinition)1 PropertiesDao (org.sonar.db.property.PropertiesDao)1 DefaultAnalysisMode (org.sonar.scanner.analysis.DefaultAnalysisMode)1 GlobalMode (org.sonar.scanner.bootstrap.GlobalMode)1 GlobalProperties (org.sonar.scanner.bootstrap.GlobalProperties)1 GlobalSettings (org.sonar.scanner.bootstrap.GlobalSettings)1