]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4535 Rename Internal.qprofiles to Internal.quality_profiles, rename updateDefau...
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 17 Dec 2013 08:56:04 +0000 (09:56 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 17 Dec 2013 08:56:04 +0000 (09:56 +0100)
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileOperations.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/new_rules_configuration_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb
sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileOperationsTest.java
sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfilesTest.java

index c1c60769b4686ebd599584aa8f240e83e4de3c1b..f35a723ae1841e4fded25a323aee1ca56dccfabe 100644 (file)
@@ -115,13 +115,13 @@ public class QProfileOperations implements ServerComponent {
     dao.update(qualityProfile);
   }
 
-  public void updateDefaultProfile(Integer id, UserSession userSession) {
+  public void setDefaultProfile(Integer id, UserSession userSession) {
     QualityProfileDto qualityProfile = validateUpdateDefaultProfile(id, userSession);
     propertiesDao.setProperty(new PropertyDto().setKey(PROPERTY_PREFIX + qualityProfile.getLanguage()).setValue(qualityProfile.getName()));
   }
 
-  public void updateDefaultProfile(String name, String language, UserSession userSession) {
-    updateDefaultProfile(findNotNull(name, language).getId(), userSession);
+  public void setDefaultProfile(String name, String language, UserSession userSession) {
+    setDefaultProfile(findNotNull(name, language).getId(), userSession);
   }
 
   public QProfileProjects projects(Integer profileId) {
index d12e3d63239a4f9e429ab50f92a239d0be4ffb78..77d0759cd50fa8be42ede67340292f832767b1c4 100644 (file)
@@ -42,7 +42,7 @@ public class QProfiles implements ServerComponent {
   }
 
   public List<QProfile> searchProfiles() {
-    throw new UnsupportedOperationException();
+    return search.searchProfiles();
   }
 
   public void searchProfile(Integer profileId) {
@@ -62,15 +62,15 @@ public class QProfiles implements ServerComponent {
     operations.renameProfile(profileId, newName, UserSession.get());
   }
 
-  public void updateDefaultProfile(Integer profileId) {
-    operations.updateDefaultProfile(profileId, UserSession.get());
+  public void setDefaultProfile(Integer profileId) {
+    operations.setDefaultProfile(profileId, UserSession.get());
   }
 
   /**
    * Used by WS
    */
-  public void updateDefaultProfile(String name, String language) {
-    operations.updateDefaultProfile(name, language, UserSession.get());
+  public void setDefaultProfile(String name, String language) {
+    operations.setDefaultProfile(name, language, UserSession.get());
   }
 
   public void copyProfile() {
@@ -118,13 +118,6 @@ public class QProfiles implements ServerComponent {
     throw new UnsupportedOperationException();
   }
 
-  /**
-   * Used in /project/profile
-   */
-  public List<QProfile> profiles(String language) {
-    throw new UnsupportedOperationException();
-  }
-
   public void addProject(Integer profileId, Long projectId) {
     operations.addProject(profileId, projectId, UserSession.get());
   }
index 4fe95efecabf7e5614b636c520729900df17df78..b745240fac5bc19eb14365dd6ccc81dfd89d6d18 100644 (file)
@@ -75,7 +75,7 @@ class Api::ProfilesController < Api::ApiController
   # Since v.3.3
   def set_as_default
     verify_post_request
-    Internal.qprofiles.updateDefaultProfile(params[:name], params[:language])
+    Internal.quality_profiles.setDefaultProfile(params[:name], params[:language])
     render_success
   end
 
index 85542956992fbe2858aba008df420ddafbe1230c..5b0ae0cbff082514d299a366c2ab25b4c18d33b2 100644 (file)
@@ -64,9 +64,9 @@ class NewRulesConfigurationController < ApplicationController
         paging = Java::OrgSonarServerQualityprofile::Paging.create(@pagination.per_page.to_i, @pagination.page.to_i)
 
         if @activation==STATUS_ACTIVE
-          result = Internal.qprofiles.searchActiveRules(query, paging)
+          result = Internal.quality_profiles.searchActiveRules(query, paging)
         else
-          result = Internal.qprofiles.searchInactiveRules(query, paging)
+          result = Internal.quality_profiles.searchInactiveRules(query, paging)
         end
 
         @rules = result.rules
@@ -74,9 +74,9 @@ class NewRulesConfigurationController < ApplicationController
 
         unless @searchtext.blank?
           if @activation==STATUS_ACTIVE
-            @hidden_inactives = Internal.qprofiles.countInactiveRules(query)
+            @hidden_inactives = Internal.quality_profiles.countInactiveRules(query)
           else
-            @hidden_actives = Internal.qprofiles.countInactiveRules(query)
+            @hidden_actives = Internal.quality_profiles.countInactiveRules(query)
           end
         end
       end
index 203d298cfb22f5567bf8bcda3cc75938860b812d..7297166fe9e3288751d42bdf14d990b01fd53e98 100644 (file)
@@ -52,7 +52,7 @@ class ProfilesController < ApplicationController
           end
         end
       end
-      result = Internal.qprofiles.newProfile(params[:name], params[:language], files_by_key)
+      result = Internal.quality_profiles.newProfile(params[:name], params[:language], files_by_key)
       flash[:notice] = message('quality_profiles.profile_x_created', :params => result.profile.name)
 
       # only 4 messages are kept each time to avoid cookie overflow.
@@ -83,8 +83,10 @@ class ProfilesController < ApplicationController
   # POST /profiles/set_as_default/<id>
   def set_as_default
     verify_post_request
+    require_parameters 'id'
+
     call_backend do
-      Internal.qprofiles.updateDefaultProfile(params[:id].to_i)
+      Internal.quality_profiles.setDefaultProfile(params[:id].to_i)
     end
     redirect_to :action => 'index'
   end
@@ -267,8 +269,10 @@ class ProfilesController < ApplicationController
   #
   #
   def projects
+    require_parameters 'id'
+
     call_backend do
-      result = Internal.qprofiles.projects(params[:id].to_i)
+      result = Internal.quality_profiles.projects(params[:id].to_i)
       @profile = result.profile
       @projects = Api::Utils.insensitive_sort(result.projects.to_a) { |p| p.name }
       set_profile_breadcrumbs
@@ -279,6 +283,7 @@ class ProfilesController < ApplicationController
   # POST /profiles/add_project?id=<profile id>&project=<project id>
   def add_project
     verify_post_request
+    require_parameters 'id', 'project'
 
     # Used for Selenium test as it send a project key instead of a project id
     begin
@@ -289,7 +294,7 @@ class ProfilesController < ApplicationController
     profile_id = params[:id].to_i
 
     call_backend do
-      Internal.qprofiles.addProject(profile_id, project_id.to_i)
+      Internal.quality_profiles.addProject(profile_id, project_id.to_i)
     end
     redirect_to :action => 'projects', :id => profile_id
   end
@@ -297,9 +302,11 @@ class ProfilesController < ApplicationController
   # POST /profiles/remove_project?id=<profile id>&project=<project id>
   def remove_project
     verify_post_request
+    require_parameters 'id', 'project'
+
     profile_id = params[:id].to_i
     call_backend do
-      Internal.qprofiles.removeProject(profile_id, params[:project].to_i)
+      Internal.quality_profiles.removeProject(profile_id, params[:project].to_i)
     end
     redirect_to :action => 'projects', :id => profile_id
   end
@@ -329,9 +336,10 @@ class ProfilesController < ApplicationController
   def rename
     verify_post_request
     verify_ajax_request
+    require_parameters 'id'
 
     call_backend do
-      Internal.qprofiles.renameProfile(params[:id].to_i, params[:new_name])
+      Internal.quality_profiles.renameProfile(params[:id].to_i, params[:new_name])
     end
     render :text => 'ok', :status => 200
   end
index 1887eab42b38396b081e13adf034af3f137ddd32..1cd6b48252e89d500fc3ac835170c2d337bf521d 100644 (file)
@@ -92,9 +92,9 @@ class ProjectController < ApplicationController
 
     call_backend do
       if profile_id.blank?
-        Internal.qprofiles.removeProjectByLanguage(language, project)
+        Internal.quality_profiles.removeProjectByLanguage(language, project)
       else
-        Internal.qprofiles.addProject(profile_id.to_i, project)
+        Internal.quality_profiles.addProject(profile_id.to_i, project)
       end
     end
 
index fdbf40dddab52f3bffe154b0ddfbce05318abe57..6091ecdfb0a6de145c6eaef1daf28ae15e39a00b 100644 (file)
@@ -66,7 +66,7 @@ class Internal
     component(Java::OrgSonarServerGroup::InternalGroupMembershipService.java_class)
   end
 
-  def self.qprofiles
+  def self.quality_profiles
     component(Java::OrgSonarServerQualityprofile::QProfiles.java_class)
   end
 
index b4e0b23b3268283cd00c7674aae64984ae131beb..37f3e86f92ce58dc4a6549e6b2f2f022343b0e26 100644 (file)
@@ -259,7 +259,7 @@ public class QProfileOperationsTest {
   public void update_default_profile() throws Exception {
     when(dao.selectById(1)).thenReturn(new QualityProfileDto().setId(1).setName("My profile").setLanguage("java"));
 
-    operations.updateDefaultProfile(1, MockUserSession.create().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN));
+    operations.setDefaultProfile(1, MockUserSession.create().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN));
 
     ArgumentCaptor<PropertyDto> argumentCaptor = ArgumentCaptor.forClass(PropertyDto.class);
     verify(propertiesDao).setProperty(argumentCaptor.capture());
@@ -272,7 +272,7 @@ public class QProfileOperationsTest {
     when(dao.selectByNameAndLanguage("My profile", "java")).thenReturn(new QualityProfileDto().setId(1).setName("My profile").setLanguage("java"));
     when(dao.selectById(1)).thenReturn(new QualityProfileDto().setId(1).setName("My profile").setLanguage("java"));
 
-    operations.updateDefaultProfile("My profile", "java", MockUserSession.create().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN));
+    operations.setDefaultProfile("My profile", "java", MockUserSession.create().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN));
 
     ArgumentCaptor<PropertyDto> argumentCaptor = ArgumentCaptor.forClass(PropertyDto.class);
     verify(propertiesDao).setProperty(argumentCaptor.capture());
index 58863d75af3035bc925a326ebf27c832e3359d13..55ed1a5588f932e6746673e8353e6cec5fd8f2ae 100644 (file)
@@ -56,9 +56,10 @@ public class QProfilesTest {
     qProfiles = new QProfiles(search, operations, rules);
   }
 
-  @Test(expected = UnsupportedOperationException.class)
+  @Test
   public void search_profiles() throws Exception {
     qProfiles.searchProfiles();
+    verify(search).searchProfiles();
   }
 
   @Test(expected = UnsupportedOperationException.class)
@@ -86,14 +87,14 @@ public class QProfilesTest {
 
   @Test
   public void update_default_profile() throws Exception {
-    qProfiles.updateDefaultProfile(1);
-    verify(operations).updateDefaultProfile(eq(1), any(UserSession.class));
+    qProfiles.setDefaultProfile(1);
+    verify(operations).setDefaultProfile(eq(1), any(UserSession.class));
   }
 
   @Test
   public void update_default_profile_from_name_and_language() throws Exception {
-    qProfiles.updateDefaultProfile("Default", "java");
-    verify(operations).updateDefaultProfile(eq("Default"), eq("java"), any(UserSession.class));
+    qProfiles.setDefaultProfile("Default", "java");
+    verify(operations).setDefaultProfile(eq("Default"), eq("java"), any(UserSession.class));
   }
 
   @Test(expected = UnsupportedOperationException.class)
@@ -142,11 +143,6 @@ public class QProfilesTest {
     qProfiles.profile(1);
   }
 
-  @Test(expected = UnsupportedOperationException.class)
-  public void get_profiles_from_language() throws Exception {
-    qProfiles.profiles("java");
-  }
-
   @Test
   public void add_project() throws Exception {
     qProfiles.addProject(1, 10L);