]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5417 Fix issue when setting a profile on a provisoned project
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 25 Aug 2014 13:31:00 +0000 (15:31 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 25 Aug 2014 13:31:08 +0000 (15:31 +0200)
server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java
server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java
server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json

index 20172488b7cc7e79c58cdc49c3019c1d72478361..5610d673b6163dea4bbbb78c218090f803782b25 100644 (file)
@@ -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;
         }
       }
 
index a2afc2d7a852868b88372836e953fa4df7b2c70d..508d35a18b78ae3c5c6eb832077920fb33d56abb 100644 (file)
@@ -210,6 +210,21 @@ public class ProjectReferentialsActionTest {
     request.execute().assertJson(getClass(), "return_project_settings.json");
   }
 
+  @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 (file)
index 0000000..282fafa
--- /dev/null
@@ -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": {}
+}
index a1bb33bb01ffdf761efa3a1773a37180b3a3b7dd..282fafa5b33fd1fe3aac12c874baa6d0489a0d17 100644 (file)
@@ -3,7 +3,7 @@
   "qprofilesByLanguage": {
     "java": {
       "key": "abcd",
-      "name": "Default",
+      "name": "SonarQube way",
       "language": "java",
       "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM"
     }