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() {
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;
return this;
}
- public Tester enableOnBoardingTutorials() {
- verifyNotStarted();
- enableOnBoardingTutorials = true;
- return this;
- }
-
@Override
protected void before() {
verifyNotStarted();
organizations().enableSupport();
}
- if (!enableOnBoardingTutorials) {
- rootSession.wsClient().settings().set(SetRequest.builder()
- .setKey("sonar.onboardingTutorial.showToNewUsers")
- .setValue("false")
- .build());
- rootSession.wsClient().users().skipOnboardingTutorial();
- }
-
beforeCalled = true;
}
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;
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()
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;
return htmlTests;
}
+ /**
+ * @deprecated replaced by {@link Tester#runHtmlTests(String...)}
+ */
+ @Deprecated
public static void runSelenese(Orchestrator orchestrator, String... htmlFiles) {
Selenese selenese = new Builder()
.setHtmlTests(htmlFiles)
import java.util.Optional;
import javax.annotation.Nullable;
+/**
+ * @deprecated replaced by {@link org.sonarqube.test.Tester}
+ */
+@Deprecated
public interface GroupManagement {
void createGroup(String name);
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;
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";