From 1401fcc1796c9adef599cc3d0bc77d87b78834ec Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Tue, 2 Jun 2015 14:14:25 +0200 Subject: [PATCH] add MetricsWsModule --- .../server/metric/ws/MetricsWsModule.java | 36 +++++++++++++++++++ .../platformlevel/PlatformLevel4.java | 10 ++---- .../server/metric/ws/MetricsWsModuleTest.java | 35 ++++++++++++++++++ 3 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 server/sonar-server/src/main/java/org/sonar/server/metric/ws/MetricsWsModule.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/metric/ws/MetricsWsModuleTest.java diff --git a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/MetricsWsModule.java b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/MetricsWsModule.java new file mode 100644 index 00000000000..4ac2423a008 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/MetricsWsModule.java @@ -0,0 +1,36 @@ +/* + * 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.metric.ws; + +import org.sonar.core.component.Module; + +public class MetricsWsModule extends Module { + @Override + protected void configureModule() { + add( + MetricsWs.class, + CreateAction.class, + DeleteAction.class, + DomainsAction.class, + SearchAction.class, + TypesAction.class); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index 73972ef1ed7..c8b5f739899 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -169,8 +169,7 @@ import org.sonar.server.measure.template.ProjectFilter; import org.sonar.server.measure.ws.ManualMeasuresWs; import org.sonar.server.measure.ws.TimeMachineWs; import org.sonar.server.metric.CoreCustomMetrics; -import org.sonar.server.metric.ws.MetricsWs; -import org.sonar.server.metric.ws.SearchAction; +import org.sonar.server.metric.ws.MetricsWsModule; import org.sonar.server.notifications.NotificationCenter; import org.sonar.server.notifications.NotificationService; import org.sonar.server.permission.InternalPermissionService; @@ -494,13 +493,8 @@ public class PlatformLevel4 extends PlatformLevel { DefaultMetricFinder.class, TimeMachineWs.class, ManualMeasuresWs.class, - MetricsWs.class, - SearchAction.class, - org.sonar.server.metric.ws.TypesAction.class, - org.sonar.server.metric.ws.DomainsAction.class, - org.sonar.server.metric.ws.DeleteAction.class, - org.sonar.server.metric.ws.CreateAction.class, + MetricsWsModule.class, // quality gates QualityGateDao.class, diff --git a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/MetricsWsModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/MetricsWsModuleTest.java new file mode 100644 index 00000000000..fba94669370 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/MetricsWsModuleTest.java @@ -0,0 +1,35 @@ +/* + * 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.metric.ws; + +import org.junit.Test; +import org.sonar.core.platform.ComponentContainer; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MetricsWsModuleTest { + @Test + public void verify_count_of_added_components() { + ComponentContainer container = new ComponentContainer(); + new MetricsWsModule().configure(container); + assertThat(container.size()).isEqualTo(8); + } +} -- 2.39.5