aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-02-15 17:22:26 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-02-15 17:22:26 +0100
commite1d2ed65a58178ef30073d74d0fab077ffd12c6f (patch)
tree42fc24a403a99e759d3739c51bd4379e348f618f
parent6b1c892c3b40a9fd5e3210cf5c6c411ff3165236 (diff)
downloadsonarqube-e1d2ed65a58178ef30073d74d0fab077ffd12c6f.tar.gz
sonarqube-e1d2ed65a58178ef30073d74d0fab077ffd12c6f.zip
QGate ITs now restore default qgate at the end
As they were not restoring default quality gate, following IT ProjectOverviewTest was failing
-rw-r--r--it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java13
-rw-r--r--it/it-tests/src/test/java/it/qualityGate/QualityGateTest.java11
-rw-r--r--it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java12
3 files changed, 30 insertions, 6 deletions
diff --git a/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java b/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java
index 5920d677138..620c781385a 100644
--- a/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java
+++ b/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java
@@ -25,8 +25,11 @@ import com.sonar.orchestrator.selenium.Selenese;
import it.Category1Suite;
import java.util.Iterator;
import javax.mail.internet.MimeMessage;
-
-import org.junit.*;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
import org.sonar.wsclient.Sonar;
import org.sonar.wsclient.qualitygate.NewCondition;
import org.sonar.wsclient.qualitygate.QualityGate;
@@ -47,6 +50,8 @@ import static util.ItUtils.setServerProperty;
public class QualityGateNotificationTest {
+ private static long DEFAULT_QUALITY_GATE;
+
private static final String PROJECT_KEY = "sample";
@ClassRule
@@ -57,11 +62,13 @@ public class QualityGateNotificationTest {
setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
setServerProperty(orchestrator, "sonar.timemachine.period2", "30");
setServerProperty(orchestrator, "sonar.timemachine.period3", "previous_version");
+ DEFAULT_QUALITY_GATE = qgClient().list().defaultGate().id();
}
@AfterClass
- public static void resetPeriods() throws Exception {
+ public static void resetData() throws Exception {
ItUtils.resetPeriods(orchestrator);
+ qgClient().setDefault(DEFAULT_QUALITY_GATE);
}
@Before
diff --git a/it/it-tests/src/test/java/it/qualityGate/QualityGateTest.java b/it/it-tests/src/test/java/it/qualityGate/QualityGateTest.java
index 3e495c056a9..d25961a7e18 100644
--- a/it/it-tests/src/test/java/it/qualityGate/QualityGateTest.java
+++ b/it/it-tests/src/test/java/it/qualityGate/QualityGateTest.java
@@ -28,6 +28,7 @@ import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.Properties;
import org.apache.commons.io.FileUtils;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
@@ -53,10 +54,12 @@ import static util.ItUtils.projectDir;
public class QualityGateTest {
- private static final String PROJECT_KEY = "sample";
+ private static long DEFAULT_QUALITY_GATE;
private long provisionedProjectId = -1L;
+ private static final String PROJECT_KEY = "sample";
+
@ClassRule
public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR;
static WsClient wsClient;
@@ -64,6 +67,12 @@ public class QualityGateTest {
@BeforeClass
public static void startOrchestrator() {
wsClient = newAdminWsClient(orchestrator);
+ DEFAULT_QUALITY_GATE = qgClient().list().defaultGate().id();
+ }
+
+ @AfterClass
+ public static void restoreDefaultQualitGate() throws Exception {
+ qgClient().setDefault(DEFAULT_QUALITY_GATE);
}
@Before
diff --git a/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java b/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java
index 3a874dbd4c5..79733afc282 100644
--- a/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java
+++ b/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java
@@ -45,16 +45,20 @@ public class QualityGateUiTest {
@ClassRule
public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR;
+ private static long DEFAULT_QUALITY_GATE;
+
@BeforeClass
public static void initPeriods() throws Exception {
setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
setServerProperty(orchestrator, "sonar.timemachine.period2", "30");
setServerProperty(orchestrator, "sonar.timemachine.period3", "previous_version");
+ DEFAULT_QUALITY_GATE = qgClient().list().defaultGate().id();
}
@AfterClass
- public static void resetPeriods() throws Exception {
+ public static void resetData() throws Exception {
ItUtils.resetPeriods(orchestrator);
+ qgClient().setDefault(DEFAULT_QUALITY_GATE);
}
@Before
@@ -67,7 +71,7 @@ public class QualityGateUiTest {
*/
@Test
public void display_alerts_correctly_in_history_page() {
- QualityGateClient qgClient = orchestrator.getServer().adminWsClient().qualityGateClient();
+ QualityGateClient qgClient = qgClient();
QualityGate qGate = qgClient.create("AlertsForHistory");
qgClient.setDefault(qGate.id());
@@ -141,4 +145,8 @@ public class QualityGateUiTest {
orchestrator.executeBuild(scan);
}
+ private static QualityGateClient qgClient() {
+ return orchestrator.getServer().adminWsClient().qualityGateClient();
+ }
+
}