|
|
@@ -28,6 +28,7 @@ import org.sonar.api.config.Configuration; |
|
|
|
import org.sonar.api.config.Encryption; |
|
|
|
import org.sonar.api.config.PropertyDefinition; |
|
|
|
import org.sonar.api.config.PropertyDefinitions; |
|
|
|
import org.sonar.api.config.PropertyFieldDefinition; |
|
|
|
import org.sonar.api.utils.log.LogTester; |
|
|
|
import org.sonar.api.utils.log.LoggerLevel; |
|
|
|
|
|
|
@@ -51,13 +52,15 @@ public class DefaultConfigurationTest { |
|
|
|
|
|
|
|
assertThat(config.get("multiA")).hasValue("a,b"); |
|
|
|
assertThat(logTester.logs(LoggerLevel.WARN)) |
|
|
|
.contains("Access to the multi-valued property 'multiA' should be made using 'getStringArray' method. The SonarQube plugin using this property should be updated."); |
|
|
|
.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-valued but was read using 'getStringArray' method. The SonarQube plugin declaring this property should be updated."); |
|
|
|
.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(); |
|
|
|
|
|
|
@@ -66,6 +69,26 @@ public class DefaultConfigurationTest { |
|
|
|
assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty(); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void accessingPropertySetPropertiesShouldBeConsistentWithDeclaration() { |
|
|
|
Configuration config = new DefaultConfiguration(new PropertyDefinitions(Arrays.asList( |
|
|
|
PropertyDefinition.builder("props").fields(PropertyFieldDefinition.build("foo1").name("Foo1").build(), PropertyFieldDefinition.build("foo2").name("Foo2").build()).build())), |
|
|
|
new Encryption(null), |
|
|
|
mock(AnalysisMode.class), |
|
|
|
ImmutableMap.of("props", "1,2", "props.1.foo1", "a", "props.1.foo2", "b")) { |
|
|
|
}; |
|
|
|
|
|
|
|
assertThat(config.get("props")).hasValue("1,2"); |
|
|
|
assertThat(logTester.logs(LoggerLevel.WARN)) |
|
|
|
.contains( |
|
|
|
"Access to the multi-values/property set property 'props' should be made using 'getStringArray' method. The SonarQube plugin using this property should be updated."); |
|
|
|
|
|
|
|
logTester.clear(); |
|
|
|
|
|
|
|
assertThat(config.getStringArray("props")).containsExactly("1", "2"); |
|
|
|
assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty(); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void getDefaultValues() { |
|
|
|
Configuration config = new DefaultConfiguration(new PropertyDefinitions(Arrays.asList( |