From b1ebe7217250cb9f4fc767b0df9f8d626c14f513 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Wed, 13 May 2015 13:52:21 +0200 Subject: [PATCH] add module for Batch WS --- .../org/sonar/server/batch/BatchWsModule.java | 38 +++++++++++++++++++ .../platformlevel/PlatformLevel4.java | 18 +-------- .../sonar/server/batch/BatchWsModuleTest.java | 35 +++++++++++++++++ .../java/org/sonar/core/component/Module.java | 12 ------ 4 files changed, 75 insertions(+), 28 deletions(-) create mode 100644 server/sonar-server/src/main/java/org/sonar/server/batch/BatchWsModule.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsModuleTest.java diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/BatchWsModule.java b/server/sonar-server/src/main/java/org/sonar/server/batch/BatchWsModule.java new file mode 100644 index 00000000000..ebc0445137c --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/BatchWsModule.java @@ -0,0 +1,38 @@ +/* + * 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.batch; + +import org.sonar.core.component.Module; +import org.sonar.server.computation.ws.SubmitReportAction; + +public class BatchWsModule extends Module { + @Override + protected void configureModule() { + add( + BatchIndex.class, + GlobalAction.class, + ProjectAction.class, + ProjectRepositoryLoader.class, + SubmitReportAction.class, + IssuesAction.class, + UsersAction.class, + BatchWs.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 5fee29e8167..e98c4798ac3 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 @@ -56,13 +56,7 @@ import org.sonar.server.activity.index.ActivityIndexer; import org.sonar.server.activity.ws.ActivitiesWs; import org.sonar.server.activity.ws.ActivityMapping; import org.sonar.server.authentication.ws.AuthenticationWs; -import org.sonar.server.batch.BatchIndex; -import org.sonar.server.batch.BatchWs; -import org.sonar.server.batch.GlobalAction; -import org.sonar.server.batch.IssuesAction; -import org.sonar.server.batch.ProjectAction; -import org.sonar.server.batch.ProjectRepositoryLoader; -import org.sonar.server.batch.UsersAction; +import org.sonar.server.batch.BatchWsModule; import org.sonar.server.charts.ChartFactory; import org.sonar.server.component.ComponentCleanerService; import org.sonar.server.component.ComponentService; @@ -77,7 +71,6 @@ import org.sonar.server.computation.ws.ComputationWs; import org.sonar.server.computation.ws.HistoryAction; import org.sonar.server.computation.ws.IsQueueEmptyWs; import org.sonar.server.computation.ws.QueueAction; -import org.sonar.server.computation.ws.SubmitReportAction; import org.sonar.server.config.ws.PropertiesWs; import org.sonar.server.dashboard.ws.DashboardsWs; import org.sonar.server.debt.DebtCharacteristicsXMLImporter; @@ -323,14 +316,7 @@ public class PlatformLevel4 extends PlatformLevel { ActivityIndex.class, // batch - BatchIndex.class, - GlobalAction.class, - ProjectAction.class, - ProjectRepositoryLoader.class, - SubmitReportAction.class, - IssuesAction.class, - UsersAction.class, - BatchWs.class, + BatchWsModule.class, // Dashboard DashboardsWs.class, diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsModuleTest.java new file mode 100644 index 00000000000..6c992f9219b --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsModuleTest.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.batch; + +import org.junit.Test; +import org.sonar.core.platform.ComponentContainer; + +import static org.assertj.core.api.Assertions.assertThat; + +public class BatchWsModuleTest { + @Test + public void verify_count_of_added_components() throws Exception { + ComponentContainer container = new ComponentContainer(); + new BatchWsModule().configure(container); + assertThat(container.size()).isEqualTo(10); + } + +} diff --git a/sonar-core/src/main/java/org/sonar/core/component/Module.java b/sonar-core/src/main/java/org/sonar/core/component/Module.java index 6662ebdd24c..25a015e55e6 100644 --- a/sonar-core/src/main/java/org/sonar/core/component/Module.java +++ b/sonar-core/src/main/java/org/sonar/core/component/Module.java @@ -19,8 +19,6 @@ */ package org.sonar.core.component; -import java.util.Collection; -import javax.annotation.Nullable; import org.sonar.core.platform.ComponentContainer; import static com.google.common.base.Preconditions.checkNotNull; @@ -38,12 +36,6 @@ public abstract class Module { protected abstract void configureModule(); - protected void add(@Nullable Object object, boolean singleton) { - if (object != null) { - container.addComponent(object, singleton); - } - } - protected T getComponentByType(Class tClass) { return container.getComponentByType(tClass); } @@ -56,8 +48,4 @@ public abstract class Module { } } - protected void addAll(Collection objects) { - add(objects.toArray(new Object[objects.size()])); - } - } -- 2.39.5