use of org.sonar.db.qualitygate.QualityGateConditionDto in project sonarqube by SonarSource.
the class QualityGateConditionsUpdaterTest method verifyCondition.
private void verifyCondition(QualityGateConditionDto dto, int metricId, String operator, @Nullable String warning, @Nullable String error, @Nullable Integer period) {
QualityGateConditionDto reloaded = dbClient.gateConditionDao().selectById(dto.getId(), dbSession);
assertThat(reloaded.getQualityGateId()).isEqualTo(qualityGateDto.getId());
assertThat(reloaded.getMetricId()).isEqualTo(metricId);
assertThat(reloaded.getOperator()).isEqualTo(operator);
assertThat(reloaded.getWarningThreshold()).isEqualTo(warning);
assertThat(reloaded.getErrorThreshold()).isEqualTo(error);
assertThat(reloaded.getPeriod()).isEqualTo(period);
assertThat(dto.getQualityGateId()).isEqualTo(qualityGateDto.getId());
assertThat(dto.getMetricId()).isEqualTo(metricId);
assertThat(dto.getOperator()).isEqualTo(operator);
assertThat(dto.getWarningThreshold()).isEqualTo(warning);
assertThat(dto.getErrorThreshold()).isEqualTo(error);
assertThat(dto.getPeriod()).isEqualTo(period);
}
use of org.sonar.db.qualitygate.QualityGateConditionDto in project sonarqube by SonarSource.
the class QualityGateConditionsUpdaterTest method fail_to_update_condition_on_rating_metric_on_not_core_rating_metric.
@Test
public void fail_to_update_condition_on_rating_metric_on_not_core_rating_metric() {
MetricDto metricDto = dbClient.metricDao().insert(dbSession, newMetricDto().setKey("rating_metric").setShortName("Not core rating").setValueType(RATING.name()).setHidden(false));
QualityGateConditionDto condition = insertCondition(metricDto.getId(), "LT", null, "3", null);
dbSession.commit();
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("The metric 'Not core rating' cannot be used");
underTest.updateCondition(dbSession, condition.getId(), metricDto.getKey(), "GT", "4", null, 1);
}
use of org.sonar.db.qualitygate.QualityGateConditionDto in project sonarqube by SonarSource.
the class QualityGateConditionsUpdaterTest method update_condition.
@Test
public void update_condition() {
QualityGateConditionDto condition = insertCondition(coverageMetricDto.getId(), "LT", null, "80", null);
QualityGateConditionDto result = underTest.updateCondition(dbSession, condition.getId(), "coverage", "GT", "60", null, 1);
verifyCondition(result, coverageMetricDto.getId(), "GT", "60", null, 1);
}
Aggregations