@@ -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() { |
@@ -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; | |||
} | |||
@@ -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() |
@@ -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) |
@@ -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); | |||
@@ -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; |
@@ -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"; |