use of org.sonarqube.ws.client.qualitygate.ProjectStatusWsRequest 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.client.qualitygate.ProjectStatusWsRequest in project sonarqube by SonarSource.
the class ProjectStatusAction method toProjectStatusWsRequest.
private static ProjectStatusWsRequest toProjectStatusWsRequest(Request request) {
ProjectStatusWsRequest projectStatusWsRequest = new ProjectStatusWsRequest().setAnalysisId(request.param(PARAM_ANALYSIS_ID)).setProjectId(request.param(PARAM_PROJECT_ID)).setProjectKey(request.param(PARAM_PROJECT_KEY));
checkRequest(!isNullOrEmpty(projectStatusWsRequest.getAnalysisId()) ^ !isNullOrEmpty(projectStatusWsRequest.getProjectId()) ^ !isNullOrEmpty(projectStatusWsRequest.getProjectKey()), MSG_ONE_PARAMETER_ONLY);
return projectStatusWsRequest;
}
Aggregations