Search in sources :

Example 1 with CreateWsResponse

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

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

the class CreateAction method handle.

@Override
public void handle(Request request, Response response) {
    userSession.checkPermission(OrganizationPermission.ADMINISTER_QUALITY_GATES, defaultOrganizationProvider.get().getUuid());
    try (DbSession dbSession = dbClient.openSession(false)) {
        QualityGateDto newQualityGate = qualityGateUpdater.create(dbSession, request.mandatoryParam(PARAM_NAME));
        CreateWsResponse.Builder createWsResponse = CreateWsResponse.newBuilder().setId(newQualityGate.getId()).setName(newQualityGate.getName());
        writeProtobuf(createWsResponse.build(), request, response);
        dbSession.commit();
    }
}
Also used : DbSession(org.sonar.db.DbSession) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto) CreateWsResponse(org.sonarqube.ws.WsQualityGates.CreateWsResponse)

Aggregations

QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)2 CreateWsResponse (org.sonarqube.ws.WsQualityGates.CreateWsResponse)2 Test (org.junit.Test)1 DbSession (org.sonar.db.DbSession)1