use of org.sonarqube.ws.WsQualityGates.ProjectStatusWsResponse in project sonarqube by SonarSource.
the class QualityGateTest method ad_hoc_build_break_strategy.
@Test
public void ad_hoc_build_break_strategy() throws IOException {
QualityGate simple = qgClient().create("SimpleWithLowThresholdForBuildBreakStrategy");
qgClient().setDefault(simple.id());
qgClient().createCondition(NewCondition.create(simple.id()).metricKey("ncloc").operator("GT").errorThreshold("7"));
try {
File projectDir = projectDir("qualitygate/xoo-sample");
SonarScanner build = SonarScanner.create(projectDir);
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_ERROR);
String taskId = getTaskIdInLocalReport(projectDir);
String analysisId = getAnalysisId(taskId);
ProjectStatusWsResponse projectStatusWsResponse = wsClient.qualityGates().projectStatus(new ProjectStatusWsRequest().setAnalysisId(analysisId));
ProjectStatusWsResponse.ProjectStatus projectStatus = projectStatusWsResponse.getProjectStatus();
assertThat(projectStatus.getStatus()).isEqualTo(ProjectStatusWsResponse.Status.ERROR);
assertThat(projectStatus.getConditionsCount()).isEqualTo(1);
ProjectStatusWsResponse.Condition condition = projectStatus.getConditionsList().get(0);
assertThat(condition.getMetricKey()).isEqualTo("ncloc");
assertThat(condition.getErrorThreshold()).isEqualTo("7");
} finally {
qgClient().unsetDefault();
qgClient().destroy(simple.id());
}
}
use of org.sonarqube.ws.WsQualityGates.ProjectStatusWsResponse in project sonarqube by SonarSource.
the class ProjectStatusActionTest method return_undefined_status_if_snapshot_is_not_found.
@Test
public void return_undefined_status_if_snapshot_is_not_found() {
ComponentDto project = db.components().insertProject(db.organizations().insert());
userSession.addProjectUuidPermissions(UserRole.USER, project.uuid());
ProjectStatusWsResponse result = callByProjectUuid(project.uuid());
assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
assertThat(result.getProjectStatus().getConditionsCount()).isEqualTo(0);
}
use of org.sonarqube.ws.WsQualityGates.ProjectStatusWsResponse in project sonarqube by SonarSource.
the class ProjectStatusActionTest method return_undefined_status_if_measure_is_not_found.
@Test
public void return_undefined_status_if_measure_is_not_found() {
ComponentDto project = db.components().insertProject(db.organizations().insert());
SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
dbSession.commit();
userSession.addProjectUuidPermissions(UserRole.USER, project.uuid());
ProjectStatusWsResponse result = call(snapshot.getUuid());
assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
assertThat(result.getProjectStatus().getConditionsCount()).isEqualTo(0);
}
Aggregations