aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEric Hartmann <hartmann.eric@gmail.com>2017-11-27 11:52:14 +0100
committerEric Hartmann <hartmann.eric@gmail.Com>2017-12-04 13:44:55 +0100
commitbdcd6c83057c7021ce649f728ed76c64a2c6eb3c (patch)
tree2c153995cd8c40c7172ecc1286dda12b90739e43 /tests
parent426de5143b2680781b815fdb1087b5b00edc0336 (diff)
downloadsonarqube-bdcd6c83057c7021ce649f728ed76c64a2c6eb3c.tar.gz
sonarqube-bdcd6c83057c7021ce649f728ed76c64a2c6eb3c.zip
SONAR-9962 Remove the ability to unset default quality profile
Diffstat (limited to 'tests')
-rw-r--r--tests/src/test/java/org/sonarqube/tests/qualityGate/ProjectQualityGatePageTest.java26
-rw-r--r--tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateTest.java119
2 files changed, 40 insertions, 105 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/qualityGate/ProjectQualityGatePageTest.java b/tests/src/test/java/org/sonarqube/tests/qualityGate/ProjectQualityGatePageTest.java
index 474038f74cc..1cdc8389520 100644
--- a/tests/src/test/java/org/sonarqube/tests/qualityGate/ProjectQualityGatePageTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/qualityGate/ProjectQualityGatePageTest.java
@@ -20,16 +20,13 @@
package org.sonarqube.tests.qualityGate;
import com.codeborne.selenide.Condition;
-import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.sonar.orchestrator.Orchestrator;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
-import org.openqa.selenium.Keys;
import org.sonar.wsclient.qualitygate.QualityGate;
import org.sonar.wsclient.qualitygate.QualityGateClient;
import org.sonarqube.qa.util.Tester;
@@ -76,7 +73,6 @@ public class ProjectQualityGatePageTest {
selectedQualityGate.should(Condition.text("Default"));
selectedQualityGate.should(Condition.text(customQualityGate.name()));
} finally {
- qualityGateClient().unsetDefault();
qualityGateClient().destroy(customQualityGate.id());
}
}
@@ -93,14 +89,6 @@ public class ProjectQualityGatePageTest {
}
@Test
- public void should_display_none() {
- qualityGateClient().unsetDefault();
-
- ProjectQualityGatePage page = openPage();
- page.assertNotSelected();
- }
-
- @Test
public void should_set_custom() {
QualityGate customQualityGate = createCustomQualityGate("should_set_custom");
@@ -124,24 +112,10 @@ public class ProjectQualityGatePageTest {
selectedQualityGate.should(Condition.text("Default"));
selectedQualityGate.should(Condition.text(customQualityGate.name()));
} finally {
- qualityGateClient().unsetDefault();
qualityGateClient().destroy(customQualityGate.id());
}
}
- @Test
- @Ignore
- public void should_set_none() {
- qualityGateClient().unsetDefault();
- QualityGate customQualityGate = createCustomQualityGate("should_set_none");
- associateWithQualityGate(customQualityGate);
-
- ProjectQualityGatePage page = openPage();
- Selenide.$(".Select-input input").sendKeys(Keys.UP, Keys.UP, Keys.UP, Keys.ENTER);
-
- page.assertNotSelected();
- }
-
private ProjectQualityGatePage openPage() {
tester.wsClient().users().skipOnboardingTutorial();
Navigation navigation = tester.openBrowser().logIn().submitCredentials("admin");
diff --git a/tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateTest.java b/tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateTest.java
index 51439df8ea9..76f3f677092 100644
--- a/tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateTest.java
@@ -102,31 +102,16 @@ public class QualityGateTest {
}
@Test
- public void do_not_compute_status_if_no_gate() throws Exception {
- qgClient().unsetDefault();
- String projectKey = newProjectKey();
- BuildResult buildResult = executeAnalysis(projectKey);
-
- verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_NO_QG);
-
- assertThat(getGateStatusMeasure(projectKey)).isNull();
- }
-
- @Test
public void status_ok_if_empty_gate() throws Exception {
QualityGate empty = qgClient().create("Empty");
qgClient().setDefault(empty.id());
- try {
- String projectKey = newProjectKey();
- BuildResult buildResult = executeAnalysis(projectKey);
+ String projectKey = newProjectKey();
+ BuildResult buildResult = executeAnalysis(projectKey);
- verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_OK);
+ verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_OK);
- assertThat(getGateStatusMeasure(projectKey).getValue()).isEqualTo("OK");
- } finally {
- qgClient().unsetDefault();
- }
+ assertThat(getGateStatusMeasure(projectKey).getValue()).isEqualTo("OK");
}
@Test
@@ -135,16 +120,12 @@ public class QualityGateTest {
qgClient().setDefault(simple.id());
qgClient().createCondition(NewCondition.create(simple.id()).metricKey("ncloc").operator("GT").warningThreshold("40"));
- try {
- String projectKey = newProjectKey();
- BuildResult buildResult = executeAnalysis(projectKey);
+ String projectKey = newProjectKey();
+ BuildResult buildResult = executeAnalysis(projectKey);
- verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_OK);
+ verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_OK);
- assertThat(getGateStatusMeasure(projectKey).getValue()).isEqualTo("OK");
- } finally {
- qgClient().unsetDefault();
- }
+ assertThat(getGateStatusMeasure(projectKey).getValue()).isEqualTo("OK");
}
@Test
@@ -153,16 +134,12 @@ public class QualityGateTest {
qgClient().setDefault(simple.id());
qgClient().createCondition(NewCondition.create(simple.id()).metricKey("ncloc").operator("GT").warningThreshold("10"));
- try {
- String projectKey = newProjectKey();
- BuildResult buildResult = executeAnalysis(projectKey);
+ String projectKey = newProjectKey();
+ BuildResult buildResult = executeAnalysis(projectKey);
- verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_WARN);
+ verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_WARN);
- assertThat(getGateStatusMeasure(projectKey).getValue()).isEqualTo("WARN");
- } finally {
- qgClient().unsetDefault();
- }
+ assertThat(getGateStatusMeasure(projectKey).getValue()).isEqualTo("WARN");
}
@Test
@@ -171,16 +148,12 @@ public class QualityGateTest {
qgClient().setDefault(simple.id());
qgClient().createCondition(NewCondition.create(simple.id()).metricKey("ncloc").operator("GT").errorThreshold("10"));
- try {
- String projectKey = newProjectKey();
- BuildResult buildResult = executeAnalysis(projectKey);
+ String projectKey = newProjectKey();
+ BuildResult buildResult = executeAnalysis(projectKey);
- verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_ERROR);
+ verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_ERROR);
- assertThat(getGateStatusMeasure(projectKey).getValue()).isEqualTo("ERROR");
- } finally {
- qgClient().unsetDefault();
- }
+ assertThat(getGateStatusMeasure(projectKey).getValue()).isEqualTo("ERROR");
}
@Test
@@ -195,15 +168,11 @@ public class QualityGateTest {
orchestrator.getServer().provisionProject(projectKey, projectKey);
associateQualityGateToProject(error.id(), projectKey);
- try {
- BuildResult buildResult = executeAnalysis(projectKey);
+ BuildResult buildResult = executeAnalysis(projectKey);
- verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_ERROR);
+ verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_ERROR);
- assertThat(getGateStatusMeasure(projectKey).getValue()).isEqualTo("ERROR");
- } finally {
- qgClient().unsetDefault();
- }
+ assertThat(getGateStatusMeasure(projectKey).getValue()).isEqualTo("ERROR");
}
@Test
@@ -213,22 +182,18 @@ public class QualityGateTest {
qgClient().createCondition(NewCondition.create(allTypes.id()).metricKey("duplicated_lines_density").operator("GT").warningThreshold("20"));
qgClient().setDefault(allTypes.id());
- try {
- String projectKey = newProjectKey();
- BuildResult buildResult = executeAnalysis(projectKey, "sonar.cpd.xoo.minimumLines", "2", "sonar.cpd.xoo.minimumTokens", "5");
+ String projectKey = newProjectKey();
+ BuildResult buildResult = executeAnalysis(projectKey, "sonar.cpd.xoo.minimumLines", "2", "sonar.cpd.xoo.minimumTokens", "5");
- verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_WARN);
+ verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_WARN);
- Measure alertStatus = getGateStatusMeasure(projectKey);
- assertThat(alertStatus.getValue()).isEqualTo("WARN");
+ Measure alertStatus = getGateStatusMeasure(projectKey);
+ assertThat(alertStatus.getValue()).isEqualTo("WARN");
- String qualityGateDetailJson = getMeasure(orchestrator, projectKey, "quality_gate_details").getValue();
- assertThat(QualityGateDetails.parse(qualityGateDetailJson).getConditions())
- .extracting(QualityGateDetails.Conditions::getMetric, QualityGateDetails.Conditions::getOp, QualityGateDetails.Conditions::getWarning)
- .contains(tuple("ncloc", "GT", "10"), tuple("duplicated_lines_density", "GT", "20"));
- } finally {
- qgClient().unsetDefault();
- }
+ String qualityGateDetailJson = getMeasure(orchestrator, projectKey, "quality_gate_details").getValue();
+ assertThat(QualityGateDetails.parse(qualityGateDetailJson).getConditions())
+ .extracting(QualityGateDetails.Conditions::getMetric, QualityGateDetails.Conditions::getOp, QualityGateDetails.Conditions::getWarning)
+ .contains(tuple("ncloc", "GT", "10"), tuple("duplicated_lines_density", "GT", "20"));
}
@Test
@@ -237,25 +202,21 @@ public class QualityGateTest {
qgClient().setDefault(simple.id());
qgClient().createCondition(NewCondition.create(simple.id()).metricKey("ncloc").operator("GT").errorThreshold("7"));
- try {
- String projectKey = newProjectKey();
- BuildResult buildResult = executeAnalysis(projectKey);
+ String projectKey = newProjectKey();
+ BuildResult buildResult = executeAnalysis(projectKey);
- verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_ERROR);
+ verifyQGStatusInPostTask(buildResult, projectKey, TASK_STATUS_SUCCESS, QG_STATUS_ERROR);
- String taskId = getTaskIdInLocalReport(projectDir("qualitygate/xoo-sample"));
- String analysisId = getAnalysisId(taskId);
+ String taskId = getTaskIdInLocalReport(projectDir("qualitygate/xoo-sample"));
+ String analysisId = getAnalysisId(taskId);
- Qualitygates.ProjectStatusResponse projectStatusWsResponse = tester.wsClient().qualityGates().projectStatus(new ProjectStatusRequest().setAnalysisId(analysisId));
- Qualitygates.ProjectStatusResponse.ProjectStatus projectStatus = projectStatusWsResponse.getProjectStatus();
- assertThat(projectStatus.getStatus()).isEqualTo(Qualitygates.ProjectStatusResponse.Status.ERROR);
- assertThat(projectStatus.getConditionsCount()).isEqualTo(1);
- Qualitygates.ProjectStatusResponse.Condition condition = projectStatus.getConditionsList().get(0);
- assertThat(condition.getMetricKey()).isEqualTo("ncloc");
- assertThat(condition.getErrorThreshold()).isEqualTo("7");
- } finally {
- qgClient().unsetDefault();
- }
+ ProjectStatusWsResponse projectStatusWsResponse = tester.wsClient().qualityGates().projectStatus(new ProjectStatusRequest().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");
}
@Test