Search in sources :

Example 1 with QualityGateClient

use of org.sonar.wsclient.qualitygate.QualityGateClient 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());
}
Also used : QualityGateClient(org.sonar.wsclient.qualitygate.QualityGateClient) ProjectActivityPage(pageobjects.ProjectActivityPage) QualityGateCondition(org.sonar.wsclient.qualitygate.QualityGateCondition) Date(java.util.Date) QualityGate(org.sonar.wsclient.qualitygate.QualityGate) Test(org.junit.Test)

Aggregations

Date (java.util.Date)1 Test (org.junit.Test)1 QualityGate (org.sonar.wsclient.qualitygate.QualityGate)1 QualityGateClient (org.sonar.wsclient.qualitygate.QualityGateClient)1 QualityGateCondition (org.sonar.wsclient.qualitygate.QualityGateCondition)1 ProjectActivityPage (pageobjects.ProjectActivityPage)1