]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5795 Move project indexation post job on server side
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Fri, 31 Oct 2014 09:54:32 +0000 (10:54 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Fri, 31 Oct 2014 12:53:23 +0000 (13:53 +0100)
17 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/batch/IndexProjectPostJob.java [deleted file]
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/batch/package-info.java [deleted file]
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/batch/IndexProjectPostJobTest.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/computation/ComputationService.java
server/sonar-server/src/main/java/org/sonar/server/computation/ComputationStep.java
server/sonar-server/src/main/java/org/sonar/server/computation/ComputationStepRegistry.java
server/sonar-server/src/main/java/org/sonar/server/computation/DataCleanerStep.java
server/sonar-server/src/main/java/org/sonar/server/computation/IndexProjectIssuesStep.java
server/sonar-server/src/main/java/org/sonar/server/computation/InvalidatePreviewCacheStep.java
server/sonar-server/src/main/java/org/sonar/server/computation/ProjectDatabaseIndexationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/computation/SwitchSnapshotStep.java
server/sonar-server/src/main/java/org/sonar/server/computation/SynchronizeProjectPermissionsStep.java
server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
server/sonar-server/src/test/java/org/sonar/server/computation/ComputationStepRegistryMediumTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/computation/ComputationStepRegistryTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/computation/ProjectDatabaseIndexationStepTest.java [new file with mode: 0644]

index e1965074eb82c0afe396f4b426d8d905e6823d17..0fddfec945613132fa85a38e20d0fa50a6a77ecb 100644 (file)
@@ -23,7 +23,6 @@ import com.google.common.collect.ImmutableList;
 import org.sonar.api.*;
 import org.sonar.api.checks.NoSonarFilter;
 import org.sonar.core.timemachine.Periods;
-import org.sonar.plugins.core.batch.IndexProjectPostJob;
 import org.sonar.plugins.core.charts.DistributionAreaChart;
 import org.sonar.plugins.core.charts.DistributionBarChart;
 import org.sonar.plugins.core.colorizers.JavaColorizerFormat;
@@ -312,7 +311,6 @@ public final class CorePlugin extends SonarPlugin {
       NoSonarFilter.class,
       DirectoriesDecorator.class,
       FilesDecorator.class,
-      IndexProjectPostJob.class,
       ManualMeasureDecorator.class,
       FileHashSensor.class,
 
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/batch/IndexProjectPostJob.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/batch/IndexProjectPostJob.java
deleted file mode 100644 (file)
index c8f7320..0000000
+++ /dev/null
@@ -1,45 +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.plugins.core.batch;
-
-import org.sonar.core.DryRunIncompatible;
-import org.sonar.api.batch.PostJob;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.resources.Project;
-import org.sonar.core.resource.ResourceIndexerDao;
-
-/**
- * @since 2.13
- */
-@DryRunIncompatible
-public class IndexProjectPostJob implements PostJob {
-  private ResourceIndexerDao indexer;
-
-  public IndexProjectPostJob(ResourceIndexerDao indexer) {
-    this.indexer = indexer;
-  }
-
-  @Override
-  public void executeOn(Project project, SensorContext context) {
-    if (project.getId() != null) {
-      indexer.indexProject(project.getId());
-    }
-  }
-}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/batch/package-info.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/batch/package-info.java
deleted file mode 100644 (file)
index 53156e1..0000000
+++ /dev/null
@@ -1,26 +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.
- */
-/**
- * Deprecated in 4.5.1. JFreechart charts are replaced by Javascript charts.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.plugins.core.batch;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/batch/IndexProjectPostJobTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/batch/IndexProjectPostJobTest.java
deleted file mode 100644 (file)
index c63e890..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.plugins.core.batch;
-
-import org.junit.Test;
-import org.sonar.api.resources.Project;
-import org.sonar.core.resource.ResourceIndexerDao;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
-
-public class IndexProjectPostJobTest {
-  @Test
-  public void shouldIndexProject() {
-    ResourceIndexerDao indexer = mock(ResourceIndexerDao.class);
-    IndexProjectPostJob job = new IndexProjectPostJob(indexer);
-    Project project = new Project("foo");
-    project.setId(123);
-
-    job.executeOn(project, null);
-
-    verify(indexer).indexProject(123);
-  }
-
-  @Test
-  public void shouldNotIndexProjectIfMissingId() {
-    ResourceIndexerDao indexer = mock(ResourceIndexerDao.class);
-    IndexProjectPostJob job = new IndexProjectPostJob(indexer);
-
-    job.executeOn(new Project("foo"), null);
-
-    verifyZeroInteractions(indexer);
-  }
-
-}
index b49f2dce617721fc0a8cc692e0ae3f2094be424d..afb6b8542b609292097851195d014d5bca80252f 100644 (file)
@@ -65,7 +65,7 @@ public class ComputationService implements ServerComponent {
     try {
       report.succeed();
       for (ComputationStep step : stepRegistry.steps()) {
-        TimeProfiler stepProfiler = new TimeProfiler(LOG).start(step.description());
+        TimeProfiler stepProfiler = new TimeProfiler(LOG).start(step.getDescription());
         step.execute(session, report, project);
         session.commit();
         stepProfiler.stop();
index a451f09da94c18764358fe01cff779d31eefcac8..ed52abee335a16cc56fee695725af680acbafea1 100644 (file)
@@ -29,5 +29,5 @@ public interface ComputationStep extends ServerComponent {
 
   void execute(DbSession session, AnalysisReportDto analysisReportDto, ComponentDto project);
 
-  String description();
+  String getDescription();
 }
index 0e392ca2aadf0f318c03b33bee3beceed4854316..f5140b19d25342189a59a42ffb122b166d9361fe 100644 (file)
 package org.sonar.server.computation;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
 import org.sonar.api.ServerComponent;
+import org.sonar.api.platform.ComponentContainer;
 
 import java.util.List;
 
 public class ComputationStepRegistry implements ServerComponent {
 
-  private final List<ComputationStep> steps;
+  private final ComponentContainer pico;
+
+  public ComputationStepRegistry(ComponentContainer pico) {
+    this.pico = pico;
 
-  public ComputationStepRegistry(
-    SynchronizeProjectPermissionsStep synchronizeProjectPermissionsStep,
-    IndexProjectIssuesStep indexProjectIssuesStep,
-    SwitchSnapshotStep switchSnapshotStep,
-    DataCleanerStep dataCleanerStep,
-    InvalidatePreviewCacheStep invalidatePreviewCacheStep) {
-    steps = ImmutableList.of(synchronizeProjectPermissionsStep, switchSnapshotStep, invalidatePreviewCacheStep, dataCleanerStep, indexProjectIssuesStep);
   }
 
   public List<ComputationStep> steps() {
-    return steps;
+    List<ComputationStep> steps = Lists.newArrayList();
+    steps.add(pico.getComponentByType(SynchronizeProjectPermissionsStep.class));
+    steps.add(pico.getComponentByType(SwitchSnapshotStep.class));
+    steps.add(pico.getComponentByType(InvalidatePreviewCacheStep.class));
+    steps.add(pico.getComponentByType(DataCleanerStep.class));
+    steps.add(pico.getComponentByType(ProjectDatabaseIndexationStep.class));
+    steps.add(pico.getComponentByType(IndexProjectIssuesStep.class));
+
+    return ImmutableList.copyOf(steps);
   }
 }
index fcd0de2e2b49896e32ead6d58ef0a5da6349e065..8532f486ad1e316365843780a29b3c0e11eabc48 100644 (file)
@@ -53,7 +53,7 @@ public class DataCleanerStep implements ComputationStep {
   }
 
   @Override
-  public String description() {
+  public String getDescription() {
     return "Purge database";
   }
 }
index d84cff541ac42bd9a03bfba5fb0f5908145e3e03..34936e7febe3ef5c1c6e89deb0c892bf908b60a2 100644 (file)
@@ -47,7 +47,7 @@ public class IndexProjectIssuesStep implements ComputationStep {
   }
 
   @Override
-  public String description() {
+  public String getDescription() {
     return "Update issues index";
   }
 
index dcdf9c822d1608ab60d2fc8d0ee81faf583f2997..e71ee278627384f0668c4495a13076b89b5d78c0 100644 (file)
@@ -46,7 +46,7 @@ public class InvalidatePreviewCacheStep implements ComputationStep {
   }
 
   @Override
-  public String description() {
+  public String getDescription() {
     return "Invalidate preview cache";
   }
 }
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
new file mode 100644 (file)
index 0000000..7f2c5d3
--- /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 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 1fe6f0a29b9404a53264dbdbe7bdb3cf7c1ee487..c1109ed6310e4b6d0e5590ef7298d5c78acd2868 100644 (file)
@@ -43,7 +43,7 @@ public class SwitchSnapshotStep implements ComputationStep {
   }
 
   @Override
-  public String description() {
+  public String getDescription() {
     return "Switch last snapshot flag";
   }
 
index 7d388dd8e085351bb57ffea20af11e0dadb93ada..01815b0a8570efe821f79a9dba4b5adfb5b65df4 100644 (file)
@@ -47,7 +47,7 @@ public class SynchronizeProjectPermissionsStep implements ComputationStep {
   }
 
   @Override
-  public String description() {
+  public String getDescription() {
     return "Synchronize project permissions";
   }
 
index cefc8430479820bcbc6a0fc1ded1e6043cf8ea83..03132c8a74be7a8b792622f1435bdee3757e6d1f 100644 (file)
@@ -271,7 +271,7 @@ class ServerComponents {
       ActivityNormalizer.class,
       ActivityIndex.class,
       ActivityDao.class
-    ));
+      ));
     components.addAll(CorePropertyDefinitions.all());
     components.addAll(DatabaseMigrations.CLASSES);
     components.addAll(DaoUtils.getDaoClasses());
@@ -304,7 +304,7 @@ class ServerComponents {
       // ws
       RestartHandler.class,
       SystemWs.class
-    );
+      );
   }
 
   /**
@@ -321,7 +321,7 @@ class ServerComponents {
       HttpDownloader.class,
       UriReader.class,
       ServerIdGenerator.class
-    );
+      );
   }
 
   void startLevel4Components(ComponentContainer pico) {
@@ -598,6 +598,7 @@ class ServerComponents {
       IndexProjectIssuesStep.class,
       SwitchSnapshotStep.class,
       InvalidatePreviewCacheStep.class,
+      ProjectDatabaseIndexationStep.class,
       DataCleanerStep.class));
     pico.addSingleton(AnalysisReportQueue.class);
     pico.addSingleton(AnalysisReportTaskLauncher.class);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationStepRegistryMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationStepRegistryMediumTest.java
new file mode 100644 (file)
index 0000000..cdf5965
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * 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 com.google.common.collect.Lists;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonar.api.platform.ComponentContainer;
+import org.sonar.server.tester.ServerTester;
+
+import java.util.List;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+
+public class ComputationStepRegistryMediumTest {
+
+  @ClassRule
+  public static ServerTester tester = new ServerTester();
+
+  private ComputationStepRegistry sut;
+
+  @Before
+  public void before() {
+    ComponentContainer pico = new ComponentContainer();
+
+    pico.addSingleton(mock(SynchronizeProjectPermissionsStep.class));
+    pico.addSingleton(mock(IndexProjectIssuesStep.class));
+    pico.addSingleton(mock(SwitchSnapshotStep.class));
+    pico.addSingleton(mock(DataCleanerStep.class));
+    pico.addSingleton(mock(InvalidatePreviewCacheStep.class));
+    pico.addSingleton(mock(ProjectDatabaseIndexationStep.class));
+
+    sut = new ComputationStepRegistry(pico);
+  }
+
+  @Test
+  public void steps_returned_in_the_right_order() throws Exception {
+    List<Class<? extends ComputationStep>> wishStepsClasses = Lists.newArrayList(
+      SynchronizeProjectPermissionsStep.class,
+      SwitchSnapshotStep.class,
+      InvalidatePreviewCacheStep.class,
+      DataCleanerStep.class,
+      ProjectDatabaseIndexationStep.class,
+      IndexProjectIssuesStep.class
+      );
+    List<ComputationStep> steps = sut.steps();
+
+    assertThat(steps).hasSize(wishStepsClasses.size());
+    for (int i = 0; i < steps.size(); i++) {
+      assertThat(steps.get(i)).isInstanceOf(wishStepsClasses.get(i));
+    }
+  }
+
+  @Test
+  public void steps_have_a_non_empty_description() {
+    ComputationStepRegistry sut = tester.get(ComputationStepRegistry.class);
+
+    List<ComputationStep> steps = sut.steps();
+
+    assertThat(steps).onProperty("description").excludes(null, "");
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationStepRegistryTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationStepRegistryTest.java
deleted file mode 100644 (file)
index b47cdcf..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 static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-
-public class ComputationStepRegistryTest {
-
-  private ComputationStepRegistry sut;
-  private SynchronizeProjectPermissionsStep synchronizeProjectPermissionsStep;
-  private IndexProjectIssuesStep indexProjectIssuesStep;
-  private SwitchSnapshotStep switchSnapshotStep;
-  private DataCleanerStep dataCleanerStep;
-  private InvalidatePreviewCacheStep invalidatePreviewCacheStep;
-
-  @Before
-  public void before() {
-    synchronizeProjectPermissionsStep = mock(SynchronizeProjectPermissionsStep.class);
-    indexProjectIssuesStep = mock(IndexProjectIssuesStep.class);
-    switchSnapshotStep = mock(SwitchSnapshotStep.class);
-    dataCleanerStep = mock(DataCleanerStep.class);
-    invalidatePreviewCacheStep = mock(InvalidatePreviewCacheStep.class);
-
-    sut = new ComputationStepRegistry(synchronizeProjectPermissionsStep, indexProjectIssuesStep, switchSnapshotStep, dataCleanerStep, invalidatePreviewCacheStep);
-  }
-
-  @Test
-  public void steps_returned_in_the_right_order() throws Exception {
-    assertThat(sut.steps()).containsExactly(synchronizeProjectPermissionsStep, switchSnapshotStep, invalidatePreviewCacheStep, dataCleanerStep, indexProjectIssuesStep);
-  }
-}
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
new file mode 100644 (file)
index 0000000..fdc9a57
--- /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 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);
+  }
+
+}