use of org.sonar.server.qualitygate.changeevent.QGChangeEvent in project sonarqube by SonarSource.
the class LiveMeasureComputerImplTest method refresh_multiple_projects_at_the_same_time.
@Test
public void refresh_multiple_projects_at_the_same_time() {
markProjectAsAnalyzed(project);
ComponentDto project2 = db.components().insertPublicProject();
ComponentDto fileInProject2 = db.components().insertComponent(ComponentTesting.newFileDto(project2));
markProjectAsAnalyzed(project2);
List<QGChangeEvent> result = run(asList(file1, fileInProject2), newQualifierBasedIntFormula());
// generated values depend on position of qualifier in Qualifiers.ORDERED_BOTTOM_UP (see formula)
assertThatIntMeasureHasValue(file1, 0);
assertThatIntMeasureHasValue(dir, 2);
assertThatIntMeasureHasValue(project, 4);
assertThatIntMeasureHasValue(fileInProject2, 0);
assertThatIntMeasureHasValue(project2, 4);
// no other measures generated
assertThat(db.countRowsOfTable(db.getSession(), "live_measures")).isEqualTo(5);
assertThatProjectChanged(result, project, project2);
}
use of org.sonar.server.qualitygate.changeevent.QGChangeEvent in project sonarqube by SonarSource.
the class LiveMeasureComputerImplTest method event_contains_newQualityGate_computed_by_LiveQualityGateComputer.
@Test
public void event_contains_newQualityGate_computed_by_LiveQualityGateComputer() {
markProjectAsAnalyzed(project);
db.measures().insertLiveMeasure(project, alertStatusMetric, m -> m.setData(Metric.Level.ERROR.name()));
db.measures().insertLiveMeasure(project, intMetric, m -> m.setVariation(42.0).setValue(null));
BranchDto branch = db.getDbClient().branchDao().selectByBranchKey(db.getSession(), project.projectUuid(), "master").orElseThrow(() -> new IllegalStateException("Can't find master branch"));
List<QGChangeEvent> result = run(file1, newQualifierBasedIntLeakFormula());
assertThat(result).extracting(QGChangeEvent::getQualityGateSupplier).extracting(Supplier::get).containsExactly(Optional.of(newQualityGate));
verify(qGateComputer).loadQualityGate(any(DbSession.class), argThat(p -> p.getUuid().equals(projectDto.getUuid())), eq(branch));
verify(qGateComputer).getMetricsRelatedTo(qualityGate);
verify(qGateComputer).refreshGateStatus(eq(project), same(qualityGate), any(MeasureMatrix.class), any(Configuration.class));
}
Aggregations