Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONAR-8222 Update project measures index at the end of each project a…
…nalysis
- Loading branch information
1 parent
5ce0d72
commit 2bf5b53
Showing
10 changed files
with
205 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...java/org/sonar/server/computation/task/projectanalysis/step/IndexProjectMeasuresStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* SonarQube | ||
* Copyright (C) 2009-2016 SonarSource SA | ||
* mailto:contact AT sonarsource DOT com | ||
* | ||
* This program 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. | ||
* | ||
* This program 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.task.projectanalysis.step; | ||
|
||
import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolder; | ||
import org.sonar.server.computation.task.step.ComputationStep; | ||
import org.sonar.server.project.es.ProjectMeasuresIndexer; | ||
|
||
public class IndexProjectMeasuresStep implements ComputationStep { | ||
|
||
private final ProjectMeasuresIndexer indexer; | ||
private final TreeRootHolder treeRootHolder; | ||
|
||
public IndexProjectMeasuresStep(ProjectMeasuresIndexer indexer, TreeRootHolder treeRootHolder) { | ||
this.indexer = indexer; | ||
this.treeRootHolder = treeRootHolder; | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
indexer.index(treeRootHolder.getRoot().getUuid()); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Index project measures"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
.../org/sonar/server/computation/task/projectanalysis/step/IndexProjectMeasuresStepTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* SonarQube | ||
* Copyright (C) 2009-2016 SonarSource SA | ||
* mailto:contact AT sonarsource DOT com | ||
* | ||
* This program 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. | ||
* | ||
* This program 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.task.projectanalysis.step; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule; | ||
import org.sonar.server.project.es.ProjectMeasuresIndexer; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.PROJECT; | ||
import static org.sonar.server.computation.task.projectanalysis.component.ReportComponent.builder; | ||
|
||
public class IndexProjectMeasuresStepTest { | ||
|
||
static String PROJECT_UUID = "PROJECT_UUID"; | ||
|
||
@Rule | ||
public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule() | ||
.setRoot(builder(PROJECT, 1).setUuid(PROJECT_UUID).setKey("PROJECT_KEY").build()); | ||
|
||
@Test | ||
public void call_indexer() { | ||
ProjectMeasuresIndexer indexer = mock(ProjectMeasuresIndexer.class); | ||
IndexProjectMeasuresStep underTest = new IndexProjectMeasuresStep(indexer, treeRootHolder); | ||
|
||
underTest.execute(); | ||
|
||
verify(indexer).index(PROJECT_UUID); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters