From dc56eff40ee939c2e06ad0e33fd62b27e64f8fb8 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 27 Aug 2014 16:48:56 +0200 Subject: [PATCH] SONAR-5541 Add REST Web Services in the online API documentation --- .../sonar/server/component/ws/EventsWs.java | 45 +++++ .../sonar/server/config/ws/PropertiesWs.java | 45 +++++ .../server/measure/ws/ManualMeasuresWs.java | 45 +++++ .../sonar/server/measure/ws/MetricsWs.java | 46 +++++ .../server/platform/ServerComponents.java | 165 +++--------------- .../org/sonar/server/user/ws/FavoritesWs.java | 45 +++++ .../server/user/ws/UserPropertiesWs.java | 46 +++++ .../server/component/ws/EventsWsTest.java | 40 +++++ .../server/config/ws/PropertiesWsTest.java | 41 +++++ .../measure/ws/ManualMeasuresWsTest.java | 41 +++++ .../server/measure/ws/MetricsWsTest.java | 41 +++++ .../sonar/server/user/ws/FavoritesWsTest.java | 40 +++++ .../server/user/ws/UserPropertiesWsTest.java | 41 +++++ 13 files changed, 544 insertions(+), 137 deletions(-) create mode 100644 server/sonar-server/src/main/java/org/sonar/server/component/ws/EventsWs.java create mode 100644 server/sonar-server/src/main/java/org/sonar/server/config/ws/PropertiesWs.java create mode 100644 server/sonar-server/src/main/java/org/sonar/server/measure/ws/ManualMeasuresWs.java create mode 100644 server/sonar-server/src/main/java/org/sonar/server/measure/ws/MetricsWs.java create mode 100644 server/sonar-server/src/main/java/org/sonar/server/user/ws/FavoritesWs.java create mode 100644 server/sonar-server/src/main/java/org/sonar/server/user/ws/UserPropertiesWs.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/component/ws/EventsWsTest.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/config/ws/PropertiesWsTest.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/measure/ws/ManualMeasuresWsTest.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/measure/ws/MetricsWsTest.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/user/ws/FavoritesWsTest.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/user/ws/UserPropertiesWsTest.java diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/EventsWs.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/EventsWs.java new file mode 100644 index 00000000000..629112cada7 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/EventsWs.java @@ -0,0 +1,45 @@ +/* + * 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.component.ws; + +import org.sonar.api.server.ws.RailsHandler; +import org.sonar.api.server.ws.WebService; + +public class EventsWs implements WebService { + + @Override + public void define(Context context) { + NewController controller = context.createController("api/events"); + controller.setDescription("Project's events management"); + controller.setSince("2.6"); + + defineIndexAction(controller); + + controller.done(); + } + + private void defineIndexAction(NewController controller) { + controller.createAction("index") + .setDescription("Documentation of this web service is available here") + .setSince("2.6") + .setHandler(RailsHandler.INSTANCE); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/config/ws/PropertiesWs.java b/server/sonar-server/src/main/java/org/sonar/server/config/ws/PropertiesWs.java new file mode 100644 index 00000000000..b90b1e18fb7 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/config/ws/PropertiesWs.java @@ -0,0 +1,45 @@ +/* + * 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.config.ws; + +import org.sonar.api.server.ws.RailsHandler; +import org.sonar.api.server.ws.WebService; + +public class PropertiesWs implements WebService { + + @Override + public void define(Context context) { + NewController controller = context.createController("api/properties"); + controller.setDescription("Properties management"); + controller.setSince("2.6"); + + defineIndexAction(controller); + + controller.done(); + } + + private void defineIndexAction(NewController controller) { + controller.createAction("index") + .setDescription("Documentation of this web service is available here") + .setSince("2.6") + .setHandler(RailsHandler.INSTANCE); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ManualMeasuresWs.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ManualMeasuresWs.java new file mode 100644 index 00000000000..553efe1f5cd --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ManualMeasuresWs.java @@ -0,0 +1,45 @@ +/* + * 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.measure.ws; + +import org.sonar.api.server.ws.RailsHandler; +import org.sonar.api.server.ws.WebService; + +public class ManualMeasuresWs implements WebService { + + public void define(Context context) { + NewController controller = context.createController("api/manual_measures"); + controller.setDescription("Manual measures management"); + controller.setSince("2.10"); + + defineIndexAction(controller); + + controller.done(); + } + + private void defineIndexAction(NewController controller) { + controller.createAction("index") + .setDescription("Documentation of this web service is available here") + .setSince("2.10") + .setHandler(RailsHandler.INSTANCE); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MetricsWs.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MetricsWs.java new file mode 100644 index 00000000000..897d7c6f9f3 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MetricsWs.java @@ -0,0 +1,46 @@ +/* + * 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.measure.ws; + +import org.sonar.api.server.ws.RailsHandler; +import org.sonar.api.server.ws.WebService; + +public class MetricsWs implements WebService { + + @Override + public void define(Context context) { + NewController controller = context.createController("api/metrics"); + controller.setDescription("Metrics management"); + controller.setSince("2.6"); + + defineIndexAction(controller); + + controller.done(); + } + + private void defineIndexAction(NewController controller) { + controller.createAction("index") + .setDescription("Documentation of this web service is available here") + .setSince("2.6") + .setHandler(RailsHandler.INSTANCE); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java index a850c928bcd..148f27a2b36 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java @@ -52,13 +52,7 @@ import org.sonar.core.measure.db.MeasureFilterDao; import org.sonar.core.metric.DefaultMetricFinder; import org.sonar.core.notification.DefaultNotificationManager; import org.sonar.core.permission.PermissionFacade; -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.persistence.*; import org.sonar.core.preview.PreviewCache; import org.sonar.core.profiling.Profiling; import org.sonar.core.purge.PurgeProfiler; @@ -92,42 +86,18 @@ import org.sonar.server.charts.ChartFactory; import org.sonar.server.component.DefaultComponentFinder; import org.sonar.server.component.DefaultRubyComponentService; import org.sonar.server.component.persistence.ComponentDao; -import org.sonar.server.component.ws.ComponentAppAction; -import org.sonar.server.component.ws.ComponentsWs; -import org.sonar.server.component.ws.ProjectsWs; -import org.sonar.server.component.ws.ResourcesWs; +import org.sonar.server.component.ws.*; +import org.sonar.server.config.ws.PropertiesWs; import org.sonar.server.db.DatabaseChecker; import org.sonar.server.db.DbClient; 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.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.debt.*; import org.sonar.server.duplication.ws.DuplicationsJsonWriter; import org.sonar.server.duplication.ws.DuplicationsParser; import org.sonar.server.duplication.ws.DuplicationsWs; -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.*; import org.sonar.server.issue.actionplan.ActionPlanService; import org.sonar.server.issue.actionplan.ActionPlanWs; import org.sonar.server.issue.db.IssueDao; @@ -143,6 +113,8 @@ import org.sonar.server.measure.MeasureFilterExecutor; import org.sonar.server.measure.MeasureFilterFactory; import org.sonar.server.measure.persistence.MeasureDao; import org.sonar.server.measure.persistence.MetricDao; +import org.sonar.server.measure.ws.ManualMeasuresWs; +import org.sonar.server.measure.ws.MetricsWs; import org.sonar.server.measure.ws.TimeMachineWs; import org.sonar.server.notifications.NotificationCenter; import org.sonar.server.notifications.NotificationService; @@ -154,84 +126,22 @@ import org.sonar.server.platform.ws.L10nWs; 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.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.plugins.*; import org.sonar.server.qualitygate.QgateProjectFinder; import org.sonar.server.qualitygate.QualityGates; import org.sonar.server.qualitygate.RegisterQualityGates; -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.BuiltInProfiles; -import org.sonar.server.qualityprofile.QProfileBackuper; -import org.sonar.server.qualityprofile.QProfileCopier; -import org.sonar.server.qualityprofile.QProfileExporters; -import org.sonar.server.qualityprofile.QProfileFactory; -import org.sonar.server.qualityprofile.QProfileLoader; -import org.sonar.server.qualityprofile.QProfileLookup; -import org.sonar.server.qualityprofile.QProfileProjectLookup; -import org.sonar.server.qualityprofile.QProfileProjectOperations; -import org.sonar.server.qualityprofile.QProfileRepositoryExporter; -import org.sonar.server.qualityprofile.QProfileReset; -import org.sonar.server.qualityprofile.QProfileService; -import org.sonar.server.qualityprofile.QProfiles; -import org.sonar.server.qualityprofile.RegisterQualityProfiles; -import org.sonar.server.qualityprofile.RuleActivator; -import org.sonar.server.qualityprofile.RuleActivatorContextFactory; +import org.sonar.server.qualitygate.ws.*; +import org.sonar.server.qualityprofile.*; import org.sonar.server.qualityprofile.db.ActiveRuleDao; 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.QProfileRestoreBuiltInAction; -import org.sonar.server.qualityprofile.ws.QProfilesWs; -import org.sonar.server.qualityprofile.ws.RuleActivationActions; -import org.sonar.server.rule.DefaultRuleFinder; -import org.sonar.server.rule.DeprecatedRulesDefinition; -import org.sonar.server.rule.RegisterRules; -import org.sonar.server.rule.RubyRuleService; -import org.sonar.server.rule.RuleCreator; -import org.sonar.server.rule.RuleDefinitionsLoader; -import org.sonar.server.rule.RuleDeleter; -import org.sonar.server.rule.RuleOperations; -import org.sonar.server.rule.RuleRepositories; -import org.sonar.server.rule.RuleService; -import org.sonar.server.rule.RuleUpdater; +import org.sonar.server.qualityprofile.ws.*; +import org.sonar.server.rule.*; import org.sonar.server.rule.db.RuleDao; import org.sonar.server.rule.index.RuleIndex; import org.sonar.server.rule.index.RuleNormalizer; -import org.sonar.server.rule.ws.ActiveRuleCompleter; -import org.sonar.server.rule.ws.AppAction; -import org.sonar.server.rule.ws.DeleteAction; -import org.sonar.server.rule.ws.RuleMapping; -import org.sonar.server.rule.ws.RulesWebService; -import org.sonar.server.rule.ws.SearchAction; -import org.sonar.server.rule.ws.TagsAction; -import org.sonar.server.rule.ws.UpdateAction; -import org.sonar.server.search.IndexClient; -import org.sonar.server.search.IndexQueue; -import org.sonar.server.search.IndexSynchronizer; -import org.sonar.server.search.SearchClient; -import org.sonar.server.search.SearchHealth; +import org.sonar.server.rule.ws.*; +import org.sonar.server.search.*; import org.sonar.server.source.CodeColorizers; import org.sonar.server.source.DeprecatedSourceDecorator; import org.sonar.server.source.HtmlSourceDecorator; @@ -240,27 +150,9 @@ 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.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.RegisterServletFilters; -import org.sonar.server.startup.RenameDeprecatedPropertyKeys; -import org.sonar.server.startup.ServerMetadataPersister; +import org.sonar.server.startup.*; import org.sonar.server.test.CoverageService; -import org.sonar.server.test.ws.CoverageShowAction; -import org.sonar.server.test.ws.CoverageWs; -import org.sonar.server.test.ws.TestsCoveredFilesAction; -import org.sonar.server.test.ws.TestsShowAction; -import org.sonar.server.test.ws.TestsTestCasesAction; -import org.sonar.server.test.ws.TestsWs; +import org.sonar.server.test.ws.*; import org.sonar.server.text.MacroInterpreter; import org.sonar.server.text.RubyTextService; import org.sonar.server.ui.JRubyI18n; @@ -268,20 +160,11 @@ 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.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.*; +import org.sonar.server.user.ws.FavoritesWs; +import org.sonar.server.user.ws.UserPropertiesWs; import org.sonar.server.user.ws.UsersWs; -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.util.*; import org.sonar.server.ws.ListingWs; import org.sonar.server.ws.WebServiceEngine; @@ -492,6 +375,8 @@ class ServerComponents { pico.addSingleton(DefaultMetricFinder.class); pico.addSingleton(ServerLifecycleNotifier.class); pico.addSingleton(TimeMachineWs.class); + pico.addSingleton(ManualMeasuresWs.class); + pico.addSingleton(MetricsWs.class); // quality gates pico.addSingleton(QualityGateDao.class); @@ -534,6 +419,8 @@ class ServerComponents { pico.addSingleton(DefaultUserFinder.class); pico.addSingleton(DefaultUserService.class); pico.addSingleton(UsersWs.class); + pico.addSingleton(FavoritesWs.class); + pico.addSingleton(UserPropertiesWs.class); // groups pico.addSingleton(GroupMembershipService.class); @@ -554,6 +441,7 @@ class ServerComponents { pico.addSingleton(ComponentsWs.class); pico.addSingleton(ProjectsWs.class); pico.addSingleton(ComponentAppAction.class); + pico.addSingleton(EventsWs.class); // issues pico.addSingleton(ServerIssueStorage.class); @@ -641,6 +529,9 @@ class ServerComponents { pico.addSingleton(TestsCoveredFilesAction.class); pico.addSingleton(TestsShowAction.class); + // Properties + pico.addSingleton(PropertiesWs.class); + // graphs and perspective related classes pico.addSingleton(TestablePerspectiveLoader.class); pico.addSingleton(TestPlanPerspectiveLoader.class); diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ws/FavoritesWs.java b/server/sonar-server/src/main/java/org/sonar/server/user/ws/FavoritesWs.java new file mode 100644 index 00000000000..25fb4649841 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/user/ws/FavoritesWs.java @@ -0,0 +1,45 @@ +/* + * 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.user.ws; + +import org.sonar.api.server.ws.RailsHandler; +import org.sonar.api.server.ws.WebService; + +public class FavoritesWs implements WebService { + + @Override + public void define(Context context) { + NewController controller = context.createController("api/favorites"); + controller.setDescription("User's favorites management"); + controller.setSince("2.6"); + + defineIndexAction(controller); + + controller.done(); + } + + private void defineIndexAction(NewController controller) { + controller.createAction("index") + .setDescription("Documentation of this web service is available here") + .setSince("2.6") + .setHandler(RailsHandler.INSTANCE); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ws/UserPropertiesWs.java b/server/sonar-server/src/main/java/org/sonar/server/user/ws/UserPropertiesWs.java new file mode 100644 index 00000000000..a05a9d2a752 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/user/ws/UserPropertiesWs.java @@ -0,0 +1,46 @@ +/* + * 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.user.ws; + +import org.sonar.api.server.ws.RailsHandler; +import org.sonar.api.server.ws.WebService; + +public class UserPropertiesWs implements WebService { + + @Override + public void define(Context context) { + NewController controller = context.createController("api/user_properties"); + controller.setDescription("User properties management"); + controller.setSince("2.6"); + + defineIndexAction(controller); + + controller.done(); + } + + private void defineIndexAction(NewController controller) { + controller.createAction("index") + .setDescription("Documentation of this web service is available here") + .setSince("2.6") + .setHandler(RailsHandler.INSTANCE); + } + +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/EventsWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/EventsWsTest.java new file mode 100644 index 00000000000..16fbad5bce7 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/EventsWsTest.java @@ -0,0 +1,40 @@ +/* + * 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.component.ws; + +import org.junit.Test; +import org.sonar.api.server.ws.WebService; +import org.sonar.server.ws.WsTester; + +import static org.fest.assertions.Assertions.assertThat; + +public class EventsWsTest { + + WsTester tester = new WsTester(new EventsWs()); + + @Test + public void define_ws() throws Exception { + WebService.Controller controller = tester.controller("api/events"); + assertThat(controller).isNotNull(); + assertThat(controller.description()).isNotEmpty(); + assertThat(controller.actions()).hasSize(1); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/config/ws/PropertiesWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/config/ws/PropertiesWsTest.java new file mode 100644 index 00000000000..ec6ed930d71 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/config/ws/PropertiesWsTest.java @@ -0,0 +1,41 @@ +/* + * 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.config.ws; + +import org.junit.Test; +import org.sonar.api.server.ws.WebService; +import org.sonar.server.ws.WsTester; + +import static org.fest.assertions.Assertions.assertThat; + +public class PropertiesWsTest { + + WsTester tester = new WsTester(new PropertiesWs()); + + @Test + public void define_ws() throws Exception { + WebService.Controller controller = tester.controller("api/properties"); + assertThat(controller).isNotNull(); + assertThat(controller.description()).isNotEmpty(); + assertThat(controller.actions()).hasSize(1); + } + +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ManualMeasuresWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ManualMeasuresWsTest.java new file mode 100644 index 00000000000..aafaab973b6 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ManualMeasuresWsTest.java @@ -0,0 +1,41 @@ +/* + * 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.measure.ws; + +import org.junit.Test; +import org.sonar.api.server.ws.WebService; +import org.sonar.server.ws.WsTester; + +import static org.fest.assertions.Assertions.assertThat; + +public class ManualMeasuresWsTest { + + WsTester tester = new WsTester(new ManualMeasuresWs()); + + @Test + public void define_ws() throws Exception { + WebService.Controller controller = tester.controller("api/manual_measures"); + assertThat(controller).isNotNull(); + assertThat(controller.description()).isNotEmpty(); + assertThat(controller.actions()).hasSize(1); + } + +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/MetricsWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/MetricsWsTest.java new file mode 100644 index 00000000000..e5005ad332d --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/MetricsWsTest.java @@ -0,0 +1,41 @@ +/* + * 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.measure.ws; + +import org.junit.Test; +import org.sonar.api.server.ws.WebService; +import org.sonar.server.ws.WsTester; + +import static org.fest.assertions.Assertions.assertThat; + +public class MetricsWsTest { + + WsTester tester = new WsTester(new MetricsWs()); + + @Test + public void define_ws() throws Exception { + WebService.Controller controller = tester.controller("api/metrics"); + assertThat(controller).isNotNull(); + assertThat(controller.description()).isNotEmpty(); + assertThat(controller.actions()).hasSize(1); + } + +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/FavoritesWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/FavoritesWsTest.java new file mode 100644 index 00000000000..184414f8a39 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/FavoritesWsTest.java @@ -0,0 +1,40 @@ +/* + * 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.user.ws; + +import org.junit.Test; +import org.sonar.api.server.ws.WebService; +import org.sonar.server.ws.WsTester; + +import static org.fest.assertions.Assertions.assertThat; + +public class FavoritesWsTest { + + WsTester tester = new WsTester(new FavoritesWs()); + + @Test + public void define_ws() throws Exception { + WebService.Controller controller = tester.controller("api/favorites"); + assertThat(controller).isNotNull(); + assertThat(controller.description()).isNotEmpty(); + assertThat(controller.actions()).hasSize(1); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/UserPropertiesWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/UserPropertiesWsTest.java new file mode 100644 index 00000000000..bbedb353032 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/UserPropertiesWsTest.java @@ -0,0 +1,41 @@ +/* + * 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.user.ws; + +import org.junit.Test; +import org.sonar.api.server.ws.WebService; +import org.sonar.server.ws.WsTester; + +import static org.fest.assertions.Assertions.assertThat; + +public class UserPropertiesWsTest { + + WsTester tester = new WsTester(new UserPropertiesWs()); + + @Test + public void define_ws() throws Exception { + WebService.Controller controller = tester.controller("api/user_properties"); + assertThat(controller).isNotNull(); + assertThat(controller.description()).isNotEmpty(); + assertThat(controller.actions()).hasSize(1); + } + +} -- 2.39.5