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();
}
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());
}
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();
}
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());
}
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();
}
Aggregations