]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4764 Rename "Restore Default Profiles" by "Recreate Built-in Profiles"
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 6 May 2014 12:52:00 +0000 (14:52 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 6 May 2014 12:52:11 +0000 (14:52 +0200)
21 files changed:
sonar-core/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackup.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInAction.java [new file with mode: 0644]
sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultAction.java [deleted file]
sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfilesWs.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_recreate_built_in_form.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_restore_default_form.html.erb [deleted file]
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb
sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackupTest.java
sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfilesMediumTest.java
sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest.java [new file with mode: 0644]
sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest.java [deleted file]
sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest/show_infos.json [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest/show_infos_and_warnings.json [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest/show_warnings.json [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest/show_infos.json [deleted file]
sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest/show_infos_and_warnings.json [deleted file]
sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest/show_warnings.json [deleted file]

index 9ea0b618707d6c1c72564087881eeade6a1bfad6..ffc8bc14b22e3528c4e60b4557989358904c8074 100644 (file)
@@ -1631,10 +1631,9 @@ quality_profiles.remove_projects_confirm_message=Are you sure that you want to d
 quality_profiles.remove_projects_confirm_button=Remove All
 quality_profiles.copy_x_title=Copy Profile {0}
 quality_profiles.copy_new_name=New name
-quality_profiles.restore_default_profiles=Restore Default Profiles
-quality_profiles.restore_default_profiles_x_language=Restore default profiles for language '{0}'
-quality_profiles.restore_default_profiles_confirmation=Are you sure you want to restore '{0}' profile(s) for '{1}' ?
-quality_profiles.restore_default_profiles_warning=Before restoring default profiles for '{0}', you have to rename or delete profile(s) '{1}'.
+quality_profiles.recreate_built_in_profiles=Recreate Built-in Profiles
+quality_profiles.recreate_built_in_profiles_confirmation=Are you sure you want to recreate '{0}' profile(s) for '{1}' ?
+quality_profiles.recreate_built_in_profiles_warning=Before recreating built-in profiles for '{0}', you have to rename or delete profile(s) '{1}'.
 
 #------------------------------------------------------------------------------
 #
index d0d64be9d18a9a15ee84da604bc459e9df6dbe28..e61d52791cd4c2ecad93b021d34e3873115578b6 100644 (file)
@@ -115,7 +115,7 @@ import org.sonar.server.qualitygate.ws.*;
 import org.sonar.server.qualityprofile.*;
 import org.sonar.server.qualityprofile.ws.ActivateRuleAction;
 import org.sonar.server.qualityprofile.ws.ProfilesWs;
-import org.sonar.server.qualityprofile.ws.QProfileRestoreDefaultAction;
+import org.sonar.server.qualityprofile.ws.QProfileRecreateBuiltInAction;
 import org.sonar.server.qualityprofile.ws.QProfilesWs;
 import org.sonar.server.rule.*;
 import org.sonar.server.rule.ws.*;
@@ -284,7 +284,7 @@ class ServerComponents {
     pico.addSingleton(QProfileRepositoryExporter.class);
     pico.addSingleton(DefaultProfilesCache.class);
     pico.addSingleton(ESActiveRule.class);
-    pico.addSingleton(QProfileRestoreDefaultAction.class);
+    pico.addSingleton(QProfileRecreateBuiltInAction.class);
     pico.addSingleton(QProfilesWs.class);
     pico.addSingleton(ProfilesWs.class);
     pico.addSingleton(ActivateRuleAction.class);
index 624bfbfa349f5c10dafe20e5d227b82afb9d4901..e39857d4dc89d986f60335b3ea079e41c3a1e8c8 100644 (file)
@@ -138,10 +138,10 @@ public class QProfileBackup implements ServerComponent {
   }
 
   /**
-   * Restore provided profile for a given language.
+   * Recreate built-in profile for a given language.
    * If a profile with same name than default profile already exists, an exception will be thrown.
    */
-  public QProfileResult restoreDefaultProfilesByLanguage(String language) {
+  public QProfileResult recreateBuiltInProfilesByLanguage(String language) {
     checkPermission(UserSession.get());
     QProfileResult result = new QProfileResult();
 
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInAction.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInAction.java
new file mode 100644 (file)
index 0000000..3d0d0cb
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.qualityprofile.ws;
+
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.RequestHandler;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.text.JsonWriter;
+import org.sonar.server.qualityprofile.QProfileBackup;
+import org.sonar.server.qualityprofile.QProfileResult;
+
+public class QProfileRecreateBuiltInAction implements RequestHandler {
+
+  private final QProfileBackup qProfileBackup;
+
+  public QProfileRecreateBuiltInAction(QProfileBackup qProfileBackup) {
+    this.qProfileBackup = qProfileBackup;
+  }
+
+  void define(WebService.NewController controller){
+    WebService.NewAction restoreDefault = controller.createAction("recreate_built_in")
+      .setDescription("Recreate Built-in Profiles")
+      .setSince("4.4")
+      .setPost(true)
+      .setHandler(this);
+    restoreDefault.createParam("language")
+      .setDescription("Recreate built-in profiles for this language")
+    .setExampleValue("java");
+  }
+
+  @Override
+  public void handle(Request request, Response response) {
+    final String language = request.mandatoryParam("language");
+    QProfileResult result = qProfileBackup.recreateBuiltInProfilesByLanguage(language);
+
+    if (!result.infos().isEmpty() || !result.warnings().isEmpty()) {
+      JsonWriter json = response.newJsonWriter();
+      json.beginObject();
+      if (!result.infos().isEmpty()) {
+        json.name("infos").beginArray();
+        for (String info : result.infos()) {
+          json.value(info);
+        }
+        json.endArray();
+      }
+      if (!result.warnings().isEmpty()) {
+        json.name("warnings").beginArray();
+        for (String warning : result.warnings()) {
+          json.value(warning);
+        }
+        json.endArray();
+      }
+      json.endObject().close();
+    } else {
+      response.noContent();
+    }
+  }
+
+}
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultAction.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultAction.java
deleted file mode 100644 (file)
index 85520e2..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.qualityprofile.ws;
-
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.RequestHandler;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.server.qualityprofile.QProfileBackup;
-import org.sonar.server.qualityprofile.QProfileResult;
-
-public class QProfileRestoreDefaultAction implements RequestHandler {
-
-  private final QProfileBackup qProfileBackup;
-
-  public QProfileRestoreDefaultAction(QProfileBackup qProfileBackup) {
-    this.qProfileBackup = qProfileBackup;
-  }
-
-  void define(WebService.NewController controller){
-    WebService.NewAction restoreDefault = controller.createAction("restore_default")
-      .setDescription("Restore default profiles")
-      .setSince("4.4")
-      .setHandler(this);
-    restoreDefault.createParam("language")
-      .setDescription("Restore default profiles for this language")
-    .setExampleValue("java");
-  }
-
-  @Override
-  public void handle(Request request, Response response) {
-    final String language = request.mandatoryParam("language");
-    QProfileResult result = qProfileBackup.restoreDefaultProfilesByLanguage(language);
-
-    if (!result.infos().isEmpty() || !result.warnings().isEmpty()) {
-      JsonWriter json = response.newJsonWriter();
-      json.beginObject();
-      if (!result.infos().isEmpty()) {
-        json.name("infos").beginArray();
-        for (String info : result.infos()) {
-          json.value(info);
-        }
-        json.endArray();
-      }
-      if (!result.warnings().isEmpty()) {
-        json.name("warnings").beginArray();
-        for (String warning : result.warnings()) {
-          json.value(warning);
-        }
-        json.endArray();
-      }
-      json.endObject().close();
-    } else {
-      response.noContent();
-    }
-  }
-
-}
index 292e529d8bbe59be253eb9adf7422fa18370346a..d3dc74ae33482726e11474b2ec23f92b007a40bf 100644 (file)
@@ -23,20 +23,21 @@ import org.sonar.api.server.ws.WebService;
 
 public class QProfilesWs implements WebService {
 
-  private final QProfileRestoreDefaultAction restoreDefaultAction;
+  private final QProfileRecreateBuiltInAction recreateBuiltInAction;
   private final ActivateRuleAction activateRuleAction;
 
-  public QProfilesWs(QProfileRestoreDefaultAction qProfileRestoreDefaultAction, ActivateRuleAction activateRuleAction) {
-    this.restoreDefaultAction = qProfileRestoreDefaultAction;
+  public QProfilesWs(QProfileRecreateBuiltInAction recreateBuiltInAction, ActivateRuleAction activateRuleAction) {
+    this.recreateBuiltInAction = recreateBuiltInAction;
     this.activateRuleAction = activateRuleAction;
   }
 
   @Override
   public void define(Context context) {
     NewController controller = context.createController("api/qualityprofiles")
-      .setDescription("Quality profiles management");
+      .setDescription("Quality profiles management")
+      .setSince("4.4");
 
-    restoreDefaultAction.define(controller);
+    recreateBuiltInAction.define(controller);
     activateRuleAction.define(controller);
 
     controller.done();
index a6f646014641d73dcf85ff93eb6ab656e4e96f43..aba0138c600e36c2676bb6304bd0696c15396225 100644 (file)
@@ -59,9 +59,9 @@ class ProfilesController < ApplicationController
     redirect_to :action => 'index'
   end
 
-  # Modal window to restore default profiles
-  # GET /profiles/restore_default_form/<profile id>
-  def restore_default_form
+  # Modal window to recreate built-in profiles
+  # GET /profiles/recreate_built_in_form/<profile id>
+  def recreate_built_in_form
     verify_ajax_request
     require_parameters 'language'
     @language = java_facade.getLanguages().find { |l| l.getKey()==params[:language].to_s }
@@ -70,15 +70,15 @@ class ProfilesController < ApplicationController
       profiles = Internal.quality_profiles.profilesByLanguage(@language.getKey()).to_a
       @existing_default_profiles = profiles.select{|p| @default_profile_names.find{|default_profile| default_profile == p.name()}}.collect{|p| p.name()}
     end
-    render :partial => 'profiles/restore_default_form'
+    render :partial => 'profiles/recreate_built_in_form'
   end
 
-  # POST /profiles/restore_default?language=<language>
-  def restore_default
+  # POST /profiles/recreate_built_in_form?language=<language>
+  def recreate_built_in
     verify_post_request
     require_parameters 'language'
     call_backend do
-      @result = Internal.profile_backup.restoreDefaultProfilesByLanguage(params[:language].to_s)
+      @result = Internal.profile_backup.recreateBuiltInProfilesByLanguage(params[:language].to_s)
       flash_result(@result)
     end
     redirect_to :action => 'index'
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_recreate_built_in_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_recreate_built_in_form.html.erb
new file mode 100644 (file)
index 0000000..2f424ac
--- /dev/null
@@ -0,0 +1,22 @@
+<form id="recreate-built-in-profiles-form" action="profiles/recreate_built_in" method="POST">
+  <fieldset>
+    <input type="hidden" name="language" value="<%= @language.getKey() -%>"/>
+
+    <div class="modal-head">
+      <h2><%= h message('quality_profiles.recreate_built_in_profiles') -%></h2>
+    </div>
+
+    <div class="modal-body">
+      <% if @existing_default_profiles.empty? %>
+        <%= h message('quality_profiles.recreate_built_in_profiles_confirmation', :params => [@default_profile_names.join('\', \''), @language.getName()]) -%>
+      <% else %>
+        <%= h message('quality_profiles.recreate_built_in_profiles_warning', :params => [@language.getName(), @existing_default_profiles.join('\', \'')]) -%>
+      <% end %>
+    </div>
+
+    <div class="modal-foot">
+      <input type="submit" value="<%= h message('restore') -%>" id="recreate-built-in-profiles-submit" <%= 'disabled=disabled' unless @existing_default_profiles.empty? -%>/>
+      <a href="#" onclick="return closeModalWindow()" id="recreate-built-in-profiles-cancel"><%= h message('cancel') -%></a>
+    </div>
+  </fieldset>
+</form>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_restore_default_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_restore_default_form.html.erb
deleted file mode 100644 (file)
index f650cfb..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<form id="restore-default-profiles-form" action="profiles/restore_default" method="POST">
-  <fieldset>
-    <input type="hidden" name="language" value="<%= @language.getKey() -%>"/>
-
-    <div class="modal-head">
-      <h2><%= h message('quality_profiles.restore_default_profiles_x_language', :params => @language.getName()) -%></h2>
-    </div>
-
-    <div class="modal-body">
-      <% if @existing_default_profiles.empty? %>
-        <%= h message('quality_profiles.restore_default_profiles_confirmation', :params => [@default_profile_names.join('\', \''), @language.getName()]) -%>
-      <% else %>
-        <%= h message('quality_profiles.restore_default_profiles_warning', :params => [@language.getName(), @existing_default_profiles.join('\', \'')]) -%>
-      <% end %>
-    </div>
-
-    <div class="modal-foot">
-      <input type="submit" value="<%= h message('restore') -%>" id="restore-default-profiles-submit" <%= 'disabled=disabled' unless @existing_default_profiles.empty? -%>/>
-      <a href="#" onclick="return closeModalWindow()" id="restore-default-profiles-cancel"><%= h message('cancel') -%></a>
-    </div>
-  </fieldset>
-</form>
index f75e7cbf5bd97fff8600e56a43fa8f39c7369de1..61f1e566309703b46725577035778137cb0f3fa0 100644 (file)
@@ -29,8 +29,8 @@
       </ul>
       <ul style="float: right" class="horizontal">
         <li class="marginleft10">
-          <a id="create-link-<%= language.getKey() -%>" href="<%= ApplicationController.root_context -%>/profiles/restore_default_form?language=<%= u language.getKey() -%>"
-             class="open-modal link-action"><%= message('quality_profiles.restore_default_profiles') -%></a>
+          <a id="create-link-<%= language.getKey() -%>" href="<%= ApplicationController.root_context -%>/profiles/recreate_built_in_form?language=<%= u language.getKey() -%>"
+             class="open-modal link-action"><%= message('quality_profiles.recreate_built_in_profiles') -%></a>
         </li>
       </ul>
     <% end %>
index 3a970d2a29e1fcbe0a003435960c5cc9cbebf230..689776e6444da62dbd71db3e0eb19c4d6983ec7a 100644 (file)
@@ -306,7 +306,7 @@ public class QProfileBackupTest {
   }
 
   @Test
-  public void restore_default_profiles_from_language() throws Exception {
+  public void recreate_built_in_profiles_from_language() throws Exception {
     String name = "Default";
     String language = "java";
 
@@ -324,7 +324,7 @@ public class QProfileBackupTest {
 
     when(qProfileOperations.newProfile(eq(name), eq(language), eq(true), any(UserSession.class), eq(session))).thenReturn(new QProfile().setId(1));
 
-    backup.restoreDefaultProfilesByLanguage(language);
+    backup.recreateBuiltInProfilesByLanguage(language);
 
     verify(qProfileActiveRuleOperations).createActiveRule(eq(1), eq(10), eq("BLOCKER"), eq(session));
     verify(qProfileActiveRuleOperations).updateActiveRuleParam(any(ActiveRuleDto.class), eq("max"), eq("10"), eq(session));
@@ -336,7 +336,7 @@ public class QProfileBackupTest {
   }
 
   @Test
-  public void restore_default_profiles_from_language_with_multiple_profiles_with_same_name_and_same_language() throws Exception {
+  public void recreate_built_in_profiles_from_language_with_multiple_profiles_with_same_name_and_same_language() throws Exception {
     RulesProfile profile1 = RulesProfile.create("Default", "java");
     profile1.activateRule(Rule.create("pmd", "rule").setSeverity(RulePriority.BLOCKER), null);
     ProfileDefinition profileDefinition1 = mock(ProfileDefinition.class);
@@ -354,7 +354,7 @@ public class QProfileBackupTest {
 
     when(qProfileOperations.newProfile(eq("Default"), eq("java"), eq(true), any(UserSession.class), eq(session))).thenReturn(new QProfile().setId(1));
 
-    backup.restoreDefaultProfilesByLanguage("java");
+    backup.recreateBuiltInProfilesByLanguage("java");
 
     verify(qProfileActiveRuleOperations).createActiveRule(eq(1), eq(10), eq("BLOCKER"), eq(session));
     verify(qProfileActiveRuleOperations).createActiveRule(eq(1), eq(11), eq("MAJOR"), eq(session));
@@ -366,7 +366,7 @@ public class QProfileBackupTest {
   }
 
   @Test
-  public void fail_to_restore_profile_when_rule_not_found() throws Exception {
+  public void fail_to_recreate_built_in_profile_when_rule_not_found() throws Exception {
     String name = "Default";
     String language = "java";
 
@@ -383,7 +383,7 @@ public class QProfileBackupTest {
     when(qProfileOperations.newProfile(eq(name), eq(language), eq(true), any(UserSession.class), eq(session))).thenReturn(new QProfile().setId(1));
 
     try {
-      backup.restoreDefaultProfilesByLanguage(language);
+      backup.recreateBuiltInProfilesByLanguage(language);
       fail();
     } catch (Exception e) {
       assertThat(e).isInstanceOf(NotFoundException.class);
@@ -393,14 +393,14 @@ public class QProfileBackupTest {
   }
 
   @Test
-  public void not_restore_default_profiles_from_another_language() throws Exception {
+  public void not_recreate_built_in_profiles_from_another_language() throws Exception {
     RulesProfile profile = RulesProfile.create("Default", "java");
     profile.activateRule(Rule.create("pmd", "rule").setSeverity(RulePriority.BLOCKER), null);
     ProfileDefinition profileDefinition = mock(ProfileDefinition.class);
     when(profileDefinition.createProfile(any(ValidationMessages.class))).thenReturn(profile);
     definitions.add(profileDefinition);
 
-    backup.restoreDefaultProfilesByLanguage("js");
+    backup.recreateBuiltInProfilesByLanguage("js");
 
     verifyZeroInteractions(qProfileOperations);
     verifyZeroInteractions(qProfileActiveRuleOperations);
index 397cdc2ca222a9bc0008bdddeff3d13ea9d25746..91a0db112dd2d78607846db1cfca3938fdf39e2b 100644 (file)
@@ -82,7 +82,7 @@ public class QProfilesMediumTest {
   }
 
   @Test
-  public void restore_provided_profile_from_language() throws Exception {
+  public void recreate_built_in_profile_from_language() throws Exception {
     MockUserSession.set().setLogin("julien").setName("Julien").setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);
 
     QProfiles qProfiles = serverTester.get(QProfiles.class);
@@ -106,7 +106,7 @@ public class QProfilesMediumTest {
     qProfiles.renameProfile(profile.id(), "Old Basic");
 
     // Restore default profiles of xoo
-    qProfileBackup.restoreDefaultProfilesByLanguage("xoo");
+    qProfileBackup.recreateBuiltInProfilesByLanguage("xoo");
 
     // Reload profile
     profile = qProfiles.profile("Basic", "xoo");
@@ -123,14 +123,14 @@ public class QProfilesMediumTest {
   }
 
   @Test
-  public void fail_to_restore_provided_profile_from_language_if_default_profile_already_exists() throws Exception {
+  public void fail_to_recreate_built_in_profile_from_language_if_default_profile_already_exists() throws Exception {
     MockUserSession.set().setLogin("julien").setName("Julien").setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);
 
     QProfileBackup qProfileBackup = serverTester.get(QProfileBackup.class);
 
     try {
       // Restore default profiles of xoo -> fail as it already exists
-      qProfileBackup.restoreDefaultProfilesByLanguage("xoo");
+      qProfileBackup.recreateBuiltInProfilesByLanguage("xoo");
       fail();
     } catch (BadRequestException e) {
       assertThat(e.l10nKey()).isEqualTo("quality_profiles.profile_x_already_exists");
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest.java
new file mode 100644 (file)
index 0000000..0c66654
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.qualityprofile.ws;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.sonar.server.qualityprofile.QProfileBackup;
+import org.sonar.server.qualityprofile.QProfileResult;
+import org.sonar.server.qualityprofile.RuleActivationService;
+import org.sonar.server.ws.WsTester;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class QProfileRecreateBuiltInActionTest {
+
+  @Mock
+  QProfileBackup qProfileBackup;
+
+  WsTester tester;
+
+  @Before
+  public void setUp() throws Exception {
+    tester = new WsTester(new QProfilesWs(
+      new QProfileRecreateBuiltInAction(qProfileBackup),
+      new ActivateRuleAction(mock(RuleActivationService.class))));
+  }
+
+  @Test
+  public void return_empty_result_when_no_infos_or_warnings() throws Exception {
+    when(qProfileBackup.recreateBuiltInProfilesByLanguage("java")).thenReturn(new QProfileResult());
+
+    WsTester.TestRequest request = tester.newPostRequest("api/qualityprofiles", "recreate_built_in").setParam("language", "java");
+    request.execute().assertNoContent();
+  }
+
+  @Test
+  public void show_infos() throws Exception {
+    when(qProfileBackup.recreateBuiltInProfilesByLanguage("java")).thenReturn(new QProfileResult().addInfos(newArrayList("Some info")));
+
+    WsTester.TestRequest request = tester.newPostRequest("api/qualityprofiles", "recreate_built_in").setParam("language", "java");
+    request.execute().assertJson(getClass(), "show_infos.json");
+  }
+
+  @Test
+  public void show_warnings() throws Exception {
+    when(qProfileBackup.recreateBuiltInProfilesByLanguage("java")).thenReturn(new QProfileResult().addWarnings(newArrayList("Some warning")));
+
+    WsTester.TestRequest request = tester.newPostRequest("api/qualityprofiles", "recreate_built_in").setParam("language", "java");
+    request.execute().assertJson(getClass(), "show_warnings.json");
+  }
+
+  @Test
+  public void show_infos_and_warnings() throws Exception {
+    when(qProfileBackup.recreateBuiltInProfilesByLanguage("java")).thenReturn(new QProfileResult().addInfos(newArrayList("Some info")).addWarnings(newArrayList("Some warning")));
+
+    WsTester.TestRequest request = tester.newPostRequest("api/qualityprofiles", "recreate_built_in").setParam("language", "java");
+    request.execute().assertJson(getClass(), "show_infos_and_warnings.json");
+  }
+}
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest.java
deleted file mode 100644 (file)
index d68648c..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.qualityprofile.ws;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.sonar.server.qualityprofile.QProfileBackup;
-import org.sonar.server.qualityprofile.QProfileResult;
-import org.sonar.server.qualityprofile.RuleActivationService;
-import org.sonar.server.ws.WsTester;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class QProfileRestoreDefaultActionTest {
-
-  @Mock
-  QProfileBackup qProfileBackup;
-
-  WsTester tester;
-
-  @Before
-  public void setUp() throws Exception {
-    tester = new WsTester(new QProfilesWs(
-      new QProfileRestoreDefaultAction(qProfileBackup),
-      new ActivateRuleAction(mock(RuleActivationService.class))));
-  }
-
-  @Test
-  public void return_empty_result_when_no_infos_or_warnings() throws Exception {
-    when(qProfileBackup.restoreDefaultProfilesByLanguage("java")).thenReturn(new QProfileResult());
-
-    WsTester.TestRequest request = tester.newPostRequest("api/qualityprofiles", "restore_default").setParam("language", "java");
-    request.execute().assertNoContent();
-  }
-
-  @Test
-  public void show_infos() throws Exception {
-    when(qProfileBackup.restoreDefaultProfilesByLanguage("java")).thenReturn(new QProfileResult().addInfos(newArrayList("Some info")));
-
-    WsTester.TestRequest request = tester.newPostRequest("api/qualityprofiles", "restore_default").setParam("language", "java");
-    request.execute().assertJson(getClass(), "show_infos.json");
-  }
-
-  @Test
-  public void show_warnings() throws Exception {
-    when(qProfileBackup.restoreDefaultProfilesByLanguage("java")).thenReturn(new QProfileResult().addWarnings(newArrayList("Some warning")));
-
-    WsTester.TestRequest request = tester.newPostRequest("api/qualityprofiles", "restore_default").setParam("language", "java");
-    request.execute().assertJson(getClass(), "show_warnings.json");
-  }
-
-  @Test
-  public void show_infos_and_warnings() throws Exception {
-    when(qProfileBackup.restoreDefaultProfilesByLanguage("java")).thenReturn(new QProfileResult().addInfos(newArrayList("Some info")).addWarnings(newArrayList("Some warning")));
-
-    WsTester.TestRequest request = tester.newPostRequest("api/qualityprofiles", "restore_default").setParam("language", "java");
-    request.execute().assertJson(getClass(), "show_infos_and_warnings.json");
-  }
-}
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java
new file mode 100644 (file)
index 0000000..d9d3fee
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.qualityprofile.ws;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.server.qualityprofile.QProfileBackup;
+import org.sonar.server.qualityprofile.RuleActivationService;
+import org.sonar.server.ws.WsTester;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+
+public class QProfilesWsTest {
+
+  WebService.Controller controller;
+
+  @Before
+  public void setUp() {
+    controller = new WsTester(new QProfilesWs(new QProfileRecreateBuiltInAction(mock(QProfileBackup.class)), new ActivateRuleAction(mock(RuleActivationService.class))))
+      .controller("api/qualityprofiles");
+  }
+
+  @Test
+  public void define_controller() throws Exception {
+    assertThat(controller).isNotNull();
+    assertThat(controller.path()).isEqualTo("api/qualityprofiles");
+    assertThat(controller.description()).isNotEmpty();
+    assertThat(controller.actions()).hasSize(2);
+  }
+
+  @Test
+  public void define_recreate_built_in_action() throws Exception {
+    WebService.Action restoreProfiles = controller.action("recreate_built_in");
+    assertThat(restoreProfiles).isNotNull();
+    assertThat(restoreProfiles.isPost()).isTrue();
+    assertThat(restoreProfiles.params()).hasSize(1);
+  }
+
+  @Test
+  public void define_activate_rule_in_action() throws Exception {
+    WebService.Action restoreProfiles = controller.action("activate_rule");
+    assertThat(restoreProfiles).isNotNull();
+    assertThat(restoreProfiles.isPost()).isTrue();
+    assertThat(restoreProfiles.params()).hasSize(6);
+  }
+
+}
diff --git a/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest/show_infos.json b/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest/show_infos.json
new file mode 100644 (file)
index 0000000..b71854a
--- /dev/null
@@ -0,0 +1 @@
+{"infos":["Some info"]}
diff --git a/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest/show_infos_and_warnings.json b/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest/show_infos_and_warnings.json
new file mode 100644 (file)
index 0000000..49b2870
--- /dev/null
@@ -0,0 +1,4 @@
+{
+  "infos": ["Some info"],
+  "warnings": ["Some warning"]
+}
diff --git a/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest/show_warnings.json b/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest/show_warnings.json
new file mode 100644 (file)
index 0000000..256ac20
--- /dev/null
@@ -0,0 +1 @@
+{"warnings":["Some warning"]}
diff --git a/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest/show_infos.json b/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest/show_infos.json
deleted file mode 100644 (file)
index b71854a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{"infos":["Some info"]}
diff --git a/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest/show_infos_and_warnings.json b/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest/show_infos_and_warnings.json
deleted file mode 100644 (file)
index 49b2870..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-{
-  "infos": ["Some info"],
-  "warnings": ["Some warning"]
-}
diff --git a/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest/show_warnings.json b/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest/show_warnings.json
deleted file mode 100644 (file)
index 256ac20..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{"warnings":["Some warning"]}