Search in sources :

Example 1 with GetByProjectWsResponse

use of org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse 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 2 with GetByProjectWsResponse

use of org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse in project sonarqube by SonarSource.

the class GetByProjectActionTest method get_with_project_admin_permission.

@Test
public void get_with_project_admin_permission() {
    ComponentDto project = componentDb.insertProject();
    userSession.logIn().addProjectUuidPermissions(UserRole.ADMIN, project.uuid());
    QualityGateDto dbQualityGate = insertQualityGate("Sonar way");
    setDefaultQualityGate(dbQualityGate.getId());
    GetByProjectWsResponse result = callByUuid(project.uuid());
    assertThat(result.getQualityGate().getName()).isEqualTo(dbQualityGate.getName());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) GetByProjectWsResponse(org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) Test(org.junit.Test)

Example 3 with GetByProjectWsResponse

use of org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse in project sonarqube by SonarSource.

the class GetByProjectActionTest method default_quality_gate.

@Test
public void default_quality_gate() {
    ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert()));
    QualityGateDto dbQualityGate = insertQualityGate("Sonar way");
    setDefaultQualityGate(dbQualityGate.getId());
    logInAsProjectUser(project);
    GetByProjectWsResponse result = callByUuid(project.uuid());
    WsQualityGates.QualityGate qualityGate = result.getQualityGate();
    assertThat(Long.valueOf(qualityGate.getId())).isEqualTo(dbQualityGate.getId());
    assertThat(qualityGate.getName()).isEqualTo(dbQualityGate.getName());
    assertThat(qualityGate.getDefault()).isTrue();
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) GetByProjectWsResponse(org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse) WsQualityGates(org.sonarqube.ws.WsQualityGates) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) Test(org.junit.Test)

Example 4 with GetByProjectWsResponse

use of org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse in project sonarqube by SonarSource.

the class GetByProjectActionTest method get_by_project_key.

@Test
public void get_by_project_key() {
    ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert()));
    QualityGateDto dbQualityGate = insertQualityGate("My team QG");
    associateProjectToQualityGate(project.getId(), dbQualityGate.getId());
    logInAsProjectUser(project);
    GetByProjectWsResponse result = callByKey(project.key());
    assertThat(result.getQualityGate().getName()).isEqualTo(dbQualityGate.getName());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) GetByProjectWsResponse(org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) Test(org.junit.Test)

Example 5 with GetByProjectWsResponse

use of org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse in project sonarqube by SonarSource.

the class GetByProjectActionTest method project_quality_gate_over_default.

@Test
public void project_quality_gate_over_default() {
    ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization()));
    QualityGateDto defaultDbQualityGate = insertQualityGate("Sonar way");
    QualityGateDto dbQualityGate = insertQualityGate("My team QG");
    setDefaultQualityGate(defaultDbQualityGate.getId());
    associateProjectToQualityGate(project.getId(), dbQualityGate.getId());
    logInAsProjectUser(project);
    GetByProjectWsResponse result = callByUuid(project.uuid());
    WsQualityGates.QualityGate qualityGate = result.getQualityGate();
    assertThat(qualityGate.getName()).isEqualTo(dbQualityGate.getName());
    assertThat(qualityGate.getDefault()).isFalse();
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) GetByProjectWsResponse(org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse) WsQualityGates(org.sonarqube.ws.WsQualityGates) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) Test(org.junit.Test)

Aggregations

QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)6 GetByProjectWsResponse (org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse)6 Test (org.junit.Test)5 ComponentDto (org.sonar.db.component.ComponentDto)5 WsQualityGates (org.sonarqube.ws.WsQualityGates)2