]> source.dussan.org Git - sonarqube.git/commitdiff
Deprecate the utilities replaced by Tester in integration tests
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 23 Jun 2017 14:46:10 +0000 (16:46 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 23 Jun 2017 17:07:48 +0000 (19:07 +0200)
it/it-tests/src/test/java/it/user/OnboardingTest.java
it/it-tests/src/test/java/org/sonarqube/test/Tester.java
it/it-tests/src/test/java/util/ItUtils.java
it/it-tests/src/test/java/util/selenium/Selenese.java
it/it-tests/src/test/java/util/user/GroupManagement.java
it/it-tests/src/test/java/util/user/Groups.java
it/it-tests/src/test/java/util/user/UserRule.java

index ecc26fbe05642979d794f3ee6ee7478a2e25cf51..e0a277a812a70d05b20795b525b504e4f6fda370 100644 (file)
@@ -39,13 +39,10 @@ public class OnboardingTest {
   private static final String ONBOARDING_TUTORIAL_SHOW_TO_NEW_USERS = "sonar.onboardingTutorial.showToNewUsers";
 
   @ClassRule
-  public static final Orchestrator orchestrator = Orchestrator.builderEnv()
-    .build();
+  public static final Orchestrator orchestrator = Orchestrator.builderEnv().build();
 
   @Rule
-  public Tester tester = new Tester(orchestrator)
-    .disableOrganizations()
-    .enableOnBoardingTutorials();
+  public Tester tester = new Tester(orchestrator).disableOrganizations();
 
   @Before
   public void setUp() {
index a5b31a4b00016f274e6d5df649d6dc6dd031c192..9373e82abd9223316f8836834a8e48a133f8eb3b 100644 (file)
@@ -23,19 +23,32 @@ import com.sonar.orchestrator.Orchestrator;
 import javax.annotation.Nullable;
 import org.junit.rules.ExternalResource;
 import org.sonarqube.ws.client.WsClient;
-import org.sonarqube.ws.client.setting.SetRequest;
 import pageobjects.Navigation;
 import util.selenium.Selenese;
 
 import static util.ItUtils.newUserWsClient;
 
+/**
+ * This JUnit rule wraps an {@link Orchestrator} instance and provides :
+ * <ul>
+ *   <li>enabling the organization feature by default</li>
+ *   <li>clean-up of organizations between tests</li>
+ *   <li>clean-up of users between tests</li>
+ *   <li>clean-up of session when opening a browser (cookies, local storage)</li>
+ *   <li>quick access to {@link WsClient} instances</li>
+ *   <li>helpers to generate organizations and users</li>
+ * </ul>
+ *
+ * Recommendation is to define a {@code @Rule} instance. If not possible, then
+ * {@code @ClassRule} must be used through a {@link org.junit.rules.RuleChain}
+ * around {@link Orchestrator}.
+ */
 public class Tester extends ExternalResource implements Session {
 
   private final Orchestrator orchestrator;
 
   // configuration before startup
   private boolean disableOrganizations = false;
-  private boolean enableOnBoardingTutorials = false;
 
   // initialized in #before()
   private boolean beforeCalled = false;
@@ -51,12 +64,6 @@ public class Tester extends ExternalResource implements Session {
     return this;
   }
 
-  public Tester enableOnBoardingTutorials() {
-    verifyNotStarted();
-    enableOnBoardingTutorials = true;
-    return this;
-  }
-
   @Override
   protected void before() {
     verifyNotStarted();
@@ -66,14 +73,6 @@ public class Tester extends ExternalResource implements Session {
       organizations().enableSupport();
     }
 
-    if (!enableOnBoardingTutorials) {
-      rootSession.wsClient().settings().set(SetRequest.builder()
-        .setKey("sonar.onboardingTutorial.showToNewUsers")
-        .setValue("false")
-        .build());
-      rootSession.wsClient().users().skipOnboardingTutorial();
-    }
-
     beforeCalled = true;
   }
 
index e5281dd88b54a58454b2fe88a53826ee98924999..a8e5ee495e0ad9f7fe29284b8c1655cf75e5bb8c 100644 (file)
@@ -61,6 +61,7 @@ import org.junit.Assert;
 import org.sonar.wsclient.issue.Issue;
 import org.sonar.wsclient.issue.IssueClient;
 import org.sonar.wsclient.issue.IssueQuery;
+import org.sonarqube.test.Tester;
 import org.sonarqube.ws.WsComponents.Component;
 import org.sonarqube.ws.WsMeasures;
 import org.sonarqube.ws.WsMeasures.Measure;
@@ -100,14 +101,26 @@ public class ItUtils {
     return issueClient.find(IssueQuery.create()).list();
   }
 
+  /**
+   * @deprecated replaced by {@link Tester#wsClient()}
+   */
+  @Deprecated
   public static WsClient newAdminWsClient(Orchestrator orchestrator) {
     return newUserWsClient(orchestrator, ADMIN_LOGIN, ADMIN_PASSWORD);
   }
 
+  /**
+   * @deprecated replaced by {@link Tester#wsClient()}
+   */
+  @Deprecated
   public static WsClient newWsClient(Orchestrator orchestrator) {
     return newUserWsClient(orchestrator, null, null);
   }
 
+  /**
+   * @deprecated replaced by {@link Tester#wsClient()}
+   */
+  @Deprecated
   public static WsClient newUserWsClient(Orchestrator orchestrator, @Nullable String login, @Nullable String password) {
     Server server = orchestrator.getServer();
     return WsClientFactories.getDefault().newClient(HttpConnector.newBuilder()
index 67f0755cacd9c8ce97b6bfc932230939c4a0f4cd..4e01674e59bb4462613984da076b5885277854cf 100644 (file)
@@ -23,10 +23,13 @@ import com.sonar.orchestrator.Orchestrator;
 import java.io.File;
 import javax.annotation.Nullable;
 import org.apache.commons.io.FileUtils;
+import org.sonarqube.test.Tester;
 
 /**
  * Selenium HTML tests, generally written with Selenium IDE
+ * @deprecated replaced by {@link Tester}
  */
+@Deprecated
 public final class Selenese {
 
   private File[] htmlTests;
@@ -39,6 +42,10 @@ public final class Selenese {
     return htmlTests;
   }
 
+  /**
+   * @deprecated replaced by {@link Tester#runHtmlTests(String...)}
+   */
+  @Deprecated
   public static void runSelenese(Orchestrator orchestrator, String... htmlFiles) {
     Selenese selenese = new Builder()
       .setHtmlTests(htmlFiles)
index 8ff4d6046a1eb11671e48f5630f3a5c5d925318c..17d526456f23153e29c4496ee99eb1f735a311b6 100644 (file)
@@ -23,6 +23,10 @@ import java.util.List;
 import java.util.Optional;
 import javax.annotation.Nullable;
 
+/**
+ * @deprecated replaced by {@link org.sonarqube.test.Tester}
+ */
+@Deprecated
 public interface GroupManagement {
   void createGroup(String name);
 
index d2834fb63dab1e82051df59a8454cca2dfc43d47..5856352a44718b97b580b1cddcea6a0fe2737c94 100644 (file)
@@ -22,6 +22,11 @@ package util.user;
 import com.google.gson.Gson;
 import java.util.List;
 
+/**
+ * @deprecated replaced by {@link org.sonarqube.test.Tester}
+ */
+@Deprecated
+
 public class Groups {
 
   private List<Group> groups;
index 36beb068231ee8be06ceebe8f72847b2feeb8913..96f67c4a879bcedf6db45e33bde1474745c4e0c3 100644 (file)
@@ -50,6 +50,10 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.guava.api.Assertions.assertThat;
 import static util.ItUtils.newAdminWsClient;
 
+/**
+ * @deprecated replaced by {@link org.sonarqube.test.Tester}
+ */
+@Deprecated
 public class UserRule extends ExternalResource implements GroupManagement {
 
   public static final String ADMIN_LOGIN = "admin";