Search in sources :

Example 11 with QualityGateDto

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

the class GetByProjectAction method buildResponse.

private static GetByProjectWsResponse buildResponse(Optional<QualityGateData> data) {
    if (!data.isPresent()) {
        return GetByProjectWsResponse.getDefaultInstance();
    }
    QualityGateDto qualityGate = data.get().getQualityGate();
    GetByProjectWsResponse.Builder response = GetByProjectWsResponse.newBuilder();
    response.getQualityGateBuilder().setId(String.valueOf(qualityGate.getId())).setName(qualityGate.getName()).setDefault(data.get().isDefault());
    return response.build();
}
Also used : GetByProjectWsResponse(org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto)

Example 12 with QualityGateDto

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

the class QualityGatesWsTest method list_with_default.

@Test
public void list_with_default() throws Exception {
    QualityGateDto defaultQgate = new QualityGateDto().setId(42L).setName("Golden");
    when(qGates.list()).thenReturn(Lists.newArrayList(defaultQgate, new QualityGateDto().setId(43L).setName("Star"), new QualityGateDto().setId(666L).setName("Ninth")));
    when(qGates.getDefault()).thenReturn(defaultQgate);
    tester.newGetRequest("api/qualitygates", "list").execute().assertJson("{\"qualitygates\":[{\"id\":42,\"name\":\"Golden\"},{\"id\":43,\"name\":\"Star\"},{\"id\":666,\"name\":\"Ninth\"}],\"default\":42}");
}
Also used : QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) Test(org.junit.Test)

Example 13 with QualityGateDto

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

the class QualityGatesWsTest method rename_nominal.

@Test
public void rename_nominal() throws Exception {
    Long id = 42L;
    String name = "New QG";
    when(qGates.rename(id, name)).thenReturn(new QualityGateDto().setId(id).setName(name));
    tester.newPostRequest("api/qualitygates", "rename").setParam("id", id.toString()).setParam("name", name).execute().assertJson("{\"id\":42,\"name\":\"New QG\"}");
    ;
}
Also used : QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) Test(org.junit.Test)

Example 14 with QualityGateDto

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

the class QualityGatesWsTest method show_empty.

@Test
public void show_empty() throws Exception {
    long gateId = 12345L;
    when(qGates.get(gateId)).thenReturn(new QualityGateDto().setId(gateId).setName("Golden"));
    tester.newGetRequest("api/qualitygates", "show").setParam("id", Long.toString(gateId)).execute().assertJson("{\"id\":12345,\"name\":\"Golden\"}");
}
Also used : QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) Test(org.junit.Test)

Example 15 with QualityGateDto

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

the class QualityGatesWsTest method copy_nominal.

@Test
public void copy_nominal() throws Exception {
    String name = "Copied QG";
    when(qGates.copy(24L, name)).thenReturn(new QualityGateDto().setId(42L).setName(name));
    tester.newPostRequest("api/qualitygates", "copy").setParam("id", "24").setParam("name", name).execute().assertJson("{\"id\":42,\"name\":\"Copied QG\"}");
}
Also used : QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) Test(org.junit.Test)

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