diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-05-06 09:19:24 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-05-06 09:19:24 +0200 |
commit | 2b3ea2a1f270f0ec43b6d08e1702ea145a4d58c0 (patch) | |
tree | e9647eaf8259165536e3b14932f5afe4e85b2d02 /sonar-server | |
parent | 09582321164657872f5b3c38afb2473f449210e0 (diff) | |
download | sonarqube-2b3ea2a1f270f0ec43b6d08e1702ea145a4d58c0.tar.gz sonarqube-2b3ea2a1f270f0ec43b6d08e1702ea145a4d58c0.zip |
Draft of RuleActivationService
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java | 129 | ||||
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/qualityprofile/BulkRuleActivation.java | 24 | ||||
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivation.java | 71 | ||||
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivationService.java | 89 | ||||
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRuleAction.java | 66 | ||||
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProfilesWs.java | 1 | ||||
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfilesWs.java (renamed from sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QualityProfilesWs.java) | 13 | ||||
-rw-r--r-- | sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileRestoreDefaultActionTest.java | 6 |
8 files changed, 381 insertions, 18 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java b/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java index 8dea431807e..64ee5d16172 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java @@ -55,7 +55,13 @@ import org.sonar.core.measure.MeasureFilterFactory; import org.sonar.core.metric.DefaultMetricFinder; import org.sonar.core.notification.DefaultNotificationManager; import org.sonar.core.permission.PermissionFacade; -import org.sonar.core.persistence.*; +import org.sonar.core.persistence.DaoUtils; +import org.sonar.core.persistence.DatabaseVersion; +import org.sonar.core.persistence.DefaultDatabase; +import org.sonar.core.persistence.MyBatis; +import org.sonar.core.persistence.PreviewDatabaseFactory; +import org.sonar.core.persistence.SemaphoreUpdater; +import org.sonar.core.persistence.SemaphoresImpl; import org.sonar.core.preview.PreviewCache; import org.sonar.core.profiling.Profiling; import org.sonar.core.purge.PurgeProfiler; @@ -87,10 +93,32 @@ import org.sonar.server.component.ws.ResourcesWs; import org.sonar.server.db.EmbeddedDatabaseFactory; import org.sonar.server.db.migrations.DatabaseMigrations; import org.sonar.server.db.migrations.DatabaseMigrator; -import org.sonar.server.debt.*; +import org.sonar.server.debt.DebtCharacteristicsXMLImporter; +import org.sonar.server.debt.DebtModelBackup; +import org.sonar.server.debt.DebtModelLookup; +import org.sonar.server.debt.DebtModelOperations; +import org.sonar.server.debt.DebtModelPluginRepository; +import org.sonar.server.debt.DebtModelService; +import org.sonar.server.debt.DebtModelXMLExporter; +import org.sonar.server.debt.DebtRulesXMLImporter; import org.sonar.server.es.ESIndex; import org.sonar.server.es.ESNode; -import org.sonar.server.issue.*; +import org.sonar.server.issue.ActionService; +import org.sonar.server.issue.AssignAction; +import org.sonar.server.issue.CommentAction; +import org.sonar.server.issue.DefaultIssueFinder; +import org.sonar.server.issue.InternalRubyIssueService; +import org.sonar.server.issue.IssueBulkChangeService; +import org.sonar.server.issue.IssueChangelogFormatter; +import org.sonar.server.issue.IssueChangelogService; +import org.sonar.server.issue.IssueCommentService; +import org.sonar.server.issue.IssueService; +import org.sonar.server.issue.IssueStatsFinder; +import org.sonar.server.issue.PlanAction; +import org.sonar.server.issue.PublicRubyIssueService; +import org.sonar.server.issue.ServerIssueStorage; +import org.sonar.server.issue.SetSeverityAction; +import org.sonar.server.issue.TransitionAction; import org.sonar.server.issue.actionplan.ActionPlanService; import org.sonar.server.issue.actionplan.ActionPlanWs; import org.sonar.server.issue.filter.IssueFilterService; @@ -107,16 +135,68 @@ import org.sonar.server.permission.PermissionFinder; import org.sonar.server.platform.ws.RestartHandler; import org.sonar.server.platform.ws.ServerWs; import org.sonar.server.platform.ws.SystemWs; -import org.sonar.server.plugins.*; +import org.sonar.server.plugins.BatchWs; +import org.sonar.server.plugins.InstalledPluginReferentialFactory; +import org.sonar.server.plugins.PluginDownloader; +import org.sonar.server.plugins.ServerExtensionInstaller; +import org.sonar.server.plugins.ServerPluginJarInstaller; +import org.sonar.server.plugins.ServerPluginJarsInstaller; +import org.sonar.server.plugins.ServerPluginRepository; +import org.sonar.server.plugins.UpdateCenterClient; +import org.sonar.server.plugins.UpdateCenterMatrixFactory; import org.sonar.server.qualitygate.QgateProjectFinder; import org.sonar.server.qualitygate.QualityGates; import org.sonar.server.qualitygate.RegisterQualityGates; -import org.sonar.server.qualitygate.ws.*; -import org.sonar.server.qualityprofile.*; +import org.sonar.server.qualitygate.ws.QGatesAppAction; +import org.sonar.server.qualitygate.ws.QGatesCopyAction; +import org.sonar.server.qualitygate.ws.QGatesCreateAction; +import org.sonar.server.qualitygate.ws.QGatesCreateConditionAction; +import org.sonar.server.qualitygate.ws.QGatesDeleteConditionAction; +import org.sonar.server.qualitygate.ws.QGatesDeselectAction; +import org.sonar.server.qualitygate.ws.QGatesDestroyAction; +import org.sonar.server.qualitygate.ws.QGatesListAction; +import org.sonar.server.qualitygate.ws.QGatesRenameAction; +import org.sonar.server.qualitygate.ws.QGatesSearchAction; +import org.sonar.server.qualitygate.ws.QGatesSelectAction; +import org.sonar.server.qualitygate.ws.QGatesSetAsDefaultAction; +import org.sonar.server.qualitygate.ws.QGatesShowAction; +import org.sonar.server.qualitygate.ws.QGatesUnsetDefaultAction; +import org.sonar.server.qualitygate.ws.QGatesUpdateConditionAction; +import org.sonar.server.qualitygate.ws.QGatesWs; +import org.sonar.server.qualityprofile.DefaultProfilesCache; +import org.sonar.server.qualityprofile.ESActiveRule; +import org.sonar.server.qualityprofile.ProfilesManager; +import org.sonar.server.qualityprofile.QProfileActiveRuleOperations; +import org.sonar.server.qualityprofile.QProfileBackup; +import org.sonar.server.qualityprofile.QProfileLookup; +import org.sonar.server.qualityprofile.QProfileOperations; +import org.sonar.server.qualityprofile.QProfileProjectLookup; +import org.sonar.server.qualityprofile.QProfileProjectOperations; +import org.sonar.server.qualityprofile.QProfileRepositoryExporter; +import org.sonar.server.qualityprofile.QProfileRuleLookup; +import org.sonar.server.qualityprofile.QProfiles; +import org.sonar.server.qualityprofile.RuleActivationService; +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.rule.*; -import org.sonar.server.rule.ws.*; +import org.sonar.server.rule.DeprecatedRulesDefinition; +import org.sonar.server.rule.ESRuleTags; +import org.sonar.server.rule.RegisterRules; +import org.sonar.server.rule.RubyRuleService; +import org.sonar.server.rule.RuleDefinitionsLoader; +import org.sonar.server.rule.RuleOperations; +import org.sonar.server.rule.RuleRegistry; +import org.sonar.server.rule.RuleRepositories; +import org.sonar.server.rule.RuleTagLookup; +import org.sonar.server.rule.RuleTagOperations; +import org.sonar.server.rule.RuleTags; +import org.sonar.server.rule.Rules; +import org.sonar.server.rule.ws.AddTagsWsHandler; +import org.sonar.server.rule.ws.RemoveTagsWsHandler; +import org.sonar.server.rule.ws.RuleSearchWsHandler; +import org.sonar.server.rule.ws.RuleShowWsHandler; +import org.sonar.server.rule.ws.RuleTagsWs; +import org.sonar.server.rule.ws.RulesWs; import org.sonar.server.rule2.RuleService; import org.sonar.server.rule2.ws.RulesWebService; import org.sonar.server.rule2.ws.SearchAction; @@ -130,7 +210,21 @@ import org.sonar.server.source.ws.ScmAction; import org.sonar.server.source.ws.ScmWriter; import org.sonar.server.source.ws.ShowAction; import org.sonar.server.source.ws.SourcesWs; -import org.sonar.server.startup.*; +import org.sonar.server.startup.CleanPreviewAnalysisCache; +import org.sonar.server.startup.CopyRequirementsFromCharacteristicsToRules; +import org.sonar.server.startup.GeneratePluginIndex; +import org.sonar.server.startup.GwtPublisher; +import org.sonar.server.startup.JdbcDriverDeployer; +import org.sonar.server.startup.LogServerId; +import org.sonar.server.startup.RegisterDashboards; +import org.sonar.server.startup.RegisterDebtModel; +import org.sonar.server.startup.RegisterMetrics; +import org.sonar.server.startup.RegisterNewMeasureFilters; +import org.sonar.server.startup.RegisterPermissionTemplates; +import org.sonar.server.startup.RegisterQualityProfiles; +import org.sonar.server.startup.RegisterServletFilters; +import org.sonar.server.startup.RenameDeprecatedPropertyKeys; +import org.sonar.server.startup.ServerMetadataPersister; import org.sonar.server.test.ws.TestsWs; import org.sonar.server.text.MacroInterpreter; import org.sonar.server.text.RubyTextService; @@ -139,9 +233,20 @@ import org.sonar.server.ui.JRubyProfiling; import org.sonar.server.ui.PageDecorations; import org.sonar.server.ui.Views; import org.sonar.server.updatecenter.ws.UpdateCenterWs; -import org.sonar.server.user.*; +import org.sonar.server.user.DefaultUserService; +import org.sonar.server.user.DoPrivileged; +import org.sonar.server.user.GroupMembershipFinder; +import org.sonar.server.user.GroupMembershipService; +import org.sonar.server.user.NewUserNotifier; +import org.sonar.server.user.SecurityRealmFactory; import org.sonar.server.user.ws.UsersWs; -import org.sonar.server.util.*; +import org.sonar.server.util.BooleanTypeValidation; +import org.sonar.server.util.FloatTypeValidation; +import org.sonar.server.util.IntegerTypeValidation; +import org.sonar.server.util.StringListTypeValidation; +import org.sonar.server.util.StringTypeValidation; +import org.sonar.server.util.TextTypeValidation; +import org.sonar.server.util.TypeValidations; import org.sonar.server.ws.ListingWs; import org.sonar.server.ws.WebServiceEngine; @@ -284,6 +389,8 @@ class ServerComponents { pico.addSingleton(ESActiveRule.class); pico.addSingleton(QProfileRestoreDefaultAction.class); pico.addSingleton(ProfilesWs.class); + pico.addSingleton(ActivateRuleAction.class); + pico.addSingleton(RuleActivationService.class); // rule pico.addSingleton(AnnotationRuleParser.class); diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/BulkRuleActivation.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/BulkRuleActivation.java new file mode 100644 index 00000000000..14b20bf40b1 --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/BulkRuleActivation.java @@ -0,0 +1,24 @@ +/* + * 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; + +public class BulkRuleActivation { + +} diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivation.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivation.java new file mode 100644 index 00000000000..65cae48c066 --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivation.java @@ -0,0 +1,71 @@ +/* + * 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; + +import com.google.common.collect.Maps; +import org.sonar.api.rule.Severity; +import org.sonar.core.qualityprofile.db.ActiveRuleKey; + +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; +import java.util.Map; + +public class RuleActivation { + + private final ActiveRuleKey key; + private final Map<String, String> parameters = Maps.newHashMap(); + private String severity = null; + + public RuleActivation(ActiveRuleKey key) { + this.key = key; + } + + public RuleActivation setSeverity(@Nullable String s) { + if (s != null) { + if (!Severity.ALL.contains(s)) { + throw new IllegalArgumentException("Unknown severity: " + s); + } + } + this.severity = s; + return this; + } + + public RuleActivation setParam(String key, @Nullable String value) { + if (value == null) { + parameters.remove(key); + } else { + parameters.put(key, value); + } + return this; + } + + public ActiveRuleKey getKey() { + return key; + } + + public Map<String, String> getParameters() { + return parameters; + } + + @CheckForNull + public String getSeverity() { + return severity; + } +} diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivationService.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivationService.java new file mode 100644 index 00000000000..f1d91b5a78a --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivationService.java @@ -0,0 +1,89 @@ +/* + * 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; + +import org.sonar.api.ServerComponent; +import org.sonar.core.permission.GlobalPermissions; +import org.sonar.core.persistence.DbSession; +import org.sonar.core.persistence.MyBatis; +import org.sonar.core.qualityprofile.db.ActiveRuleDto; +import org.sonar.core.qualityprofile.db.ActiveRuleKey; +import org.sonar.server.rule2.ActiveRuleDao; +import org.sonar.server.user.UserSession; + +public class RuleActivationService implements ServerComponent { + + private final MyBatis myBatis; + private final ActiveRuleDao activeRuleDao; + + public RuleActivationService(MyBatis myBatis, ActiveRuleDao activeRuleDao) { + this.myBatis = myBatis; + this.activeRuleDao = activeRuleDao; + } + + /** + * Activate a rule on a Quality profile. Update configuration (severity/parameters) if the rule is already + * activated. + */ + public RuleActivation activate(RuleActivation activation, UserSession userSession) { + verifyPermission(userSession); + DbSession session = myBatis.openSession(false); + try { + ActiveRuleDto dto = activeRuleDao.getByKey(activation.getKey()); + if (dto == null) { + // insert -> verify profile and parameters + + } else { + // update -> verify parameters + } + + } finally { + MyBatis.closeQuietly(session); + } + + throw new UnsupportedOperationException("TODO"); + } + + /** + * Deactivate a rule on a Quality profile. Does nothing if the rule is not activated. + */ + public boolean deactivate(ActiveRuleKey key, UserSession userSession) { + verifyPermission(userSession); + throw new UnsupportedOperationException("TODO"); + } + + /** + * Only for rules inherited from parent profile + */ + public RuleActivation revert(ActiveRuleKey key, UserSession userSession) { + verifyPermission(userSession); + throw new UnsupportedOperationException("TODO"); + } + + public void bulkActivate(BulkRuleActivation activation, UserSession userSession) { + verifyPermission(userSession); + throw new UnsupportedOperationException("TODO"); + } + + private void verifyPermission(UserSession userSession) { + userSession.checkLoggedIn(); + userSession.checkGlobalPermission(GlobalPermissions.QUALITY_PROFILE_ADMIN); + } +} diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRuleAction.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRuleAction.java new file mode 100644 index 00000000000..445609287b3 --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ActivateRuleAction.java @@ -0,0 +1,66 @@ +/* + * 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.rule.Severity; +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.server.qualityprofile.RuleActivationService; + +public class ActivateRuleAction implements RequestHandler { + + private final RuleActivationService service; + + public ActivateRuleAction(RuleActivationService service) { + this.service = service; + } + + void define(WebService.NewController controller) { + WebService.NewAction action = controller + .createAction("activate_rule") + .setHandler(this) + .setPost(true) + .setSince("4.4"); + + action.createParam("profile_lang") + .setRequired(true); + + action.createParam("profile_name") + .setRequired(true); + + action.createParam("rule_repo") + .setRequired(true); + + action.createParam("rule_key") + .setRequired(true); + + action.createParam("severity") + .setPossibleValues(Severity.ALL); + + action.createParam("params"); + } + + @Override + public void handle(Request request, Response response) throws Exception { + + } +} diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProfilesWs.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProfilesWs.java index 2356cdc5f84..da57c84cd3b 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProfilesWs.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProfilesWs.java @@ -17,7 +17,6 @@ * 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 com.google.common.io.Resources; diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QualityProfilesWs.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfilesWs.java index e6d95603ec6..292e529d8bb 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QualityProfilesWs.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfilesWs.java @@ -21,12 +21,14 @@ package org.sonar.server.qualityprofile.ws; import org.sonar.api.server.ws.WebService; -public class QualityProfilesWs implements WebService { +public class QProfilesWs implements WebService { - private final QProfileRestoreDefaultAction qProfileRestoreDefaultAction; + private final QProfileRestoreDefaultAction restoreDefaultAction; + private final ActivateRuleAction activateRuleAction; - public QualityProfilesWs(QProfileRestoreDefaultAction qProfileRestoreDefaultAction) { - this.qProfileRestoreDefaultAction = qProfileRestoreDefaultAction; + public QProfilesWs(QProfileRestoreDefaultAction qProfileRestoreDefaultAction, ActivateRuleAction activateRuleAction) { + this.restoreDefaultAction = qProfileRestoreDefaultAction; + this.activateRuleAction = activateRuleAction; } @Override @@ -34,7 +36,8 @@ public class QualityProfilesWs implements WebService { NewController controller = context.createController("api/qualityprofiles") .setDescription("Quality profiles management"); - qProfileRestoreDefaultAction.define(controller); + restoreDefaultAction.define(controller); + activateRuleAction.define(controller); controller.done(); } 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 index 5ac3bdab5eb..d68648cc57f 100644 --- 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 @@ -27,9 +27,11 @@ 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) @@ -42,7 +44,9 @@ public class QProfileRestoreDefaultActionTest { @Before public void setUp() throws Exception { - tester = new WsTester(new QualityProfilesWs(new QProfileRestoreDefaultAction(qProfileBackup))); + tester = new WsTester(new QProfilesWs( + new QProfileRestoreDefaultAction(qProfileBackup), + new ActivateRuleAction(mock(RuleActivationService.class)))); } @Test |