use of org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures in project sonarqube by SonarSource.
the class ProjectMeasuresIndexerIteratorTest method does_not_fail_when_quality_gate_has_no_value.
@Test
public void does_not_fail_when_quality_gate_has_no_value() throws Exception {
MetricDto metric = insertMetric("alert_status", LEVEL);
insertProjectAndMeasure("project", metric, null);
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById();
assertThat(docsById.get("project").getMeasures().getNumericMeasures()).isEmpty();
}
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() throws Exception {
MetricDto dataMetric = insertMetric("data", DATA);
MetricDto distribMetric = insertMetric("distrib", DISTRIB);
MetricDto stringMetric = insertMetric("string", STRING);
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization());
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
insertMeasure(project, analysis, dataMetric, "dat");
insertMeasure(project, analysis, distribMetric, "dis");
insertMeasure(project, analysis, stringMetric, "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 return_project_measure.
@Test
public void return_project_measure() {
MetricDto metric1 = insertIntMetric("ncloc");
MetricDto metric2 = insertIntMetric("coverage");
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization()).setKey("Project-Key").setName("Project Name").setTagsString("platform,java");
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
insertMeasure(project, analysis, metric1, 10d);
insertMeasure(project, analysis, metric2, 20d);
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById();
assertThat(docsById).hasSize(1);
ProjectMeasures doc = docsById.get(project.uuid());
assertThat(doc).isNotNull();
assertThat(doc.getProject().getUuid()).isEqualTo(project.uuid());
assertThat(doc.getProject().getKey()).isEqualTo("Project-Key");
assertThat(doc.getProject().getName()).isEqualTo("Project Name");
assertThat(doc.getProject().getTags()).containsExactly("platform", "java");
assertThat(doc.getProject().getAnalysisDate()).isNotNull().isEqualTo(analysis.getCreatedAt());
assertThat(doc.getMeasures().getNumericMeasures()).containsOnly(entry("ncloc", 10d), entry("coverage", 20d));
}
use of org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures in project sonarqube by SonarSource.
the class ProjectMeasuresIndexerIteratorTest method return_only_docs_from_given_project.
@Test
public void return_only_docs_from_given_project() throws Exception {
OrganizationDto organizationDto = dbTester.organizations().insert();
ComponentDto project = newProjectDto(organizationDto);
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
dbTester.components().insertProjectAndSnapshot(newProjectDto(organizationDto));
dbTester.components().insertProjectAndSnapshot(newProjectDto(organizationDto));
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById(project.uuid());
assertThat(docsById).hasSize(1);
ProjectMeasures doc = docsById.get(project.uuid());
assertThat(doc).isNotNull();
assertThat(doc.getProject().getUuid()).isEqualTo(project.uuid());
assertThat(doc.getProject().getKey()).isNotNull().isEqualTo(project.getKey());
assertThat(doc.getProject().getName()).isNotNull().isEqualTo(project.name());
assertThat(doc.getProject().getAnalysisDate()).isNotNull().isEqualTo(analysis.getCreatedAt());
}
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