Search in sources :

Example 11 with QualityGate

use of org.sonar.wsclient.qualitygate.QualityGate in project sonarqube by SonarSource.

the class QualityGateTest method use_server_settings_instead_of_default_gate.

@Test
public void use_server_settings_instead_of_default_gate() throws IOException {
    QualityGate alert = qgClient().create("AlertWithLowThreshold");
    qgClient().createCondition(NewCondition.create(alert.id()).metricKey("ncloc").operator("GT").warningThreshold("10"));
    QualityGate error = qgClient().create("ErrorWithLowThreshold");
    qgClient().createCondition(NewCondition.create(error.id()).metricKey("ncloc").operator("GT").errorThreshold("10"));
    qgClient().setDefault(alert.id());
    associateQualityGateToProject(error.id(), PROJECT_KEY);
    try {
        SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
        BuildResult buildResult = orchestrator.executeBuild(build);
        verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_ERROR);
        assertThat(getGateStatusMeasure().getValue()).isEqualTo("ERROR");
    } finally {
        qgClient().unsetDefault();
        qgClient().destroy(alert.id());
        qgClient().destroy(error.id());
    }
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) QualityGate(org.sonar.wsclient.qualitygate.QualityGate) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 12 with QualityGate

use of org.sonar.wsclient.qualitygate.QualityGate in project sonarqube by SonarSource.

the class ProjectQualityGatePageTest method should_display_custom.

@Test
public void should_display_custom() {
    QualityGate customQualityGate = createCustomQualityGate("should_display_custom");
    associateWithQualityGate(customQualityGate);
    ProjectQualityGatePage page = openPage();
    SelenideElement selectedQualityGate = page.getSelectedQualityGate();
    selectedQualityGate.shouldNot(Condition.hasText("Default"));
    selectedQualityGate.should(Condition.hasText(customQualityGate.name()));
}
Also used : SelenideElement(com.codeborne.selenide.SelenideElement) ProjectQualityGatePage(pageobjects.ProjectQualityGatePage) QualityGate(org.sonar.wsclient.qualitygate.QualityGate) Test(org.junit.Test)

Example 13 with QualityGate

use of org.sonar.wsclient.qualitygate.QualityGate in project sonarqube by SonarSource.

the class ProjectQualityGatePageTest method should_set_none.

@Test
@Ignore("find a way to select None")
public void should_set_none() {
    qualityGateClient().unsetDefault();
    QualityGate customQualityGate = createCustomQualityGate("should_set_none");
    associateWithQualityGate(customQualityGate);
    ProjectQualityGatePage page = openPage();
    page.setQualityGate("");
    page.assertNotSelected();
}
Also used : ProjectQualityGatePage(pageobjects.ProjectQualityGatePage) QualityGate(org.sonar.wsclient.qualitygate.QualityGate) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with QualityGate

use of org.sonar.wsclient.qualitygate.QualityGate in project sonarqube by SonarSource.

the class ProjectQualityGatePageTest method should_display_default.

@Test
public void should_display_default() {
    QualityGate customQualityGate = createCustomQualityGate("should_display_default");
    qualityGateClient().setDefault(customQualityGate.id());
    ProjectQualityGatePage page = openPage();
    SelenideElement selectedQualityGate = page.getSelectedQualityGate();
    selectedQualityGate.should(Condition.hasText("Default"));
    selectedQualityGate.should(Condition.hasText(customQualityGate.name()));
}
Also used : SelenideElement(com.codeborne.selenide.SelenideElement) ProjectQualityGatePage(pageobjects.ProjectQualityGatePage) QualityGate(org.sonar.wsclient.qualitygate.QualityGate) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 QualityGate (org.sonar.wsclient.qualitygate.QualityGate)14 SonarScanner (com.sonar.orchestrator.build.SonarScanner)8 BuildResult (com.sonar.orchestrator.build.BuildResult)7 ProjectQualityGatePage (pageobjects.ProjectQualityGatePage)5 SelenideElement (com.codeborne.selenide.SelenideElement)4 File (java.io.File)1 Date (java.util.Date)1 MimeMessage (javax.mail.internet.MimeMessage)1 Ignore (org.junit.Ignore)1 QualityGateClient (org.sonar.wsclient.qualitygate.QualityGateClient)1 QualityGateCondition (org.sonar.wsclient.qualitygate.QualityGateCondition)1 Measure (org.sonarqube.ws.WsMeasures.Measure)1 ProjectStatusWsResponse (org.sonarqube.ws.WsQualityGates.ProjectStatusWsResponse)1 PostRequest (org.sonarqube.ws.client.PostRequest)1 WsClient (org.sonarqube.ws.client.WsClient)1 ProjectStatusWsRequest (org.sonarqube.ws.client.qualitygate.ProjectStatusWsRequest)1 WiserMessage (org.subethamail.wiser.WiserMessage)1 ProjectActivityPage (pageobjects.ProjectActivityPage)1 ItUtils.getMeasure (util.ItUtils.getMeasure)1