use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class ProjectConfigurationLoaderImplTest method return_configuration_with_global_settings_and_component_settings.
@Test
public void return_configuration_with_global_settings_and_component_settings() {
String globalKey = randomAlphanumeric(3);
String globalValue = randomAlphanumeric(4);
String componentDbKey = randomAlphanumeric(5);
String componentUuid = randomAlphanumeric(6);
String projectPropKey1 = randomAlphanumeric(7);
String projectPropValue1 = randomAlphanumeric(8);
String projectPropKey2 = randomAlphanumeric(9);
String projectPropValue2 = randomAlphanumeric(10);
globalSettings.setProperty(globalKey, globalValue);
when(propertiesDao.selectProjectProperties(dbSession, componentDbKey)).thenReturn(ImmutableList.of(newPropertyDto(projectPropKey1, projectPropValue1), newPropertyDto(projectPropKey2, projectPropValue2)));
ComponentDto component = newComponentDto(componentDbKey, componentUuid);
Map<String, Configuration> configurations = underTest.loadProjectConfigurations(dbSession, singleton(component));
assertThat(configurations).containsOnlyKeys(componentUuid);
assertThat(configurations.get(componentUuid).get(globalKey)).contains(globalValue);
assertThat(configurations.get(componentUuid).get(projectPropKey1)).contains(projectPropValue1);
assertThat(configurations.get(componentUuid).get(projectPropKey2)).contains(projectPropValue2);
}
use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class ProjectConfigurationLoaderImplTest method return_configuration_with_global_settings_main_branch_settings_and_branch_settings.
@Test
public void return_configuration_with_global_settings_main_branch_settings_and_branch_settings() {
String globalKey = randomAlphanumeric(3);
String globalValue = randomAlphanumeric(4);
String mainBranchDbKey = randomAlphanumeric(5);
String branchDbKey = mainBranchDbKey + ComponentDto.BRANCH_KEY_SEPARATOR + randomAlphabetic(5);
String branchUuid = randomAlphanumeric(6);
String mainBranchPropKey = randomAlphanumeric(7);
String mainBranchPropValue = randomAlphanumeric(8);
String branchPropKey = randomAlphanumeric(9);
String branchPropValue = randomAlphanumeric(10);
globalSettings.setProperty(globalKey, globalValue);
when(propertiesDao.selectProjectProperties(dbSession, mainBranchDbKey)).thenReturn(ImmutableList.of(newPropertyDto(mainBranchPropKey, mainBranchPropValue)));
when(propertiesDao.selectProjectProperties(dbSession, branchDbKey)).thenReturn(ImmutableList.of(newPropertyDto(branchPropKey, branchPropValue)));
ComponentDto component = newComponentDto(branchDbKey, branchUuid);
Map<String, Configuration> configurations = underTest.loadProjectConfigurations(dbSession, singleton(component));
assertThat(configurations).containsOnlyKeys(branchUuid);
assertThat(configurations.get(branchUuid).get(globalKey)).contains(globalValue);
assertThat(configurations.get(branchUuid).get(mainBranchPropKey)).contains(mainBranchPropValue);
assertThat(configurations.get(branchUuid).get(branchPropKey)).contains(branchPropValue);
}
use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class ComponentIssuesLoaderTest method loadClosedIssues_returns_only_closed_with_close_date_is_from_30_days_ago_if_property_is_not_an_integer.
@Test
@UseDataProvider("notAnIntegerPropertyValues")
public void loadClosedIssues_returns_only_closed_with_close_date_is_from_30_days_ago_if_property_is_not_an_integer(String notAnInteger) {
Configuration configuration = newConfiguration(notAnInteger);
ComponentIssuesLoader underTest = newComponentIssuesLoader(configuration);
loadClosedIssues_returns_only_closed_issues_with_close_date_is_from_30_days_ago(underTest);
}
use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class ComponentIssuesLoaderTest method loadClosedIssues_returns_only_closed_with_close_date_is_from_30_days_ago_if_property_is_less_than_0.
@Test
public void loadClosedIssues_returns_only_closed_with_close_date_is_from_30_days_ago_if_property_is_less_than_0() {
Configuration configuration = newConfiguration(String.valueOf(-(1 + new Random().nextInt(10))));
ComponentIssuesLoader underTest = newComponentIssuesLoader(configuration);
loadClosedIssues_returns_only_closed_issues_with_close_date_is_from_30_days_ago(underTest);
}
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();
}
Aggregations