Search in sources :

Example 46 with QualityGateDto

use of org.sonar.db.qualitygate.QualityGateDto 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 47 with QualityGateDto

use of org.sonar.db.qualitygate.QualityGateDto 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 48 with QualityGateDto

use of org.sonar.db.qualitygate.QualityGateDto 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)

Example 49 with QualityGateDto

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

the class GetByProjectActionTest method get_with_project_user_permission.

@Test
public void get_with_project_user_permission() {
    ComponentDto project = componentDb.insertProject();
    userSession.logIn().addProjectUuidPermissions(UserRole.USER, 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 50 with QualityGateDto

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

the class GetByProjectActionTest method json_example.

@Test
public void json_example() {
    OrganizationDto organizationDto = db.organizations().insert();
    ComponentDto project = componentDb.insertComponent(newProjectDto(organizationDto));
    QualityGateDto qualityGate = insertQualityGate("My team QG");
    associateProjectToQualityGate(project.getId(), qualityGate.getId());
    logInAsProjectUser(project);
    String result = ws.newRequest().setParam(PARAM_PROJECT_ID, project.uuid()).execute().getInput();
    assertJson(result).ignoreFields("id").isSimilarTo(getClass().getResource("get_by_project-example.json"));
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) 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