]> source.dussan.org Git - sonarqube.git/commitdiff
add module for Batch WS
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 13 May 2015 11:52:21 +0000 (13:52 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 27 May 2015 10:16:02 +0000 (12:16 +0200)
server/sonar-server/src/main/java/org/sonar/server/batch/BatchWsModule.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsModuleTest.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/component/Module.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 (file)
index 0000000..ebc0445
--- /dev/null
@@ -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);
+  }
+}
index 5fee29e8167a6ff35874e0092848ccab369baed3..e98c4798ac3e92b4d3bdfff9304d6c5ed0218606 100644 (file)
@@ -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 (file)
index 0000000..6c992f9
--- /dev/null
@@ -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);
+  }
+
+}
index 6662ebdd24c3d3dca438fff28e1b624f44039def..25a015e55e6d95130e1d0c8aa8e2db2e8bc6b1b4 100644 (file)
@@ -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> T getComponentByType(Class<T> 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()]));
-  }
-
 }