Search in sources :

Example 1 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 2 with PropertyDefinitions

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

the class ComponentContainerTest method shouldDeclareComponentProperties.

@Test
public void shouldDeclareComponentProperties() {
    ComponentContainer container = new ComponentContainer();
    container.addSingleton(ComponentWithProperty.class);
    PropertyDefinitions propertyDefinitions = container.getComponentByType(PropertyDefinitions.class);
    assertThat(propertyDefinitions.get("foo")).isNotNull();
    assertThat(propertyDefinitions.get("foo").defaultValue()).isEqualTo("bar");
}
Also used : PropertyDefinitions(org.sonar.api.config.PropertyDefinitions) Test(org.junit.Test)

Example 3 with PropertyDefinitions

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

the class ComponentContainerTest method shouldDeclareExtensionWhenAdding.

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

Example 4 with PropertyDefinitions

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

the class GlobalSettingsTest method should_load_global_settings.

@Test
public void should_load_global_settings() {
    when(settingsLoader.load(null)).thenReturn(ImmutableMap.of("sonar.cpd.cross", "true"));
    GlobalSettings batchSettings = new GlobalSettings(bootstrapProps, new PropertyDefinitions(), settingsLoader, mode);
    assertThat(batchSettings.getBoolean("sonar.cpd.cross")).isTrue();
}
Also used : PropertyDefinitions(org.sonar.api.config.PropertyDefinitions) Test(org.junit.Test)

Example 5 with PropertyDefinitions

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

the class IssueExclusionPatternInitializerTest method init.

@Before
public void init() {
    settings = new MapSettings(new PropertyDefinitions(IssueExclusionProperties.all()));
    patternsInitializer = new IssueExclusionPatternInitializer(settings);
}
Also used : MapSettings(org.sonar.api.config.MapSettings) PropertyDefinitions(org.sonar.api.config.PropertyDefinitions) Before(org.junit.Before)

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