use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class DefaultConfigurationTest method accessingMultiValuedPropertiesShouldBeConsistentWithDeclaration.
@Test
public void accessingMultiValuedPropertiesShouldBeConsistentWithDeclaration() {
Configuration config = new DefaultConfiguration(new PropertyDefinitions(System2.INSTANCE, Arrays.asList(PropertyDefinition.builder("single").multiValues(false).build(), PropertyDefinition.builder("multiA").multiValues(true).build())), new Encryption(null), ImmutableMap.of("single", "foo", "multiA", "a,b", "notDeclared", "c,d")) {
};
assertThat(config.get("multiA")).hasValue("a,b");
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Access to the multi-values/property set property 'multiA' should be made using 'getStringArray' method. The SonarQube plugin using this property should be updated.");
logTester.clear();
assertThat(config.getStringArray("single")).containsExactly("foo");
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Property 'single' is not declared as multi-values/property set but was read using 'getStringArray' method. The SonarQube plugin declaring this property should be updated.");
logTester.clear();
assertThat(config.get("notDeclared")).hasValue("c,d");
assertThat(config.getStringArray("notDeclared")).containsExactly("c", "d");
assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
}
use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class ProjectBuilderTest method shouldChangeProject.
@Test
public void shouldChangeProject() {
// this reactor is created and provided by Sonar
final ProjectReactor projectReactor = new ProjectReactor(ProjectDefinition.create());
ProjectBuilder builder = new ProjectBuilderSample();
final MapSettings settings = new MapSettings();
settings.setProperty("foo", "bar");
final Configuration configuration = settings.asConfig();
builder.build(new ProjectBuilderContext(projectReactor, configuration));
assertThat(projectReactor.getProjects().size(), is(2));
ProjectDefinition root = projectReactor.getRoot();
assertThat(root.getName(), is("Name changed by plugin"));
assertThat(root.getSubProjects().size(), is(1));
assertThat(root.getSubProjects().get(0).sources()).contains("src");
}
Aggregations