use of org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures in project sonarqube by SonarSource.
the class ProjectMeasuresIndexerIteratorTest method return_project_without_analysis.
@Test
public void return_project_without_analysis() {
ComponentDto project = dbTester.components().insertPrivateProject();
dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setLast(false));
dbSession.commit();
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById();
assertThat(docsById).hasSize(1);
ProjectMeasures doc = docsById.get(project.uuid());
assertThat(doc.getProject().getAnalysisDate()).isNull();
}
use of org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures in project sonarqube by SonarSource.
the class ProjectMeasuresIndexerIteratorTest method return_nothing_on_unknown_project.
@Test
public void return_nothing_on_unknown_project() {
ComponentDto project = dbTester.components().insertPrivateProject();
dbTester.components().insertSnapshot(project);
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById("UNKNOWN");
assertThat(docsById).isEmpty();
}
use of org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures in project sonarqube by SonarSource.
the class ProjectMeasuresIndexerIteratorTest method return_project_measure_having_leak.
@Test
public void return_project_measure_having_leak() {
ComponentDto project = dbTester.components().insertPrivateProject(c -> c.setDbKey("Project-Key").setName("Project Name"), p -> p.setTagsString("platform,java"));
MetricDto metric = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("new_lines"));
dbTester.measures().insertLiveMeasure(project, metric, m -> m.setVariation(10d));
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById();
assertThat(docsById.get(project.uuid()).getMeasures().getNumericMeasures()).containsOnly(entry("new_lines", 10d));
}
use of org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures in project sonarqube by SonarSource.
the class ProjectMeasuresIndexerIteratorTest method return_application_measure.
@Test
public void return_application_measure() {
ComponentDto project = dbTester.components().insertPrivateApplication(c -> c.setDbKey("App-Key").setName("App Name"));
SnapshotDto analysis = dbTester.components().insertSnapshot(project);
MetricDto metric1 = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("ncloc"));
MetricDto metric2 = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("coverage"));
dbTester.measures().insertLiveMeasure(project, metric1, m -> m.setValue(10d));
dbTester.measures().insertLiveMeasure(project, metric2, m -> m.setValue(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("App-Key");
assertThat(doc.getProject().getName()).isEqualTo("App Name");
assertThat(doc.getProject().getAnalysisDate()).isNotNull().isEqualTo(analysis.getCreatedAt());
assertThat(doc.getMeasures().getNumericMeasures()).containsOnly(entry(metric1.getKey(), 10d), entry(metric2.getKey(), 20d));
}
use of org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures in project sonarqube by SonarSource.
the class ProjectMeasuresIndexerIteratorTest method return_language_distribution_measure.
@Test
public void return_language_distribution_measure() {
ComponentDto project = dbTester.components().insertPrivateProject();
MetricDto metric = dbTester.measures().insertMetric(m -> m.setValueType(DATA.name()).setKey("ncloc_language_distribution"));
dbTester.measures().insertLiveMeasure(project, metric, m -> m.setValue(null).setData("<null>=2;java=6;xoo=18"));
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById();
assertThat(docsById.get(project.uuid()).getMeasures().getNclocByLanguages()).containsOnly(entry("<null>", 2), entry("java", 6), entry("xoo", 18));
}
Aggregations