use of org.sonar.db.qualitygate.QualityGateConditionDto in project sonarqube by SonarSource.
the class QualityGateConditionsUpdaterTest method fail_to_update_condition_when_condition_on_same_metric_already_exist.
@Test
public void fail_to_update_condition_when_condition_on_same_metric_already_exist() throws Exception {
QualityGateConditionDto conditionNotOnLeakPeriod = insertCondition(coverageMetricDto.getId(), "GT", "80", null, null);
QualityGateConditionDto conditionOnLeakPeriod = insertCondition(coverageMetricDto.getId(), "GT", "80", null, 1);
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Condition on metric 'Coverage' over leak period already exists.");
// Update condition not on leak period to be on leak period => will fail as this condition already exist
underTest.updateCondition(dbSession, conditionNotOnLeakPeriod.getId(), coverageMetricDto.getKey(), "GT", "80", null, 1);
}
use of org.sonar.db.qualitygate.QualityGateConditionDto in project sonarqube by SonarSource.
the class QualityGateConditionsUpdaterTest method create_warning_condition_without_period.
@Test
public void create_warning_condition_without_period() {
QualityGateConditionDto result = underTest.createCondition(dbSession, qualityGateDto.getId(), "coverage", "LT", "90", null, null);
verifyCondition(result, coverageMetricDto.getId(), "LT", "90", null, null);
}
use of org.sonar.db.qualitygate.QualityGateConditionDto in project sonarqube by SonarSource.
the class QualityGateConditionsUpdaterTest method create_error_condition_with_period.
@Test
public void create_error_condition_with_period() {
MetricDto metricDto = dbClient.metricDao().insert(dbSession, newMetricDto().setKey("new_coverage").setValueType(INT.name()).setHidden(false));
dbSession.commit();
QualityGateConditionDto result = underTest.createCondition(dbSession, qualityGateDto.getId(), "new_coverage", "LT", null, "80", 1);
verifyCondition(result, metricDto.getId(), "LT", null, "80", 1);
}
use of org.sonar.db.qualitygate.QualityGateConditionDto in project sonarqube by SonarSource.
the class QualityGateConditionsUpdaterTest method create_condition_on_rating_metric.
@Test
public void create_condition_on_rating_metric() {
QualityGateConditionDto result = underTest.createCondition(dbSession, qualityGateDto.getId(), ratingMetricDto.getKey(), "GT", null, "3", null);
verifyCondition(result, ratingMetricDto.getId(), "GT", null, "3", null);
}
use of org.sonar.db.qualitygate.QualityGateConditionDto in project sonarqube by SonarSource.
the class ShowAction method handle.
@Override
public void handle(Request request, Response response) {
Long qGateId = request.paramAsLong(QualityGatesWsParameters.PARAM_ID);
String qGateName = request.param(QualityGatesWsParameters.PARAM_NAME);
checkOneOfIdOrNamePresent(qGateId, qGateName);
QualityGateDto qGate = qGateId == null ? qualityGates.get(qGateName) : qualityGates.get(qGateId);
qGateId = qGate.getId();
JsonWriter writer = response.newJsonWriter().beginObject().prop(QualityGatesWsParameters.PARAM_ID, qGate.getId()).prop(QualityGatesWsParameters.PARAM_NAME, qGate.getName());
Collection<QualityGateConditionDto> conditions = qualityGates.listConditions(qGateId);
if (!conditions.isEmpty()) {
writer.name("conditions").beginArray();
for (QualityGateConditionDto condition : conditions) {
QualityGatesWs.writeQualityGateCondition(condition, writer);
}
writer.endArray();
}
writer.endObject().close();
}
Aggregations