use of org.sonar.wsclient.qualitygate.QualityGateCondition in project sonarqube by SonarSource.
the class QualityGateUiTest method display_alerts_correctly_in_history_page.
/**
* SONAR-3326
*/
@Test
public void display_alerts_correctly_in_history_page() {
QualityGateClient qgClient = qgClient();
QualityGate qGate = qgClient.create("AlertsForHistory");
qgClient.setDefault(qGate.id());
String firstAnalysisDate = DateFormatUtils.ISO_DATE_FORMAT.format(addDays(new Date(), -2));
String secondAnalysisDate = DateFormatUtils.ISO_DATE_FORMAT.format(addDays(new Date(), -1));
// with this configuration, project should have an Orange alert
QualityGateCondition lowThresholds = qgClient.createCondition(NewCondition.create(qGate.id()).metricKey("lines").operator("GT").warningThreshold("5").errorThreshold("50"));
scanSampleWithDate(firstAnalysisDate);
// with this configuration, project should have a Green alert
qgClient.updateCondition(UpdateCondition.create(lowThresholds.id()).metricKey("lines").operator("GT").warningThreshold("5000").errorThreshold("5000"));
scanSampleWithDate(secondAnalysisDate);
ProjectActivityPage page = Navigation.get(orchestrator).openProjectActivity("sample");
page.assertFirstAnalysisOfTheDayHasText(secondAnalysisDate, "Green (was Orange)").assertFirstAnalysisOfTheDayHasText(firstAnalysisDate, "Orange");
qgClient.unsetDefault();
qgClient.destroy(qGate.id());
}
Aggregations