}
private void addSettingsToChildrenModules(ProjectReferentials ref, String projectKey, Map<String, String> parentProperties, boolean hasScanPerm, DbSession session) {
- parentProperties.putAll(getPropertiesMap(propertiesDao.selectProjectProperties(projectKey, session), hasScanPerm));
- addSettings(ref, projectKey, parentProperties);
+ Map<String, String> currentParentProperties = newHashMap();
+ currentParentProperties.putAll(parentProperties);
+ currentParentProperties.putAll(getPropertiesMap(propertiesDao.selectProjectProperties(projectKey, session), hasScanPerm));
+ addSettings(ref, projectKey, currentParentProperties);
for (ComponentDto module : dbClient.componentDao().findModulesByProject(projectKey, session)) {
- addSettings(ref, module.key(), parentProperties);
- addSettingsToChildrenModules(ref, module.key(), parentProperties, hasScanPerm, session);
+ addSettings(ref, module.key(), currentParentProperties);
+ addSettingsToChildrenModules(ref, module.key(), currentParentProperties, hasScanPerm, session);
}
}
when(propertiesDao.selectProjectProperties(project.key(), session)).thenReturn(newArrayList(
new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR"),
new PropertyDto().setKey("sonar.jira.login.secured").setValue("john")
- ));
+ ));
when(propertiesDao.selectProjectProperties(module.key(), session)).thenReturn(newArrayList(
new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER"),
request.execute().assertJson(getClass(), "return_project_with_module_with_sub_module.json");
}
+ @Test
+ public void return_project_with_two_modules() throws Exception {
+ MockUserSession.set().setLogin("john").setGlobalPermissions(GlobalPermissions.SCAN_EXECUTION);
+
+ ComponentDto module2 = new ComponentDto().setKey("org.codehaus.sonar:sonar-application").setQualifier(Qualifiers.MODULE);
+
+ when(componentDao.getNullableRootProjectByKey(project.key(), session)).thenReturn(project);
+ when(componentDao.findModulesByProject(project.key(), session)).thenReturn(newArrayList(module, module2));
+
+ when(propertiesDao.selectProjectProperties(project.key(), session)).thenReturn(newArrayList(
+ new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR"),
+ new PropertyDto().setKey("sonar.jira.login.secured").setValue("john")
+ ));
+
+ when(propertiesDao.selectProjectProperties(module.key(), session)).thenReturn(newArrayList(
+ new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER"),
+ // This property should not be found on the other module
+ new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java")
+ ));
+
+ when(propertiesDao.selectProjectProperties(module2.key(), session)).thenReturn(newArrayList(
+ new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-APPLICATION")
+ ));
+
+ WsTester.TestRequest request = tester.newGetRequest("batch", "project").setParam("key", project.key());
+ request.execute().assertJson(getClass(), "return_project_with_two_modules.json");
+ }
+
@Test
public void return_provisioned_project_settings() throws Exception {
MockUserSession.set().setLogin("john").setGlobalPermissions(GlobalPermissions.SCAN_EXECUTION);
--- /dev/null
+{
+ "timestamp": 0,
+ "qprofilesByLanguage": {
+ "java": {
+ "key": "abcd",
+ "name": "Default",
+ "language": "java",
+ "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM"
+ }
+ },
+ "activeRules": [],
+ "settingsByModule": {
+ "org.codehaus.sonar:sonar": {
+ "sonar.jira.project.key": "SONAR",
+ "sonar.jira.login.secured": "john"
+ },
+ "org.codehaus.sonar:sonar-server": {
+ "sonar.jira.project.key": "SONAR-SERVER",
+ "sonar.jira.login.secured": "john",
+ "sonar.coverage.exclusions": "**/*.java"
+ },
+ "org.codehaus.sonar:sonar-application": {
+ "sonar.jira.project.key": "SONAR-APPLICATION",
+ "sonar.jira.login.secured": "john"
+ }
+ }
+}