]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8857 split RuleActivationActions into activation and deactivation
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>
Thu, 23 Mar 2017 09:25:32 +0000 (10:25 +0100)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Thu, 23 Mar 2017 19:57:55 +0000 (20:57 +0100)
15 files changed:
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRuleAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRuleAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfilesWs.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfilesWsModule.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RuleActivationActions.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionMockTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportersActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ImportersActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsModuleTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java

diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRuleAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRuleAction.java
new file mode 100644 (file)
index 0000000..c70949d
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.rule.RuleKey;
+import org.sonar.api.rule.Severity;
+import org.sonar.api.server.ServerSide;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.KeyValueFormat;
+import org.sonar.core.util.Uuids;
+import org.sonar.server.qualityprofile.QProfileService;
+import org.sonar.server.qualityprofile.RuleActivation;
+
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ACTIVATE_RULE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ActivateActionParameters.PARAM_PARAMS;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ActivateActionParameters.PARAM_PROFILE_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ActivateActionParameters.PARAM_RESET;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ActivateActionParameters.PARAM_RULE_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ActivateActionParameters.PARAM_SEVERITY;
+
+@ServerSide
+public class ActivateRuleAction implements QProfileWsAction {
+
+  private final QProfileService service;
+
+  public ActivateRuleAction(QProfileService service) {
+    this.service = service;
+  }
+
+  public void define(WebService.NewController controller) {
+    WebService.NewAction activate = controller
+      .createAction(ACTION_ACTIVATE_RULE)
+      .setDescription("Activate a rule on a Quality profile")
+      .setHandler(this)
+      .setPost(true)
+      .setSince("4.4");
+
+    activate.createParam(PARAM_PROFILE_KEY)
+      .setDescription("Key of Quality profile, can be obtained through <code>api/profiles/list</code>")
+      .setRequired(true)
+      .setExampleValue(Uuids.UUID_EXAMPLE_01);
+
+    activate.createParam(PARAM_RULE_KEY)
+      .setDescription("Key of the rule")
+      .setRequired(true)
+      .setExampleValue("squid:AvoidCycles");
+
+    activate.createParam(PARAM_SEVERITY)
+      .setDescription(String.format("Severity. Ignored if parameter %s is true.", PARAM_RESET))
+      .setPossibleValues(Severity.ALL);
+
+    activate.createParam(PARAM_PARAMS)
+      .setDescription(String.format("Parameters as semi-colon list of <key>=<value>, for example " +
+        "'<code>params=key1=v1;key2=v2</code>'. Ignored if parameter %s is true.", PARAM_RESET));
+
+    activate.createParam(PARAM_RESET)
+      .setDescription("Reset severity and parameters of activated rule. Set the values defined on parent profile " +
+        "or from rule default values.")
+      .setBooleanPossibleValues();
+  }
+
+  @Override
+  public void handle(Request request, Response response) throws Exception {
+    RuleKey ruleKey = readRuleKey(request);
+    RuleActivation activation = new RuleActivation(ruleKey);
+    activation.setSeverity(request.param(PARAM_SEVERITY));
+    String params = request.param(PARAM_PARAMS);
+    if (params != null) {
+      activation.setParameters(KeyValueFormat.parse(params));
+    }
+    activation.setReset(Boolean.TRUE.equals(request.paramAsBoolean(PARAM_RESET)));
+    service.activate(request.mandatoryParam(PARAM_PROFILE_KEY), activation);
+  }
+
+  private static RuleKey readRuleKey(Request request) {
+    return RuleKey.parse(request.mandatoryParam(PARAM_RULE_KEY));
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRuleAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeactivateRuleAction.java
new file mode 100644 (file)
index 0000000..600c90b
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.rule.RuleKey;
+import org.sonar.api.server.ServerSide;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.core.util.Uuids;
+import org.sonar.db.qualityprofile.ActiveRuleKey;
+import org.sonar.server.qualityprofile.QProfileService;
+
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_DEACTIVATE_RULE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ActivateActionParameters.PARAM_PROFILE_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ActivateActionParameters.PARAM_RULE_KEY;
+
+@ServerSide
+public class DeactivateRuleAction implements QProfileWsAction {
+
+  private final QProfileService service;
+
+  public DeactivateRuleAction(QProfileService service) {
+    this.service = service;
+  }
+
+  public void define(WebService.NewController controller) {
+    WebService.NewAction deactivate = controller
+      .createAction(ACTION_DEACTIVATE_RULE)
+      .setDescription("Deactivate a rule on a Quality profile")
+      .setHandler(this)
+      .setPost(true)
+      .setSince("4.4");
+
+    deactivate.createParam(PARAM_PROFILE_KEY)
+      .setDescription("Key of Quality profile, can be obtained through <code>api/profiles/list</code>")
+      .setRequired(true)
+      .setExampleValue(Uuids.UUID_EXAMPLE_01);
+
+    deactivate.createParam(PARAM_RULE_KEY)
+      .setDescription("Key of the rule")
+      .setRequired(true)
+      .setExampleValue("squid:AvoidCycles");
+  }
+
+  @Override
+  public void handle(Request request, Response response) throws Exception {
+    RuleKey ruleKey = readRuleKey(request);
+    service.deactivate(ActiveRuleKey.of(request.mandatoryParam(PARAM_PROFILE_KEY), ruleKey));
+  }
+
+  private static RuleKey readRuleKey(Request request) {
+    return RuleKey.parse(request.mandatoryParam(PARAM_RULE_KEY));
+  }
+}
index 4c622bb0ae021afe58c59eaa27af3a1683739c5c..f004df52703a034c7fb16f5345ac5c4b96498b5f 100644 (file)
@@ -27,14 +27,11 @@ public class QProfilesWs implements WebService {
 
   public static final String API_ENDPOINT = CONTROLLER_QUALITY_PROFILES;
 
-  private final RuleActivationActions ruleActivationActions;
   private final BulkRuleActivationActions bulkRuleActivationActions;
   private final QProfileWsAction[] actions;
 
-  public QProfilesWs(RuleActivationActions ruleActivationActions,
-    BulkRuleActivationActions bulkRuleActivationActions,
+  public QProfilesWs(BulkRuleActivationActions bulkRuleActivationActions,
     QProfileWsAction... actions) {
-    this.ruleActivationActions = ruleActivationActions;
     this.bulkRuleActivationActions = bulkRuleActivationActions;
     this.actions = actions;
   }
@@ -45,7 +42,6 @@ public class QProfilesWs implements WebService {
       .setDescription("Manage quality profiles.")
       .setSince("4.4");
 
-    ruleActivationActions.define(controller);
     bulkRuleActivationActions.define(controller);
     for (QProfileWsAction action : actions) {
       action.define(controller);
index 50eaa911c26e7455d5e9ba30054d9bb219bdb2d3..66f3d51cc1ad7085e47f40f258db7cfaf7990c07 100644 (file)
@@ -46,7 +46,8 @@ public class QProfilesWsModule extends Module {
       RemoveProjectAction.class,
       RestoreAction.class,
       RestoreBuiltInAction.class,
-      RuleActivationActions.class,
+      ActivateRuleAction.class,
+      DeactivateRuleAction.class,
       SearchAction.class,
       SetDefaultAction.class
       );
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RuleActivationActions.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RuleActivationActions.java
deleted file mode 100644 (file)
index 9887de2..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.rule.RuleKey;
-import org.sonar.api.rule.Severity;
-import org.sonar.api.server.ServerSide;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.KeyValueFormat;
-import org.sonar.core.util.Uuids;
-import org.sonar.db.qualityprofile.ActiveRuleKey;
-import org.sonar.server.qualityprofile.QProfileService;
-import org.sonar.server.qualityprofile.RuleActivation;
-
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ACTIVATE_RULE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_DEACTIVATE_RULE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ActivateActionParameters.PARAM_PARAMS;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ActivateActionParameters.PARAM_PROFILE_KEY;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ActivateActionParameters.PARAM_RESET;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ActivateActionParameters.PARAM_RULE_KEY;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ActivateActionParameters.PARAM_SEVERITY;
-
-@ServerSide
-public class RuleActivationActions {
-
-  private final QProfileService service;
-
-  public RuleActivationActions(QProfileService service) {
-    this.service = service;
-  }
-
-  void define(WebService.NewController controller) {
-    defineActivateAction(controller);
-    defineDeactivateAction(controller);
-  }
-
-  private void defineActivateAction(WebService.NewController controller) {
-    WebService.NewAction activate = controller
-      .createAction(ACTION_ACTIVATE_RULE)
-      .setDescription("Activate a rule on a Quality profile")
-      .setHandler(this::activate)
-      .setPost(true)
-      .setSince("4.4");
-
-    defineActiveRuleKeyParameters(activate);
-
-    activate.createParam(PARAM_SEVERITY)
-      .setDescription(String.format("Severity. Ignored if parameter %s is true.", PARAM_RESET))
-      .setPossibleValues(Severity.ALL);
-
-    activate.createParam(PARAM_PARAMS)
-      .setDescription(String.format("Parameters as semi-colon list of <key>=<value>, for example " +
-        "'<code>params=key1=v1;key2=v2</code>'. Ignored if parameter %s is true.", PARAM_RESET));
-
-    activate.createParam(PARAM_RESET)
-      .setDescription("Reset severity and parameters of activated rule. Set the values defined on parent profile " +
-        "or from rule default values.")
-      .setBooleanPossibleValues();
-  }
-
-  private void defineDeactivateAction(WebService.NewController controller) {
-    WebService.NewAction deactivate = controller
-      .createAction(ACTION_DEACTIVATE_RULE)
-      .setDescription("Deactivate a rule on a Quality profile")
-      .setHandler(this::deactivate)
-      .setPost(true)
-      .setSince("4.4");
-    defineActiveRuleKeyParameters(deactivate);
-  }
-
-  private static void defineActiveRuleKeyParameters(WebService.NewAction action) {
-    action.createParam(PARAM_PROFILE_KEY)
-      .setDescription("Key of Quality profile, can be obtained through <code>api/profiles/list</code>")
-      .setRequired(true)
-      .setExampleValue(Uuids.UUID_EXAMPLE_01);
-
-    action.createParam(PARAM_RULE_KEY)
-      .setDescription("Key of the rule")
-      .setRequired(true)
-      .setExampleValue("squid:AvoidCycles");
-  }
-
-  private void activate(Request request, Response response) {
-    RuleKey ruleKey = readRuleKey(request);
-    RuleActivation activation = new RuleActivation(ruleKey);
-    activation.setSeverity(request.param(PARAM_SEVERITY));
-    String params = request.param(PARAM_PARAMS);
-    if (params != null) {
-      activation.setParameters(KeyValueFormat.parse(params));
-    }
-    activation.setReset(Boolean.TRUE.equals(request.paramAsBoolean(PARAM_RESET)));
-    service.activate(request.mandatoryParam(PARAM_PROFILE_KEY), activation);
-  }
-
-  private void deactivate(Request request, Response response) {
-    RuleKey ruleKey = readRuleKey(request);
-    service.deactivate(ActiveRuleKey.of(request.mandatoryParam(PARAM_PROFILE_KEY), ruleKey));
-  }
-
-  private static RuleKey readRuleKey(Request request) {
-    return RuleKey.parse(request.mandatoryParam(PARAM_RULE_KEY));
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java
new file mode 100644 (file)
index 0000000..381f1b1
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.Test;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.server.qualityprofile.QProfileService;
+import org.sonar.server.ws.WsActionTester;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+
+public class ActivateRuleActionTest {
+
+  @Test
+  public void define_activate_rule_action() {
+    ActivateRuleAction action = new ActivateRuleAction(mock(QProfileService.class));
+    WebService.Action definition = new WsActionTester(action).getDef();
+    assertThat(definition).isNotNull();
+    assertThat(definition.isPost()).isTrue();
+    assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("severity", "profile_key", "reset", "rule_key", "params");
+  }
+}
index 0730036a52b014762da87152288a0a94f59061c2..fb591c24523231ba6a66b7cd70151378977d2ae8 100644 (file)
@@ -143,7 +143,7 @@ public class ChangeParentActionTest {
 
   @Test
   public void define_change_parent_action() {
-    WebService.Action changeParent = new WsTester(new QProfilesWs(mock(RuleActivationActions.class), mock(BulkRuleActivationActions.class), underTest))
+    WebService.Action changeParent = new WsTester(new QProfilesWs(mock(BulkRuleActivationActions.class), underTest))
       .action(QualityProfileWsParameters.CONTROLLER_QUALITY_PROFILES, "change_parent");
     assertThat(changeParent).isNotNull();
     assertThat(changeParent.isPost()).isTrue();
index e8c1bebf732a766a895c4acdfe76a683d4937c67..1de08f42ccefcbb3ff442a7446a8dca0baad380e 100644 (file)
@@ -63,7 +63,7 @@ public class ChangelogActionMockTest {
 
   @Before
   public void before() {
-    wsTester = new WsTester(new QProfilesWs(mock(RuleActivationActions.class), mock(BulkRuleActivationActions.class),
+    wsTester = new WsTester(new QProfilesWs(mock(BulkRuleActivationActions.class),
       new ChangelogAction(changelogLoader, wsSupport, new Languages(), dbTester.getDbClient())));
     organization = dbTester.organizations().insert();
   }
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java
new file mode 100644 (file)
index 0000000..4b6107f
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.Test;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.server.qualityprofile.QProfileService;
+import org.sonar.server.ws.WsActionTester;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+
+public class DeactivateRuleActionTest {
+
+  @Test
+  public void define_deactivate_rule_action() {
+    DeactivateRuleAction action = new DeactivateRuleAction(mock(QProfileService.class));
+    WebService.Action definition = new WsActionTester(action).getDef();
+    assertThat(definition).isNotNull();
+    assertThat(definition.isPost()).isTrue();
+    assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("profile_key", "rule_key");
+  }
+}
index 52fe01e8ee0cf1a1dfde555003a8f721055e5c9f..7b953ea5322d25814ff8c8aad54a5c5bfa6ee225 100644 (file)
@@ -32,7 +32,7 @@ public class ExportersActionTest {
   @Test
   public void importers_nominal() throws Exception {
     WsTester wsTester = new WsTester(new QProfilesWs(
-      mock(RuleActivationActions.class), mock(BulkRuleActivationActions.class),
+      mock(BulkRuleActivationActions.class),
       new ExportersAction(createExporters())));
 
     wsTester.newGetRequest("api/qualityprofiles", "exporters").execute().assertJson(getClass(), "exporters.json");
index 2f8c089f5aae335a87f49408563093c5ffe05496..feb7ee2b596b51a9134bad565fd9d5e29899ac52 100644 (file)
@@ -33,7 +33,7 @@ public class ImportersActionTest {
   @Test
   public void importers_nominal() throws Exception {
     WsTester wsTester = new WsTester(new QProfilesWs(
-      mock(RuleActivationActions.class), mock(BulkRuleActivationActions.class),
+      mock(BulkRuleActivationActions.class),
       new ImportersAction(createImporters())));
 
     wsTester.newGetRequest("api/qualityprofiles", "importers").execute().assertJson(getClass(), "importers.json");
index 4a5c8e67f482d20ac1d47eede28651cb895eb421..f19b3b6846fe5fb2de6212fc5fa520645356d10d 100644 (file)
@@ -61,7 +61,6 @@ public class ProjectsActionTest {
   private ComponentDto project4;
 
   private WsTester wsTester = new WsTester(new QProfilesWs(
-    mock(RuleActivationActions.class),
     mock(BulkRuleActivationActions.class),
     new ProjectsAction(dbClient, userSessionRule)));
 
index 4c66f747be148822e4ed1ef5eba2ff5629cd9a43..d4a17603fd80f4c9ec5c540f3dc6df64ad1d935b 100644 (file)
@@ -29,6 +29,6 @@ public class QProfilesWsModuleTest {
   public void verify_count_of_added_components() {
     ComponentContainer container = new ComponentContainer();
     new QProfilesWsModule().configure(container);
-    assertThat(container.size()).isEqualTo(24 + 2);
+    assertThat(container.size()).isEqualTo(25 + 2);
   }
 }
index 054dbb69f85d93320aac627426c8eeb7810ad756..78caac67c0a1bd4ae11046b21a0b29699046082f 100644 (file)
@@ -40,7 +40,6 @@ import org.sonar.server.ws.WsTester;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ACTIVATE_RULE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_DEACTIVATE_RULE;
 
 public class QProfilesWsTest {
   @Rule
@@ -62,7 +61,6 @@ public class QProfilesWsTest {
     ProfileImporter[] importers = createImporters(languages);
 
     controller = new WsTester(new QProfilesWs(
-      new RuleActivationActions(profileService),
       new BulkRuleActivationActions(profileService, null),
       new CreateAction(null, null, null, languages, wsSupport, userSessionRule, null, importers),
       new ImportersAction(importers),
@@ -115,22 +113,6 @@ public class QProfilesWsTest {
     assertThat(search.param("organization").since()).isEqualTo("6.4");
   }
 
-  @Test
-  public void define_activate_rule_action() {
-    WebService.Action restoreProfiles = controller.action(ACTION_ACTIVATE_RULE);
-    assertThat(restoreProfiles).isNotNull();
-    assertThat(restoreProfiles.isPost()).isTrue();
-    assertThat(restoreProfiles.params()).hasSize(5);
-  }
-
-  @Test
-  public void define_deactivate_rule_action() {
-    WebService.Action restoreProfiles = controller.action(ACTION_DEACTIVATE_RULE);
-    assertThat(restoreProfiles).isNotNull();
-    assertThat(restoreProfiles.isPost()).isTrue();
-    assertThat(restoreProfiles.params()).hasSize(2);
-  }
-
   @Test
   public void define_set_default_action() {
     WebService.Action setDefault = controller.action("set_default");
index e4f2318d125cc2eb0b53b41af7d5ae6a740c350e..3bcbb08a95526d8124dd629eb526e639244196eb 100644 (file)
@@ -24,7 +24,6 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.utils.System2;
-import org.sonar.core.util.UuidFactoryFast;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.organization.OrganizationDto;
@@ -35,7 +34,6 @@ import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.exceptions.UnauthorizedException;
 import org.sonar.server.organization.TestDefaultOrganizationProvider;
-import org.sonar.server.qualityprofile.QProfileFactory;
 import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.WsTester;
@@ -70,7 +68,6 @@ public class RenameActionTest {
       dbClient,
       userSessionRule);
     tester = new WsTester(new QProfilesWs(
-      mock(RuleActivationActions.class),
       mock(BulkRuleActivationActions.class),
       underTest));
     organization = db.organizations().insert();