]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 refactor restore of built-in profiles
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 9 Jun 2014 20:37:56 +0000 (22:37 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 9 Jun 2014 20:37:56 +0000 (22:37 +0200)
15 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/QProfileReset.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInAction.java [deleted file]
sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileRestoreBuiltInAction.java [new file with mode: 0644]
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 [deleted file]
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_restore_built_in_form.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb
sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileRecreateBuiltInActionTest.java [deleted file]
sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileRestoreBuiltInActionTest.java [new file with mode: 0644]
sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java

index 6c920795c2050f2c1c2b90c8c1c3ffba4ca474df..6eaf0e4daa02e7ac316aa776f8154a94c20279c3 100644 (file)
@@ -1621,8 +1621,8 @@ 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.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.restore_built_in_profiles=Restore Built-in Profiles
+quality_profiles.restore_built_in_profiles_confirmation=Are you sure you want to restore '{0}' profile(s) for '{1}' ?
 
 #------------------------------------------------------------------------------
 #
index b01688f698c2f829f37258eb6ac13e2692e2f950..935eabdebc552b34aa5e5209fe7e663eb69f28e0 100644 (file)
@@ -195,7 +195,7 @@ import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
 import org.sonar.server.qualityprofile.index.ActiveRuleNormalizer;
 import org.sonar.server.qualityprofile.ws.BulkRuleActivationActions;
 import org.sonar.server.qualityprofile.ws.ProfilesWs;
-import org.sonar.server.qualityprofile.ws.QProfileRecreateBuiltInAction;
+import org.sonar.server.qualityprofile.ws.QProfileRestoreBuiltInAction;
 import org.sonar.server.qualityprofile.ws.QProfilesWs;
 import org.sonar.server.qualityprofile.ws.RuleActivationActions;
 import org.sonar.server.rule.DeprecatedRulesDefinition;
@@ -429,7 +429,7 @@ class ServerComponents {
     pico.addSingleton(QProfileProjectLookup.class);
     pico.addSingleton(QProfileRepositoryExporter.class);
     pico.addSingleton(BuiltInProfiles.class);
-    pico.addSingleton(QProfileRecreateBuiltInAction.class);
+    pico.addSingleton(QProfileRestoreBuiltInAction.class);
     pico.addSingleton(QProfilesWs.class);
     pico.addSingleton(ProfilesWs.class);
     pico.addSingleton(RuleActivationActions.class);
index c609da55f2e6363986a97f45c9f095e14ed95cad..b7302c3031140e7460ac08b9bf8f2eaebd784d02 100644 (file)
@@ -68,6 +68,10 @@ public class QProfileReset implements ServerComponent {
     return builtInProfiles.byLanguage(language);
   }
 
+  /**
+   * Reset built-in profiles for the given language. Missing profiles are created and
+   * existing ones are updated
+   */
   void resetLanguage(String language) {
     ListMultimap<String, RulesProfile> profilesByName = loadDefinitionsGroupedByName(language);
     for (Map.Entry<String, Collection<RulesProfile>> entry : profilesByName.asMap().entrySet()) {
index 41b98160a97139a9af700fa1f7f3e247405f0ec5..c118eb7332be3a30f821a8119cf01d1f25b52693 100644 (file)
@@ -145,7 +145,7 @@ public class QProfileService implements ServerComponent {
     restore(new StringReader(backup));
   }
 
-  public void resetBuiltInProfilesForLanguage(String lang) {
+  public void restoreBuiltInProfilesForLanguage(String lang) {
     verifyAdminPermission();
     reset.resetLanguage(lang);
   }
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
deleted file mode 100644 (file)
index dc62cac..0000000
+++ /dev/null
@@ -1,82 +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.QProfileResult;
-import org.sonar.server.qualityprofile.QProfileService;
-
-public class QProfileRecreateBuiltInAction implements RequestHandler {
-
-  private final QProfileService service;
-
-  public QProfileRecreateBuiltInAction(QProfileService service) {
-    this.service = service;
-  }
-
-  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")
-      .setRequired(true);
-  }
-
-  @Override
-  public void handle(Request request, Response response) {
-    final String language = request.mandatoryParam("language");
-    service.resetBuiltInProfilesForLanguage(language);
-
-    // TODO
-    QProfileResult result = new QProfileResult();
-
-    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/QProfileRestoreBuiltInAction.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileRestoreBuiltInAction.java
new file mode 100644 (file)
index 0000000..b3e8494
--- /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.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.QProfileResult;
+import org.sonar.server.qualityprofile.QProfileService;
+
+public class QProfileRestoreBuiltInAction implements RequestHandler {
+
+  private final QProfileService service;
+
+  public QProfileRestoreBuiltInAction(QProfileService service) {
+    this.service = service;
+  }
+
+  void define(WebService.NewController controller) {
+    WebService.NewAction restoreDefault = controller.createAction("restore_built_in")
+      .setDescription("Restore built-in profiles from the definitions declared by plugins. " +
+        "Missing profiles are created, existing ones are updated.")
+      .setSince("4.4")
+      .setPost(true)
+      .setHandler(this);
+    restoreDefault.createParam("language")
+      .setDescription("Restore the built-in profiles defined for this language")
+      .setExampleValue("java")
+      .setRequired(true);
+  }
+
+  @Override
+  public void handle(Request request, Response response) {
+    String language = request.mandatoryParam("language");
+    service.restoreBuiltInProfilesForLanguage(language);
+
+    // TODO
+    QProfileResult result = new QProfileResult();
+
+    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 e450b6525e5e1d657957a35445dcc4995bfc213d..132f84c9144da7c365abcb5540fa96c6eee95842 100644 (file)
@@ -25,14 +25,14 @@ public class QProfilesWs implements WebService {
 
   public static final String API_ENDPOINT = "api/qualityprofiles";
 
-  private final QProfileRecreateBuiltInAction recreateBuiltInAction;
+  private final QProfileRestoreBuiltInAction resetAction;
   private final RuleActivationActions ruleActivationActions;
   private final BulkRuleActivationActions bulkRuleActivationActions;
 
-  public QProfilesWs(QProfileRecreateBuiltInAction recreateBuiltInAction,
+  public QProfilesWs(QProfileRestoreBuiltInAction resetAction,
                      RuleActivationActions ruleActivationActions,
                      BulkRuleActivationActions bulkRuleActivationActions) {
-    this.recreateBuiltInAction = recreateBuiltInAction;
+    this.resetAction = resetAction;
     this.ruleActivationActions = ruleActivationActions;
     this.bulkRuleActivationActions = bulkRuleActivationActions;
   }
@@ -43,7 +43,7 @@ public class QProfilesWs implements WebService {
       .setDescription("Quality Profiles")
       .setSince("4.4");
 
-    recreateBuiltInAction.define(controller);
+    resetAction.define(controller);
     ruleActivationActions.define(controller);
     bulkRuleActivationActions.define(controller);
 
index 58d2e10e31ac1eca2267f7ccda8f609da3397df4..f7bbec8d0caf9111b65442236e93b3b801ffded4 100644 (file)
@@ -59,24 +59,24 @@ class ProfilesController < ApplicationController
     redirect_to :action => 'index'
   end
 
-  # Modal window to recreate built-in profiles
-  # GET /profiles/recreate_built_in_form/<profile id>
-  def recreate_built_in_form
+  # Modal window to restore built-in profiles
+  # GET /profiles/restore_built_in_form/<profile id>
+  def restore_built_in_form
     verify_ajax_request
     require_parameters 'language'
     @language = java_facade.getLanguages().find { |l| l.getKey()==params[:language].to_s }
     call_backend do
       @builtin_profile_names = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).builtInProfileNamesForLanguage(params[:language].to_s)
     end
-    render :partial => 'profiles/recreate_built_in_form'
+    render :partial => 'profiles/restore_built_in_form'
   end
 
-  # POST /profiles/recreate_built_in_form?language=<language>
-  def recreate_built_in
+  # POST /profiles/restore_built_in?language=<language>
+  def restore_built_in
     verify_post_request
     require_parameters 'language'
     call_backend do
-      Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).resetBuiltInProfilesForLanguage(params[:language].to_s)
+      Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).restoreBuiltInProfilesForLanguage(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
deleted file mode 100644 (file)
index d35429a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<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">
-      <%= h message('quality_profiles.recreate_built_in_profiles_confirmation', :params => [@builtin_profile_names.join('\', \''), @language.getName()]) -%>
-    </div>
-
-    <div class="modal-foot">
-      <input type="submit" value="<%= h message('restore') -%>" id="recreate-built-in-profiles-submit"/>
-      <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_built_in_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_restore_built_in_form.html.erb
new file mode 100644 (file)
index 0000000..53fe42c
--- /dev/null
@@ -0,0 +1,18 @@
+<form id="restore-built-in-profiles-form" action="profiles/restore_built_in" method="POST">
+  <fieldset>
+    <input type="hidden" name="language" value="<%= @language.getKey() -%>"/>
+
+    <div class="modal-head">
+      <h2><%= h message('quality_profiles.restore_built_in_profiles') -%></h2>
+    </div>
+
+    <div class="modal-body">
+      <%= h message('quality_profiles.restore_built_in_profiles_confirmation', :params => [@builtin_profile_names.join('\', \''), @language.getName()]) -%>
+    </div>
+
+    <div class="modal-foot">
+      <input type="submit" value="<%= h message('restore') -%>" id="restore-built-in-profiles-submit"/>
+      <a href="#" onclick="return closeModalWindow()" id="restore-built-in-profiles-cancel"><%= h message('cancel') -%></a>
+    </div>
+  </fieldset>
+</form>
index 89657c272c722062feeb774bcc8e4193706212dd..962e3cb3af5237358e0ca03479409470901d1c09 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/recreate_built_in_form?language=<%= u language.getKey() -%>"
-             class="open-modal link-action"><%= message('quality_profiles.recreate_built_in_profiles') -%></a>
+          <a id="create-link-<%= language.getKey() -%>" href="<%= ApplicationController.root_context -%>/profiles/restore_built_in_form?language=<%= u language.getKey() -%>"
+             class="open-modal link-action"><%= message('quality_profiles.restore_built_in_profiles') -%></a>
         </li>
       </ul>
     <% end %>
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
deleted file mode 100644 (file)
index ec899c3..0000000
+++ /dev/null
@@ -1,87 +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.QProfileResult;
-import org.sonar.server.qualityprofile.QProfileService;
-import org.sonar.server.rule.RuleService;
-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
-  QProfileService profileService;
-
-  WsTester tester;
-
-  @Before
-  public void setUp() throws Exception {
-    QProfileService profileService = mock(QProfileService.class);
-    RuleService ruleService = mock(RuleService.class);
-    tester = new WsTester(new QProfilesWs(
-      new QProfileRecreateBuiltInAction(this.profileService),
-      new RuleActivationActions(profileService),
-      new BulkRuleActivationActions(profileService, ruleService)));
-  }
-
-  @Test
-  public void return_empty_result_when_no_infos_or_warnings() throws Exception {
-    //when(profileService.resetBuiltInProfilesForLanguage("java")).thenReturn(new QProfileResult());
-
-    WsTester.TestRequest request = tester.newPostRequest("api/qualityprofiles", "recreate_built_in").setParam("language", "java");
-    request.execute().assertNoContent();
-  }
-
-  // TODO
-//  @Test
-//  public void show_infos() throws Exception {
-//    when(profileService.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(profileService.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(profileService.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/QProfileRestoreBuiltInActionTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileRestoreBuiltInActionTest.java
new file mode 100644 (file)
index 0000000..b6756ed
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * 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.QProfileService;
+import org.sonar.server.rule.RuleService;
+import org.sonar.server.ws.WsTester;
+
+import static org.mockito.Mockito.mock;
+
+@RunWith(MockitoJUnitRunner.class)
+public class QProfileRestoreBuiltInActionTest {
+
+  @Mock
+  QProfileService profileService;
+
+  WsTester tester;
+
+  @Before
+  public void setUp() throws Exception {
+    QProfileService profileService = mock(QProfileService.class);
+    RuleService ruleService = mock(RuleService.class);
+    tester = new WsTester(new QProfilesWs(
+      new QProfileRestoreBuiltInAction(this.profileService),
+      new RuleActivationActions(profileService),
+      new BulkRuleActivationActions(profileService, ruleService)));
+  }
+
+  @Test
+  public void return_empty_result_when_no_infos_or_warnings() throws Exception {
+    //when(profileService.resetBuiltInProfilesForLanguage("java")).thenReturn(new QProfileResult());
+
+    WsTester.TestRequest request = tester.newPostRequest("api/qualityprofiles", "restore_built_in").setParam("language", "java");
+    request.execute().assertNoContent();
+  }
+
+  // TODO
+//  @Test
+//  public void show_infos() throws Exception {
+//    when(profileService.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(profileService.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(profileService.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");
+//  }
+}
index dc3b6c5d26bdd9499c15079948b70e020e4aa114..057f2081bba1ef7f7fa8530b1f515c7d99d0879f 100644 (file)
@@ -52,11 +52,10 @@ import static org.fest.assertions.Fail.fail;
 
 public class QProfilesWsMediumTest {
 
-
   @ClassRule
   public static ServerTester tester = new ServerTester();
 
-  private static final String API_BUILT_IN_METHOD = "recreate_built_in";
+  private static final String API_BUILT_IN_METHOD = "restore_built_in";
 
   QProfilesWs ws;
   DbClient db;
index 4412d463803333af75662def650be70b23716066..a26a4f92cd8f9bbd3c264b6b0b68bab725b06b9a 100644 (file)
@@ -38,7 +38,7 @@ public class QProfilesWsTest {
   public void setUp() {
     QProfileService profileService = mock(QProfileService.class);
     RuleService ruleService = mock(RuleService.class);
-    controller = new WsTester(new QProfilesWs(new QProfileRecreateBuiltInAction(
+    controller = new WsTester(new QProfilesWs(new QProfileRestoreBuiltInAction(
       mock(QProfileService.class)),
       new RuleActivationActions(profileService),
       new BulkRuleActivationActions(profileService, ruleService)
@@ -54,8 +54,8 @@ public class QProfilesWsTest {
   }
 
   @Test
-  public void define_recreate_built_action() throws Exception {
-    WebService.Action restoreProfiles = controller.action("recreate_built_in");
+  public void define_restore_built_action() throws Exception {
+    WebService.Action restoreProfiles = controller.action("restore_built_in");
     assertThat(restoreProfiles).isNotNull();
     assertThat(restoreProfiles.isPost()).isTrue();
     assertThat(restoreProfiles.params()).hasSize(1);