As they were not restoring default quality gate, following IT ProjectOverviewTest was failing
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;
public class QualityGateNotificationTest {
+ private static long DEFAULT_QUALITY_GATE;
+
private static final String PROJECT_KEY = "sample";
@ClassRule
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
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;
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;
@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
@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
*/
@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());
orchestrator.executeBuild(scan);
}
+ private static QualityGateClient qgClient() {
+ return orchestrator.getServer().adminWsClient().qualityGateClient();
+ }
+
}