aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-08-25 15:31:00 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-08-25 15:31:08 +0200
commit93c7ad5736ad3071e114aa87c925e0cb45b5f0e8 (patch)
tree5eafab8bab63f6965cbec208afbbc392ff0fd8df /server/sonar-server
parentedd595afbafd67632bb7215a081cf4cc5b77d81c (diff)
downloadsonarqube-93c7ad5736ad3071e114aa87c925e0cb45b5f0e8.tar.gz
sonarqube-93c7ad5736ad3071e114aa87c925e0cb45b5f0e8.zip
SONAR-5417 Fix issue when setting a profile on a provisoned project
Diffstat (limited to 'server/sonar-server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java17
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json13
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json2
4 files changed, 31 insertions, 2 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java
index 20172488b7c..5610d673b61 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java
@@ -123,6 +123,7 @@ public class ProjectReferentialsAction implements RequestHandler {
} else {
// Add settings of the provisioned project
addSettings(ref, projectOrModuleKey, getPropertiesMap(propertiesDao.selectProjectProperties(projectOrModuleKey, session), hasScanPerm));
+ projectKey = projectOrModuleKey;
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java
index a2afc2d7a85..508d35a18b7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java
@@ -211,6 +211,21 @@ public class ProjectReferentialsActionTest {
}
@Test
+ public void return_provisioned_project_profile() throws Exception {
+ MockUserSession.set().setLogin("john").setGlobalPermissions(GlobalPermissions.SCAN_EXECUTION, GlobalPermissions.DRY_RUN_EXECUTION);
+
+ // No root project will be found on provisioned project
+ when(componentDao.getNullableRootProjectByKey(project.key(), session)).thenReturn(null);
+
+ when(qProfileFactory.getByProjectAndLanguage(session, project.key(), "java")).thenReturn(
+ QualityProfileDto.createFor("abcd").setName("SonarQube way").setLanguage("java").setRulesUpdatedAt("2014-01-14T14:00:00+0200")
+ );
+
+ WsTester.TestRequest request = tester.newGetRequest("batch", "project").setParam("key", project.key());
+ request.execute().assertJson(getClass(), "return_provisioned_project_profile.json");
+ }
+
+ @Test
public void return_sub_module_settings() throws Exception {
MockUserSession.set().setLogin("john").setGlobalPermissions(GlobalPermissions.SCAN_EXECUTION, GlobalPermissions.DRY_RUN_EXECUTION);
@@ -300,7 +315,7 @@ public class ProjectReferentialsActionTest {
String projectKey = "org.codehaus.sonar:sonar";
when(qProfileFactory.getByProjectAndLanguage(session, projectKey, "java")).thenReturn(
- QualityProfileDto.createFor("abcd").setName("Default").setLanguage("java").setRulesUpdatedAt("2014-01-14T14:00:00+0200")
+ QualityProfileDto.createFor("abcd").setName("SonarQube way").setLanguage("java").setRulesUpdatedAt("2014-01-14T14:00:00+0200")
);
WsTester.TestRequest request = tester.newGetRequest("batch", "project").setParam("key", projectKey);
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json
new file mode 100644
index 00000000000..282fafa5b33
--- /dev/null
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json
@@ -0,0 +1,13 @@
+{
+ "timestamp": 0,
+ "qprofilesByLanguage": {
+ "java": {
+ "key": "abcd",
+ "name": "SonarQube way",
+ "language": "java",
+ "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM"
+ }
+ },
+ "activeRules": [],
+ "settingsByModule": {}
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json
index a1bb33bb01f..282fafa5b33 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json
@@ -3,7 +3,7 @@
"qprofilesByLanguage": {
"java": {
"key": "abcd",
- "name": "Default",
+ "name": "SonarQube way",
"language": "java",
"rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM"
}