Search in sources :

Example 16 with QualityGateDto

use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.

the class QualityGatesWsTest method show_by_id_nominal.

@Test
public void show_by_id_nominal() throws Exception {
    long gateId = 12345L;
    when(qGates.get(gateId)).thenReturn(new QualityGateDto().setId(gateId).setName("Golden"));
    when(qGates.listConditions(gateId)).thenReturn(ImmutableList.of(new QualityGateConditionDto().setId(1L).setMetricKey("ncloc").setOperator("GT").setErrorThreshold("10000"), new QualityGateConditionDto().setId(2L).setMetricKey("new_coverage").setOperator("LT").setWarningThreshold("90").setPeriod(3)));
    tester.newGetRequest("api/qualitygates", "show").setParam("id", Long.toString(gateId)).execute().assertJson("{\"id\":12345,\"name\":\"Golden\",\"conditions\":[" + "{\"id\":1,\"metric\":\"ncloc\",\"op\":\"GT\",\"error\":\"10000\"}," + "{\"id\":2,\"metric\":\"new_coverage\",\"op\":\"LT\",\"warning\":\"90\",\"period\":3}" + "]}");
}
Also used : QualityGateConditionDto(org.sonar.db.qualitygate.QualityGateConditionDto) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) Test(org.junit.Test)

Example 17 with QualityGateDto

use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.

the class QualityGatesWsTest method show_by_name_nominal.

@Test
public void show_by_name_nominal() throws Exception {
    long qGateId = 12345L;
    String gateName = "Golden";
    when(qGates.get(gateName)).thenReturn(new QualityGateDto().setId(qGateId).setName(gateName));
    when(qGates.listConditions(qGateId)).thenReturn(ImmutableList.of(new QualityGateConditionDto().setId(1L).setMetricKey("ncloc").setOperator("GT").setErrorThreshold("10000"), new QualityGateConditionDto().setId(2L).setMetricKey("new_coverage").setOperator("LT").setWarningThreshold("90").setPeriod(3)));
    tester.newGetRequest("api/qualitygates", "show").setParam("name", gateName).execute().assertJson("{\"id\":12345,\"name\":\"Golden\",\"conditions\":[" + "{\"id\":1,\"metric\":\"ncloc\",\"op\":\"GT\",\"error\":\"10000\"}," + "{\"id\":2,\"metric\":\"new_coverage\",\"op\":\"LT\",\"warning\":\"90\",\"period\":3}" + "]}");
}
Also used : QualityGateConditionDto(org.sonar.db.qualitygate.QualityGateConditionDto) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) Test(org.junit.Test)

Example 18 with QualityGateDto

use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.

the class SelectActionTest method insertQualityGate.

private QualityGateDto insertQualityGate() {
    QualityGateDto gate = new QualityGateDto().setName("Custom");
    dbClient.qualityGateDao().insert(dbSession, gate);
    dbSession.commit();
    return gate;
}
Also used : QualityGateDto(org.sonar.db.qualitygate.QualityGateDto)

Example 19 with QualityGateDto

use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.

the class CreateActionTest method create_quality_gate.

@Test
public void create_quality_gate() throws Exception {
    logInAsQualityGateAdmin();
    CreateWsResponse response = executeRequest("Default");
    assertThat(response.getName()).isEqualTo("Default");
    assertThat(response.getId()).isNotNull();
    dbSession.commit();
    QualityGateDto qualityGateDto = dbClient.qualityGateDao().selectByName(dbSession, "Default");
    assertThat(qualityGateDto).isNotNull();
}
Also used : QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) CreateWsResponse(org.sonarqube.ws.WsQualityGates.CreateWsResponse) Test(org.junit.Test)

Example 20 with QualityGateDto

use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.

the class DeselectActionTest method insertQualityGate.

private QualityGateDto insertQualityGate() {
    QualityGateDto gate = new QualityGateDto().setName("Custom");
    dbClient.qualityGateDao().insert(dbSession, gate);
    dbSession.commit();
    return gate;
}
Also used : QualityGateDto(org.sonar.db.qualitygate.QualityGateDto)

Aggregations

QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)51 Test (org.junit.Test)33 ComponentDto (org.sonar.db.component.ComponentDto)12 DbSession (org.sonar.db.DbSession)6 PropertyDto (org.sonar.db.property.PropertyDto)6 GetByProjectWsResponse (org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse)6 QualityGateConditionDto (org.sonar.db.qualitygate.QualityGateConditionDto)5 JsonWriter (org.sonar.api.utils.text.JsonWriter)4 OrganizationDto (org.sonar.db.organization.OrganizationDto)2 WsQualityGates (org.sonarqube.ws.WsQualityGates)2 CreateWsResponse (org.sonarqube.ws.WsQualityGates.CreateWsResponse)2 Matchers.anyString (org.mockito.Matchers.anyString)1 SnapshotDto (org.sonar.db.component.SnapshotDto)1 MetricDto (org.sonar.db.metric.MetricDto)1 MetricTesting.newMetricDto (org.sonar.db.metric.MetricTesting.newMetricDto)1 UserDto (org.sonar.db.user.UserDto)1