use of org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures in project sonarqube by SonarSource.
the class ProjectMeasuresIndexerIteratorTest method does_not_return_none_numeric_metrics.
@Test
public void does_not_return_none_numeric_metrics() {
ComponentDto project = dbTester.components().insertPrivateProject();
MetricDto dataMetric = dbTester.measures().insertMetric(m -> m.setValueType(DATA.name()).setKey("data"));
MetricDto distribMetric = dbTester.measures().insertMetric(m -> m.setValueType(DISTRIB.name()).setKey("distrib"));
MetricDto stringMetric = dbTester.measures().insertMetric(m -> m.setValueType(STRING.name()).setKey("string"));
dbTester.measures().insertLiveMeasure(project, dataMetric, m -> m.setData("dat"));
dbTester.measures().insertLiveMeasure(project, distribMetric, m -> m.setData("dis"));
dbTester.measures().insertLiveMeasure(project, stringMetric, m -> m.setData("str"));
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById();
assertThat(docsById.get(project.uuid()).getMeasures().getNumericMeasures()).isEmpty();
}
use of org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures in project sonarqube by SonarSource.
the class ProjectMeasuresIndexerIteratorTest method non_main_branches_are_not_indexed.
@Test
public void non_main_branches_are_not_indexed() {
ComponentDto project = dbTester.components().insertPrivateProject();
MetricDto metric = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("ncloc"));
dbTester.measures().insertLiveMeasure(project, metric, m -> m.setValue(10d));
ComponentDto branch = dbTester.components().insertProjectBranch(project, b -> b.setKey("feature/foo"));
dbTester.measures().insertLiveMeasure(branch, metric, m -> m.setValue(20d));
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById();
assertThat(docsById).hasSize(1).containsOnlyKeys(project.uuid());
assertThat(docsById.get(project.uuid()).getMeasures().getNumericMeasures().get(metric.getKey())).isEqualTo(10d);
}
use of org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures in project sonarqube by SonarSource.
the class ProjectMeasuresIndexer method doIndex.
private void doIndex(Size size, @Nullable String projectUuid) {
try (DbSession dbSession = dbClient.openSession(false);
ProjectMeasuresIndexerIterator rowIt = ProjectMeasuresIndexerIterator.create(dbSession, projectUuid)) {
BulkIndexer bulkIndexer = createBulkIndexer(size, IndexingListener.FAIL_ON_ERROR);
bulkIndexer.start();
while (rowIt.hasNext()) {
ProjectMeasures doc = rowIt.next();
bulkIndexer.add(toProjectMeasuresDoc(doc).toIndexRequest());
}
bulkIndexer.stop();
}
}
use of org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures in project sonarqube by SonarSource.
the class ProjectMeasuresIndexer method doIndex.
private static void doIndex(BulkIndexer bulk, Iterator<ProjectMeasures> docs) {
bulk.start();
while (docs.hasNext()) {
ProjectMeasures doc = docs.next();
bulk.add(newIndexRequest(toProjectMeasuresDoc(doc)));
}
bulk.stop();
}
Aggregations