]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5795 Component indexation right before the data cleaner step
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Fri, 31 Oct 2014 14:21:44 +0000 (15:21 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Fri, 31 Oct 2014 14:22:09 +0000 (15:22 +0100)
server/sonar-server/src/main/java/org/sonar/server/computation/ComponentIndexationInDatabaseStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/computation/ComputationStepRegistry.java
server/sonar-server/src/main/java/org/sonar/server/computation/ProjectDatabaseIndexationStep.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
server/sonar-server/src/test/java/org/sonar/server/computation/ComponentIndexationInDatabaseStepTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/computation/ComputationStepRegistryMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/ProjectDatabaseIndexationStepTest.java [deleted file]

diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ComponentIndexationInDatabaseStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ComponentIndexationInDatabaseStep.java
new file mode 100644 (file)
index 0000000..490dbf7
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.computation;
+
+import org.sonar.core.component.ComponentDto;
+import org.sonar.core.computation.db.AnalysisReportDto;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.resource.ResourceIndexerDao;
+
+public class ComponentIndexationInDatabaseStep implements ComputationStep {
+  private final ResourceIndexerDao resourceIndexerDao;
+
+  public ComponentIndexationInDatabaseStep(ResourceIndexerDao resourceIndexerDao) {
+    this.resourceIndexerDao = resourceIndexerDao;
+  }
+
+  @Override
+  public void execute(DbSession session, AnalysisReportDto analysisReportDto, ComponentDto project) {
+    resourceIndexerDao.indexProject(project.getId().intValue());
+  }
+
+  @Override
+  public String getDescription() {
+    return "Index project in database";
+  }
+}
index f5140b19d25342189a59a42ffb122b166d9361fe..00c4d9859546159d0e410a2f8e51f0ad28b55b48 100644 (file)
@@ -41,8 +41,8 @@ public class ComputationStepRegistry implements ServerComponent {
     steps.add(pico.getComponentByType(SynchronizeProjectPermissionsStep.class));
     steps.add(pico.getComponentByType(SwitchSnapshotStep.class));
     steps.add(pico.getComponentByType(InvalidatePreviewCacheStep.class));
+    steps.add(pico.getComponentByType(ComponentIndexationInDatabaseStep.class));
     steps.add(pico.getComponentByType(DataCleanerStep.class));
-    steps.add(pico.getComponentByType(ProjectDatabaseIndexationStep.class));
     steps.add(pico.getComponentByType(IndexProjectIssuesStep.class));
 
     return ImmutableList.copyOf(steps);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ProjectDatabaseIndexationStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ProjectDatabaseIndexationStep.java
deleted file mode 100644 (file)
index 7f2c5d3..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.computation;
-
-import org.sonar.core.component.ComponentDto;
-import org.sonar.core.computation.db.AnalysisReportDto;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.resource.ResourceIndexerDao;
-
-public class ProjectDatabaseIndexationStep implements ComputationStep {
-  private final ResourceIndexerDao resourceIndexerDao;
-
-  public ProjectDatabaseIndexationStep(ResourceIndexerDao resourceIndexerDao) {
-    this.resourceIndexerDao = resourceIndexerDao;
-  }
-
-  @Override
-  public void execute(DbSession session, AnalysisReportDto analysisReportDto, ComponentDto project) {
-    resourceIndexerDao.indexProject(project.getId().intValue());
-  }
-
-  @Override
-  public String getDescription() {
-    return "Index project in database";
-  }
-}
index 03132c8a74be7a8b792622f1435bdee3757e6d1f..acca81fec93440b95ca6afcada1333fd5fab8133 100644 (file)
@@ -598,7 +598,7 @@ class ServerComponents {
       IndexProjectIssuesStep.class,
       SwitchSnapshotStep.class,
       InvalidatePreviewCacheStep.class,
-      ProjectDatabaseIndexationStep.class,
+      ComponentIndexationInDatabaseStep.class,
       DataCleanerStep.class));
     pico.addSingleton(AnalysisReportQueue.class);
     pico.addSingleton(AnalysisReportTaskLauncher.class);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ComponentIndexationInDatabaseStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ComponentIndexationInDatabaseStepTest.java
new file mode 100644 (file)
index 0000000..ef5167d
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.computation;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.core.component.ComponentDto;
+import org.sonar.core.computation.db.AnalysisReportDto;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.resource.ResourceIndexerDao;
+
+import static org.mockito.Mockito.*;
+
+public class ComponentIndexationInDatabaseStepTest {
+
+  private ComponentIndexationInDatabaseStep sut;
+  private ResourceIndexerDao resourceIndexerDao;
+
+  @Before
+  public void before() {
+    this.resourceIndexerDao = mock(ResourceIndexerDao.class);
+    this.sut = new ComponentIndexationInDatabaseStep(resourceIndexerDao);
+  }
+
+  @Test
+  public void call_indexProject_of_dao() {
+    ComponentDto project = mock(ComponentDto.class);
+    when(project.getId()).thenReturn(123L);
+
+    sut.execute(mock(DbSession.class), mock(AnalysisReportDto.class), project);
+
+    verify(resourceIndexerDao).indexProject(123);
+  }
+
+}
index cdf59656cc9bce830bd36f48d8b5cfeb657ed6ab..e059c099fbf3a0abf925fa5dba9df274c8465e78 100644 (file)
@@ -48,7 +48,7 @@ public class ComputationStepRegistryMediumTest {
     pico.addSingleton(mock(SwitchSnapshotStep.class));
     pico.addSingleton(mock(DataCleanerStep.class));
     pico.addSingleton(mock(InvalidatePreviewCacheStep.class));
-    pico.addSingleton(mock(ProjectDatabaseIndexationStep.class));
+    pico.addSingleton(mock(ComponentIndexationInDatabaseStep.class));
 
     sut = new ComputationStepRegistry(pico);
   }
@@ -59,8 +59,8 @@ public class ComputationStepRegistryMediumTest {
       SynchronizeProjectPermissionsStep.class,
       SwitchSnapshotStep.class,
       InvalidatePreviewCacheStep.class,
+      ComponentIndexationInDatabaseStep.class,
       DataCleanerStep.class,
-      ProjectDatabaseIndexationStep.class,
       IndexProjectIssuesStep.class
       );
     List<ComputationStep> steps = sut.steps();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ProjectDatabaseIndexationStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ProjectDatabaseIndexationStepTest.java
deleted file mode 100644 (file)
index fdc9a57..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.computation;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.core.component.ComponentDto;
-import org.sonar.core.computation.db.AnalysisReportDto;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.resource.ResourceIndexerDao;
-
-import static org.mockito.Mockito.*;
-
-public class ProjectDatabaseIndexationStepTest {
-
-  private ProjectDatabaseIndexationStep sut;
-  private ResourceIndexerDao resourceIndexerDao;
-
-  @Before
-  public void before() {
-    this.resourceIndexerDao = mock(ResourceIndexerDao.class);
-    this.sut = new ProjectDatabaseIndexationStep(resourceIndexerDao);
-  }
-
-  @Test
-  public void call_indexProject_of_dao() {
-    ComponentDto project = mock(ComponentDto.class);
-    when(project.getId()).thenReturn(123L);
-
-    sut.execute(mock(DbSession.class), mock(AnalysisReportDto.class), project);
-
-    verify(resourceIndexerDao).indexProject(123);
-  }
-
-}