diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2015-09-15 14:23:40 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-09-16 11:00:08 +0200 |
commit | 469890daa18e3a106cd211a32b0c3274422297a5 (patch) | |
tree | 17ffe739e7342b9ba75e3c03bad01475a3ba2d3f /server | |
parent | 5fbc4e133ece92f997e6dbe139c6524f7f109cbf (diff) | |
download | sonarqube-469890daa18e3a106cd211a32b0c3274422297a5.tar.gz sonarqube-469890daa18e3a106cd211a32b0c3274422297a5.zip |
VIEWS-323 make IndexComponentsStepTest support indexing a View
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-server/src/test/java/org/sonar/server/computation/step/IndexComponentsStepTest.java | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/IndexComponentsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/IndexComponentsStepTest.java index 4da0ef5d678..923d19bdb20 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/IndexComponentsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/IndexComponentsStepTest.java @@ -26,11 +26,14 @@ import org.sonar.db.component.ResourceIndexDao; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; -import org.sonar.server.computation.component.DbIdsRepositoryImpl; +import org.sonar.server.computation.component.MutableDbIdsRepositoryRule; import org.sonar.server.computation.component.ReportComponent; +import org.sonar.server.computation.component.ViewsComponent; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import static org.sonar.server.computation.component.Component.Type.PROJECT; +import static org.sonar.server.computation.component.Component.Type.VIEW; public class IndexComponentsStepTest extends BaseStepTest { @@ -38,17 +41,17 @@ public class IndexComponentsStepTest extends BaseStepTest { @Rule public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule(); - @Rule public BatchReportReaderRule reportReader = new BatchReportReaderRule(); + @Rule + public MutableDbIdsRepositoryRule dbIdsRepository = MutableDbIdsRepositoryRule.create(treeRootHolder); ResourceIndexDao resourceIndexDao = mock(ResourceIndexDao.class); - DbIdsRepositoryImpl dbIdsRepository = new DbIdsRepositoryImpl(); IndexComponentsStep underTest = new IndexComponentsStep(resourceIndexDao, dbIdsRepository, treeRootHolder); @Test - public void call_indexProject_of_dao() { - Component project = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("PROJECT_UUID").setKey(PROJECT_KEY).build(); + public void call_indexProject_of_dao_for_project() { + Component project = ReportComponent.builder(PROJECT, 1).setUuid("PROJECT_UUID").setKey(PROJECT_KEY).build(); dbIdsRepository.setComponentId(project, 123L); treeRootHolder.setRoot(project); @@ -57,6 +60,17 @@ public class IndexComponentsStepTest extends BaseStepTest { verify(resourceIndexDao).indexProject(123L); } + @Test + public void call_indexProject_of_dao_for_view() { + Component view = ViewsComponent.builder(VIEW, PROJECT_KEY).setUuid("PROJECT_UUID").build(); + dbIdsRepository.setComponentId(view, 123L); + treeRootHolder.setRoot(view); + + underTest.execute(); + + verify(resourceIndexDao).indexProject(123L); + } + @Override protected ComputationStep step() { return underTest; |