use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.
the class QualityGateTest method test_status_warning.
@Test
public void test_status_warning() throws IOException {
QualityGate simple = qgClient().create("SimpleWithLowThreshold");
qgClient().setDefault(simple.id());
qgClient().createCondition(NewCondition.create(simple.id()).metricKey("ncloc").operator("GT").warningThreshold("10"));
try {
SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_WARN);
assertThat(getGateStatusMeasure().getValue()).isEqualTo("WARN");
} finally {
qgClient().unsetDefault();
qgClient().destroy(simple.id());
}
}
use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.
the class QualityGateTest method status_ok_if_empty_gate.
@Test
public void status_ok_if_empty_gate() throws IOException {
QualityGate empty = qgClient().create("Empty");
qgClient().setDefault(empty.id());
try {
SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_OK);
assertThat(getGateStatusMeasure().getValue()).isEqualTo("OK");
} finally {
qgClient().unsetDefault();
qgClient().destroy(empty.id());
}
}
use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.
the class QualityGateTest method do_not_compute_status_if_no_gate.
@Test
public void do_not_compute_status_if_no_gate() throws IOException {
SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_NO_QG);
assertThat(getGateStatusMeasure()).isNull();
}
use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.
the class QualityGateTest method use_server_settings_instead_of_default_gate.
@Test
public void use_server_settings_instead_of_default_gate() throws IOException {
QualityGate alert = qgClient().create("AlertWithLowThreshold");
qgClient().createCondition(NewCondition.create(alert.id()).metricKey("ncloc").operator("GT").warningThreshold("10"));
QualityGate error = qgClient().create("ErrorWithLowThreshold");
qgClient().createCondition(NewCondition.create(error.id()).metricKey("ncloc").operator("GT").errorThreshold("10"));
qgClient().setDefault(alert.id());
associateQualityGateToProject(error.id(), PROJECT_KEY);
try {
SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_ERROR);
assertThat(getGateStatusMeasure().getValue()).isEqualTo("ERROR");
} finally {
qgClient().unsetDefault();
qgClient().destroy(alert.id());
qgClient().destroy(error.id());
}
}
use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.
the class EventTest method old_ws_events_does_not_allow_creating_events_on_modules.
@Test
public void old_ws_events_does_not_allow_creating_events_on_modules() {
SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-multi-modules-sample"));
orchestrator.executeBuild(sampleProject);
WsConnector wsConnector = ItUtils.newAdminWsClient(orchestrator).wsConnector();
WsResponse response = wsConnector.call(newCreateEventRequest("com.sonarsource.it.samples:multi-modules-sample", "bar"));
assertThat(response.code()).isEqualTo(200);
assertThat(wsConnector.call(newCreateEventRequest("com.sonarsource.it.samples:multi-modules-sample:module_a", "bar")).code()).isEqualTo(400);
}
Aggregations