]> source.dussan.org Git - sonarqube.git/commitdiff
Move helpers to sonar-qa-util
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 9 Nov 2017 16:39:52 +0000 (17:39 +0100)
committerEric Hartmann <hartmann.eric@gmail.Com>
Tue, 14 Nov 2017 12:10:17 +0000 (13:10 +0100)
121 files changed:
server/sonar-qa-util/pom.xml
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Elasticsearch.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/GroupTester.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/LogsTailer.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/OrganizationTester.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/ProjectTester.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QGateTester.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SettingTester.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/TesterSession.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTaskItem.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/LoginPage.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/MarketplacePage.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/NotificationsPage.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectActivityPage.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectDashboardPage.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectKeyPage.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPageItem.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/IssuesPage.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/package-info.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasuresPage.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/package-info.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MemberItem.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MembersPage.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/package-info.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectsPage.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/package-info.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/package-info.java [new file with mode: 0644]
tests/src/test/java/org/sonarqube/tests/Elasticsearch.java [deleted file]
tests/src/test/java/org/sonarqube/tests/GroupTester.java [deleted file]
tests/src/test/java/org/sonarqube/tests/LogsTailer.java [deleted file]
tests/src/test/java/org/sonarqube/tests/OrganizationTester.java [deleted file]
tests/src/test/java/org/sonarqube/tests/ProjectTester.java [deleted file]
tests/src/test/java/org/sonarqube/tests/QGateTester.java [deleted file]
tests/src/test/java/org/sonarqube/tests/QProfileTester.java [deleted file]
tests/src/test/java/org/sonarqube/tests/Session.java [deleted file]
tests/src/test/java/org/sonarqube/tests/SettingTester.java [deleted file]
tests/src/test/java/org/sonarqube/tests/Tester.java [deleted file]
tests/src/test/java/org/sonarqube/tests/UserTester.java [deleted file]
tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java
tests/src/test/java/org/sonarqube/tests/analysis/RedirectTest.java
tests/src/test/java/org/sonarqube/tests/authorisation/PermissionTemplateTest.java
tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java
tests/src/test/java/org/sonarqube/tests/authorisation/SystemPasscodeTest.java
tests/src/test/java/org/sonarqube/tests/branch/BranchTest.java
tests/src/test/java/org/sonarqube/tests/ce/CeShutdownTest.java
tests/src/test/java/org/sonarqube/tests/ce/ReportFailureNotificationTest.java
tests/src/test/java/org/sonarqube/tests/dbCleaner/PurgeTest.java
tests/src/test/java/org/sonarqube/tests/issue/IssueCreationDatePluginChangedTest.java
tests/src/test/java/org/sonarqube/tests/issue/IssueNotificationsTest.java
tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java
tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java
tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssuesPageTest.java
tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java
tests/src/test/java/org/sonarqube/tests/measure/ProjectMeasuresPageTest.java
tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java
tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipTest.java
tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipUiTest.java
tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java
tests/src/test/java/org/sonarqube/tests/organization/PersonalOrganizationTest.java
tests/src/test/java/org/sonarqube/tests/organization/RootUserOnOrganizationTest.java
tests/src/test/java/org/sonarqube/tests/organization/RootUserTest.java
tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectAdministrationTest.java
tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectBulkDeleteTest.java
tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectBulkDeletionPageTest.java
tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectDeleteTest.java
tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectKeyUpdateTest.java
tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectProvisioningTest.java
tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectQualityGatePageTest.java
tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectSearchTest.java
tests/src/test/java/org/sonarqube/tests/projectSearch/LeakProjectsPageTest.java
tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java
tests/src/test/java/org/sonarqube/tests/projectSearch/SearchProjectsTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/OrganizationQualityGateUiTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateForSmallChangesetsTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateNotificationTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateOnRatingMeasuresTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateUiTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateWithOrganizationsTest.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesTest.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesEditTest.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java
tests/src/test/java/org/sonarqube/tests/rule/RuleEsResilienceTest.java
tests/src/test/java/org/sonarqube/tests/rule/RuleTagsTest.java
tests/src/test/java/org/sonarqube/tests/rule/RulesPageTest.java
tests/src/test/java/org/sonarqube/tests/rule/RulesWsTest.java
tests/src/test/java/org/sonarqube/tests/serverSystem/ServerSystemTest.java
tests/src/test/java/org/sonarqube/tests/serverSystem/SystemInfoTest.java
tests/src/test/java/org/sonarqube/tests/serverSystem/SystemStateTest.java
tests/src/test/java/org/sonarqube/tests/settings/EmailsTest.java
tests/src/test/java/org/sonarqube/tests/sourceCode/EncodingTest.java
tests/src/test/java/org/sonarqube/tests/sourceCode/HighlightingTest.java
tests/src/test/java/org/sonarqube/tests/sourceCode/ProjectCodeTest.java
tests/src/test/java/org/sonarqube/tests/startup/StartupIndexationTest.java
tests/src/test/java/org/sonarqube/tests/telemetry/TelemetryOptOutTest.java
tests/src/test/java/org/sonarqube/tests/test/CoverageTest.java
tests/src/test/java/org/sonarqube/tests/test/CoverageTrackingTest.java
tests/src/test/java/org/sonarqube/tests/ui/OrganizationUiExtensionsTest.java
tests/src/test/java/org/sonarqube/tests/ui/UiExtensionsTest.java
tests/src/test/java/org/sonarqube/tests/user/ForceAuthenticationTest.java
tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java
tests/src/test/java/org/sonarqube/tests/user/MyAccountPageTest.java
tests/src/test/java/org/sonarqube/tests/user/OAuth2IdentityProviderTest.java
tests/src/test/java/org/sonarqube/tests/user/OnboardingTest.java
tests/src/test/java/org/sonarqube/tests/user/OrganizationIdentityProviderTest.java
tests/src/test/java/org/sonarqube/tests/user/RealmAuthenticationTest.java
tests/src/test/java/org/sonarqube/tests/user/UserEsResilienceTest.java
tests/src/test/java/util/ItUtils.java
tests/src/test/java/util/selenium/Selenese.java
tests/src/test/java/util/user/GroupManagement.java
tests/src/test/java/util/user/Groups.java
tests/src/test/java/util/user/UserRule.java

index a9534332a895eb9971e82ccbb76353cff7f470c2..4f5911163bd2af9f8f6f52242d024eb75197adee 100644 (file)
   </properties>
 
   <dependencies>
+    <dependency>
+      <groupId>org.sonarsource.sonarqube</groupId>
+      <artifactId>sonar-ws</artifactId>
+      <version>${project.version}</version>
+    </dependency>
     <dependency>
       <groupId>com.codeborne</groupId>
       <artifactId>selenide</artifactId>
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Elasticsearch.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Elasticsearch.java
new file mode 100644 (file)
index 0000000..434044c
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.qa.util;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Helper to directly access Elasticsearch. It requires the HTTP port
+ * to be open.
+ */
+public class Elasticsearch {
+
+  private final int httpPort;
+
+  public Elasticsearch(int httpPort) {
+    this.httpPort = httpPort;
+  }
+
+  /**
+   * Forbid indexing requests on the specified index. Index becomes read-only.
+   */
+  public void lockWrites(String index) throws IOException {
+    putIndexSetting(httpPort, index, "blocks.write", "true");
+  }
+
+  /**
+   * Enable indexing requests on the specified index.
+   * @see #lockWrites(String)
+   */
+  public void unlockWrites(String index) throws IOException {
+    putIndexSetting(httpPort, index, "blocks.write", "false");
+  }
+
+  public void makeYellow() throws IOException {
+    putIndexSetting(httpPort, "issues", "number_of_replicas", "5");
+  }
+
+  public void makeGreen() throws IOException {
+    putIndexSetting(httpPort, "issues", "number_of_replicas", "0");
+  }
+
+  private static void putIndexSetting(int searchHttpPort, String index, String key, String value) throws IOException {
+    Request.Builder request = new Request.Builder()
+      .url(baseUrl(searchHttpPort) + index + "/_settings")
+      .put(RequestBody.create(MediaType.parse("application/json"), "{" +
+        "    \"index\" : {" +
+        "        \"" + key + "\" : \"" + value + "\"" +
+        "    }" +
+        "}"));
+    OkHttpClient okClient = new OkHttpClient.Builder().build();
+    Response response = okClient.newCall(request.build()).execute();
+    assertThat(response.isSuccessful()).isTrue();
+  }
+
+  private static String baseUrl(int searchHttpPort) {
+    return "http://" + InetAddress.getLoopbackAddress().getHostAddress() + ":" + searchHttpPort + "/";
+  }
+}
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/GroupTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/GroupTester.java
new file mode 100644 (file)
index 0000000..8b395c9
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.qa.util;
+
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+import javax.annotation.Nullable;
+import org.sonarqube.ws.Organizations;
+import org.sonarqube.ws.WsUserGroups;
+import org.sonarqube.ws.WsUsers;
+import org.sonarqube.ws.WsUsers.GroupsWsResponse.Group;
+import org.sonarqube.ws.client.user.GroupsRequest;
+import org.sonarqube.ws.client.usergroup.AddUserWsRequest;
+import org.sonarqube.ws.client.usergroup.CreateWsRequest;
+
+import static java.util.Arrays.stream;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class GroupTester {
+
+  private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
+
+  private final TesterSession session;
+
+  GroupTester(TesterSession session) {
+    this.session = session;
+  }
+
+  @SafeVarargs
+  public final WsUserGroups.Group generate(@Nullable Organizations.Organization organization, Consumer<CreateWsRequest.Builder>... populators) {
+    int id = ID_GENERATOR.getAndIncrement();
+    CreateWsRequest.Builder request = CreateWsRequest.builder()
+      .setName("Group" + id)
+      .setDescription("Description " + id)
+      .setOrganization(organization != null ? organization.getKey() : null);
+    stream(populators).forEach(p -> p.accept(request));
+    return session.wsClient().userGroups().create(request.build()).getGroup();
+  }
+
+  public List<Group> getGroupsOfUser(@Nullable Organizations.Organization organization, String userLogin) {
+    GroupsRequest request = GroupsRequest.builder()
+      .setOrganization(organization != null ? organization.getKey() : null)
+      .setLogin(userLogin)
+      .build();
+    WsUsers.GroupsWsResponse response = session.users().service().groups(request);
+    return response.getGroupsList();
+  }
+
+  public GroupTester addMemberToGroups(Organizations.Organization organization, String userLogin, String... groups) {
+    for (String group : groups) {
+      AddUserWsRequest request = AddUserWsRequest.builder()
+        .setLogin(userLogin)
+        .setOrganization(organization.getKey())
+        .setName(group)
+        .build();
+      session.wsClient().userGroups().addUser(request);
+    }
+    return this;
+  }
+
+  public GroupTester assertThatUserIsMemberOf(@Nullable Organizations.Organization organization, String userLogin, String expectedGroup, String... otherExpectedGroups) {
+    List<String> groups = getGroupsOfUser(organization, userLogin)
+      .stream()
+      .map(Group::getName)
+      .collect(Collectors.toList());
+
+    assertThat(groups).contains(expectedGroup);
+    if (otherExpectedGroups.length > 0) {
+      assertThat(groups).contains(otherExpectedGroups);
+    }
+    return this;
+  }
+
+  public GroupTester assertThatUserIsOnlyMemberOf(@Nullable Organizations.Organization organization, String userLogin, String... expectedGroups) {
+    Set<String> groups = getGroupsOfUser(organization, userLogin)
+      .stream()
+      .map(Group::getName)
+      .collect(Collectors.toSet());
+    assertThat(groups).containsExactlyInAnyOrder(expectedGroups);
+    return this;
+  }
+}
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/LogsTailer.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/LogsTailer.java
new file mode 100644 (file)
index 0000000..a172b56
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.qa.util;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Consumer;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import org.apache.commons.io.input.Tailer;
+import org.apache.commons.io.input.TailerListenerAdapter;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Watch log files, usually server logs (see Orchestrator.getServer().get*Logs()).
+ * This class allows to not load the full content in memory.
+ */
+public class LogsTailer implements AutoCloseable {
+
+  private final List<Tailer> tailers;
+  private final LogConsumer logConsumer;
+
+  private LogsTailer(Builder builder) {
+    logConsumer = new LogConsumer(builder.consumers);
+    tailers = builder.files.stream()
+      .map(file -> Tailer.create(file, logConsumer, 500))
+      .collect(Collectors.toList());
+  }
+
+  public Watch watch(String text) {
+    return new Watch(text);
+  }
+
+  @Override
+  public void close() {
+    for (Tailer tailer : tailers) {
+      tailer.stop();
+    }
+  }
+
+  public static Builder builder() {
+    return new Builder();
+  }
+
+  public static class Builder {
+    private final List<File> files = new ArrayList<>();
+    private final List<Consumer<String>> consumers = new ArrayList<>();
+
+    public Builder addFile(File file) {
+      this.files.add(file);
+      return this;
+    }
+
+    public Builder addFiles(File file, File... otherFiles) {
+      this.files.add(file);
+      Collections.addAll(this.files, otherFiles);
+      return this;
+    }
+
+    /**
+     * Adds a consumer that is called on each new line appended
+     * to the files.
+     * Note that the consumer {@link Content} allows to keep
+     * all past logs in memory.
+     */
+    public Builder addConsumer(Consumer<String> consumer) {
+      this.consumers.add(consumer);
+      return this;
+    }
+
+    public LogsTailer build() {
+      return new LogsTailer(this);
+    }
+  }
+
+  private static class LogConsumer extends TailerListenerAdapter {
+    private final List<Consumer<String>> consumers = Collections.synchronizedList(new ArrayList<>());
+
+    private LogConsumer(List<Consumer<String>> consumers) {
+      this.consumers.addAll(consumers);
+    }
+
+    @Override
+    public void handle(String line) {
+      synchronized (consumers) {
+        for (Consumer<String> consumer : consumers) {
+          try {
+            consumer.accept(line);
+          } catch (Exception e) {
+            // do not prevent other consumers to handle the log
+            e.printStackTrace();
+          }
+        }
+      }
+    }
+
+    public void add(Consumer<String> consumer) {
+      this.consumers.add(consumer);
+    }
+
+    public void remove(Consumer<String> consumer) {
+      this.consumers.remove(consumer);
+    }
+  }
+
+  public class Watch implements AutoCloseable {
+    private final String expectedText;
+    private final CountDownLatch foundSignal = new CountDownLatch(1);
+    private String log = null;
+    private final Consumer<String> consumer;
+
+    private Watch(String expectedText) {
+      this.expectedText = requireNonNull(expectedText);
+      this.consumer = l -> {
+        if (l.contains(this.expectedText)) {
+          this.log = l;
+          foundSignal.countDown();
+        }
+      };
+      logConsumer.add(consumer);
+    }
+
+    /**
+     * Blocks until the expected log appears in watched files.
+     */
+    public void waitForLog() throws InterruptedException {
+      foundSignal.await();
+    }
+
+    /**
+     * Blocks until the expected log appears in watched files with timeout
+     */
+    public void waitForLog(long timeout, TimeUnit timeUnit) throws InterruptedException {
+      foundSignal.await(timeout, timeUnit);
+    }
+
+    public Optional<String> getLog() {
+      return Optional.ofNullable(log);
+    }
+
+    @Override
+    public void close() {
+      logConsumer.remove(consumer);
+    }
+  }
+
+  public static class Content implements Consumer<String> {
+    private final List<String> lines = Collections.synchronizedList(new ArrayList<>());
+
+    @Override
+    public void accept(String s) {
+      lines.add(s);
+    }
+
+    public boolean hasText(String text) {
+      synchronized (lines) {
+        for (String line : lines) {
+          if (line.contains(text)) {
+            return true;
+          }
+        }
+      }
+      return false;
+    }
+
+    public boolean hasLineMatching(Pattern pattern) {
+      synchronized (lines) {
+        for (String line : lines) {
+          if (pattern.matcher(line).matches()) {
+            return true;
+          }
+        }
+      }
+      return false;
+    }
+  }
+}
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/OrganizationTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/OrganizationTester.java
new file mode 100644 (file)
index 0000000..a9d098e
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.qa.util;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+import javax.annotation.Nullable;
+import org.assertj.core.api.Assertions;
+import org.sonarqube.ws.Organizations;
+import org.sonarqube.ws.WsUsers;
+import org.sonarqube.ws.client.HttpException;
+import org.sonarqube.ws.client.PostRequest;
+import org.sonarqube.ws.client.organization.CreateWsRequest;
+import org.sonarqube.ws.client.organization.OrganizationService;
+import org.sonarqube.ws.client.organization.SearchMembersWsRequest;
+import org.sonarqube.ws.client.organization.SearchWsRequest;
+import org.sonarqube.ws.client.user.GroupsRequest;
+
+import static java.util.Arrays.stream;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class OrganizationTester {
+
+  private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
+
+  private final TesterSession session;
+
+  OrganizationTester(TesterSession session) {
+    this.session = session;
+  }
+
+  void enableSupport() {
+    session.wsClient().wsConnector().call(new PostRequest("api/organizations/enable_support"));
+  }
+
+  void deleteNonGuardedOrganizations() {
+    service().search(SearchWsRequest.builder().build()).getOrganizationsList()
+      .stream()
+      .filter(o -> !o.getKey().equals("default-organization"))
+      .forEach(organization -> service().delete(organization.getKey()));
+  }
+
+  @SafeVarargs
+  public final Organizations.Organization generate(Consumer<CreateWsRequest.Builder>... populators) {
+    int id = ID_GENERATOR.getAndIncrement();
+    CreateWsRequest.Builder request = new CreateWsRequest.Builder()
+      .setKey("org" + id)
+      .setName("Org " + id)
+      .setDescription("Description " + id)
+      .setUrl("http://test" + id);
+    stream(populators).forEach(p -> p.accept(request));
+    return service().create(request.build()).getOrganization();
+  }
+
+  public OrganizationTester addMember(Organizations.Organization organization, WsUsers.CreateWsResponse.User user) {
+    service().addMember(organization.getKey(), user.getLogin());
+    return this;
+  }
+
+  public Organizations.Organization getDefaultOrganization() {
+    return service().search(SearchWsRequest.builder().build()).getOrganizationsList()
+      .stream()
+      .filter(o -> o.getKey().equals("default-organization"))
+      .findFirst().orElseThrow(() -> new IllegalStateException("Can't find default organization"));
+  }
+
+  public OrganizationTester assertThatOrganizationDoesNotExist(String organizationKey) {
+    SearchWsRequest request = new SearchWsRequest.Builder().setOrganizations(organizationKey).build();
+    Organizations.SearchWsResponse searchWsResponse = service().search(request);
+    Assertions.assertThat(searchWsResponse.getOrganizationsList()).isEmpty();
+    return this;
+  }
+
+  public OrganizationTester assertThatMemberOf(Organizations.Organization organization, WsUsers.CreateWsResponse.User user) {
+    return assertThatMemberOf(organization, user.getLogin());
+  }
+
+  public OrganizationTester assertThatMemberOf(Organizations.Organization organization, String userLogin) {
+    verifyOrganizationMembership(organization, userLogin, true);
+    verifyMembersGroupMembership(userLogin, organization, true);
+    return this;
+  }
+
+  public OrganizationTester assertThatNotMemberOf(Organizations.Organization organization, WsUsers.CreateWsResponse.User user) {
+    return assertThatNotMemberOf(organization, user.getLogin());
+  }
+
+  public OrganizationTester assertThatNotMemberOf(Organizations.Organization organization, String userLogin) {
+    verifyOrganizationMembership(organization, userLogin, false);
+    try {
+      verifyMembersGroupMembership(userLogin, organization, false);
+    } catch (HttpException e) {
+      // do not fail if user does not exist
+      if (e.code() != 404) {
+        throw e;
+      }
+    }
+    return this;
+  }
+
+  private void verifyOrganizationMembership(@Nullable Organizations.Organization organization, String userLogin, boolean isMember) {
+    List<Organizations.User> users = service().searchMembers(new SearchMembersWsRequest()
+      .setQuery(userLogin)
+      .setSelected("selected")
+      .setOrganization(organization != null ? organization.getKey() : null))
+      .getUsersList();
+    Assertions.assertThat(users).hasSize(isMember ? 1 : 0);
+  }
+
+  private void verifyMembersGroupMembership(String userLogin, @Nullable Organizations.Organization organization, boolean isMember) {
+    List<WsUsers.GroupsWsResponse.Group> groups = session.wsClient().users().groups(GroupsRequest.builder()
+      .setLogin(userLogin)
+      .setOrganization(organization != null ? organization.getKey() : null)
+      .setQuery("Members")
+      .setSelected("selected")
+      .build())
+      .getGroupsList();
+    Assertions.assertThat(groups).hasSize(isMember ? 1 : 0);
+  }
+
+  public OrganizationService service() {
+    return session.wsClient().organizations();
+  }
+}
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/ProjectTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/ProjectTester.java
new file mode 100644 (file)
index 0000000..6b63e85
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.qa.util;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+import javax.annotation.Nullable;
+import org.sonarqube.ws.Organizations;
+import org.sonarqube.ws.WsProjects;
+import org.sonarqube.ws.client.project.CreateRequest;
+import org.sonarqube.ws.client.project.DeleteRequest;
+import org.sonarqube.ws.client.project.ProjectsService;
+import org.sonarqube.ws.client.project.SearchWsRequest;
+
+import static java.util.Arrays.stream;
+import static java.util.Collections.singletonList;
+
+public class ProjectTester {
+
+  private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
+
+  private final TesterSession session;
+
+  ProjectTester(TesterSession session) {
+    this.session = session;
+  }
+
+  void deleteAll() {
+    ProjectsService service = session.wsClient().projects();
+    service.search(SearchWsRequest.builder().setQualifiers(singletonList("TRK")).build()).getComponentsList().forEach(p ->
+      service.delete(DeleteRequest.builder().setKey(p.getKey()).build()));
+  }
+
+  @SafeVarargs
+  public final WsProjects.CreateWsResponse.Project generate(@Nullable Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) {
+    int id = ID_GENERATOR.getAndIncrement();
+    CreateRequest.Builder request = CreateRequest.builder()
+      .setKey("key" + id)
+      .setName("Name " + id)
+      .setOrganization(organization != null ? organization.getKey() : null);
+    stream(populators).forEach(p -> p.accept(request));
+
+    return session.wsClient().projects().create(request.build()).getProject();
+  }
+}
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QGateTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QGateTester.java
new file mode 100644 (file)
index 0000000..e0a1f8b
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.qa.util;
+
+import com.google.gson.Gson;
+import com.google.gson.annotations.SerializedName;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.sonarqube.ws.WsProjects.CreateWsResponse.Project;
+import org.sonarqube.ws.WsQualityGates.CreateWsResponse;
+import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.PostRequest;
+import org.sonarqube.ws.client.qualitygate.QualityGatesService;
+import org.sonarqube.ws.client.qualitygate.SelectWsRequest;
+
+public class QGateTester {
+  private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
+
+  private final TesterSession session;
+
+  QGateTester(TesterSession session) {
+    this.session = session;
+  }
+
+  public QualityGatesService service() {
+    return session.wsClient().qualityGates();
+  }
+
+  void deleteAll() {
+    String json = session.wsClient().wsConnector().call(new GetRequest("api/qualitygates/list")).failIfNotSuccessful().content();
+    ListResponse response = ListResponse.parse(json);
+    response.getQualityGates().stream()
+      .filter(qualityGate -> !qualityGate.getId().equals(response.getDefault()))
+      .forEach(qualityGate -> session.wsClient().wsConnector().call(new PostRequest("api/qualitygates/destroy").setParam("id", qualityGate.getId())).failIfNotSuccessful());
+  }
+
+  public CreateWsResponse generate() {
+    int id = ID_GENERATOR.getAndIncrement();
+    return session.wsClient().qualityGates().create("QualityGate" + id);
+  }
+
+  public void associateProject(CreateWsResponse qualityGate, Project project){
+    service().associateProject(new SelectWsRequest().setGateId(qualityGate.getId()).setProjectKey(project.getKey()));
+  }
+
+  public static class ListResponse {
+
+    @SerializedName("default")
+    private final String defaultQGate;
+    @SerializedName("qualitygates")
+    private final List<QGate> qualityGates = new ArrayList<>();
+
+    public ListResponse(String defaultQGate) {
+      this.defaultQGate = defaultQGate;
+    }
+
+    public List<QGate> getQualityGates() {
+      return qualityGates;
+    }
+
+    public String getDefault() {
+      return defaultQGate;
+    }
+
+    public static ListResponse parse(String json) {
+      Gson gson = new Gson();
+      return gson.fromJson(json, ListResponse.class);
+    }
+
+    public static class QGate {
+      @SerializedName("id")
+      private final String id;
+      @SerializedName("name")
+      private final String name;
+
+      public QGate(String id, String name) {
+        this.id = id;
+        this.name = name;
+      }
+
+      public String getId() {
+        return id;
+      }
+
+      public String getName() {
+        return name;
+      }
+    }
+  }
+}
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java
new file mode 100644 (file)
index 0000000..2c80d28
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.qa.util;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+import org.assertj.core.api.Assertions;
+import org.sonarqube.ws.Common;
+import org.sonarqube.ws.Organizations.Organization;
+import org.sonarqube.ws.QualityProfiles.CreateWsResponse.QualityProfile;
+import org.sonarqube.ws.Rules;
+import org.sonarqube.ws.WsProjects.CreateWsResponse.Project;
+import org.sonarqube.ws.client.HttpException;
+import org.sonarqube.ws.client.qualityprofile.ActivateRuleWsRequest;
+import org.sonarqube.ws.client.qualityprofile.AddProjectRequest;
+import org.sonarqube.ws.client.qualityprofile.CreateRequest;
+import org.sonarqube.ws.client.qualityprofile.QualityProfilesService;
+import org.sonarqube.ws.client.rule.SearchWsRequest;
+
+import static java.util.Arrays.asList;
+import static java.util.Arrays.stream;
+import static java.util.Collections.singletonList;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class QProfileTester {
+  private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
+
+  private final TesterSession session;
+
+  QProfileTester(TesterSession session) {
+    this.session = session;
+  }
+
+  public QualityProfilesService service() {
+    return session.wsClient().qualityProfiles();
+  }
+
+  @SafeVarargs
+  public final QualityProfile createXooProfile(Organization organization, Consumer<CreateRequest.Builder>... populators) {
+    int id = ID_GENERATOR.getAndIncrement();
+    CreateRequest.Builder request = CreateRequest.builder()
+      .setOrganizationKey(organization.getKey())
+      .setLanguage("xoo")
+      .setName("Profile" + id);
+    stream(populators).forEach(p -> p.accept(request));
+    return service().create(request.build()).getProfile();
+  }
+
+  public QProfileTester activateRule(QualityProfile profile, String ruleKey) {
+    return activateRule(profile.getKey(), ruleKey);
+  }
+
+  public QProfileTester activateRule(String profileKey, String ruleKey) {
+    ActivateRuleWsRequest request = ActivateRuleWsRequest.builder()
+      .setKey(profileKey)
+      .setRuleKey(ruleKey)
+      .build();
+    service().activateRule(request);
+    return this;
+  }
+
+  public QProfileTester deactivateRule(QualityProfile profile, String ruleKey) {
+    service().deactivateRule(profile.getKey(), ruleKey);
+    return this;
+  }
+
+  public QProfileTester assignQProfileToProject(QualityProfile profile, Project project) {
+    service().addProject(AddProjectRequest.builder()
+      .setProjectKey(project.getKey())
+      .setKey(profile.getKey())
+      .build());
+    return this;
+  }
+
+  public QProfileTester assertThatNumberOfActiveRulesEqualsTo(QualityProfile profile, int expectedActiveRules) {
+    return assertThatNumberOfActiveRulesEqualsTo(profile.getKey(), expectedActiveRules);
+  }
+
+  public QProfileTester assertThatNumberOfActiveRulesEqualsTo(String profileKey, int expectedActiveRules) {
+    try {
+      List<String> facetIds = asList("active_severities", "repositories", "languages", "severities", "statuses", "types");
+      SearchWsRequest request = new SearchWsRequest()
+        .setQProfile(profileKey)
+        .setActivation(true)
+        .setFacets(facetIds)
+        .setFields(singletonList("actives"));
+      Rules.SearchResponse response = session.wsClient().rules().search(request);
+
+      // assume that expectedActiveRules fits in first page of results
+      Assertions.assertThat(response.getRulesCount()).isEqualTo(expectedActiveRules);
+      Assertions.assertThat(response.getTotal()).isEqualTo(expectedActiveRules);
+      Assertions.assertThat(response.getActives().getActives()).as(response.toString()).hasSize(expectedActiveRules);
+
+      // verify facets
+      Assertions.assertThat(response.getFacets().getFacetsCount()).isEqualTo(facetIds.size());
+      response.getFacets().getFacetsList().forEach(facet -> {
+        long total = facet.getValuesList().stream()
+          .mapToLong(Common.FacetValue::getCount)
+          .sum();
+        assertThat(total).as("Facet " + facet.getProperty()).isEqualTo((long) expectedActiveRules);
+      });
+    } catch (HttpException e) {
+      if (expectedActiveRules == 0 && e.code() == 404) {
+        // profile does not exist, do nothing
+        return this;
+      }
+      throw e;
+    }
+    return this;
+  }
+}
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SettingTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SettingTester.java
new file mode 100644 (file)
index 0000000..00c08c1
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.qa.util;
+
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.annotation.Nullable;
+import org.sonarqube.ws.Settings;
+import org.sonarqube.ws.client.setting.ListDefinitionsRequest;
+import org.sonarqube.ws.client.setting.ResetRequest;
+import org.sonarqube.ws.client.setting.SetRequest;
+import org.sonarqube.ws.client.setting.SettingsService;
+
+public class SettingTester {
+
+  private static final Set<String> EMAIL_SETTINGS = ImmutableSet.of("email.smtp_host.secured", "email.smtp_port.secured", "email.smtp_secure_connection.secured",
+    "email.smtp_username.secured", "email.smtp_password.secured", "email.from", "email.prefix");
+
+  private final TesterSession session;
+
+  SettingTester(TesterSession session) {
+    this.session = session;
+  }
+
+  public SettingsService service() {
+    return session.wsClient().settings();
+  }
+
+  void deleteAll() {
+    List<String> settingKeys = Stream.concat(
+      session.wsClient().settings().listDefinitions(ListDefinitionsRequest.builder().build()).getDefinitionsList()
+        .stream()
+        .filter(def -> def.getType() != Settings.Type.LICENSE)
+        .map(Settings.Definition::getKey),
+      EMAIL_SETTINGS.stream())
+      .collect(Collectors.toList());
+    session.wsClient().settings().reset(ResetRequest.builder().setKeys(settingKeys).build());
+  }
+
+  public void resetSettings(String... keys){
+    session.wsClient().settings().reset(ResetRequest.builder().setKeys(keys).build());
+  }
+
+  public void setGlobalSetting(String key, @Nullable String value) {
+    setSetting(null, key, value);
+  }
+
+  public void setGlobalSettings(String... properties) {
+    for (int i = 0; i < properties.length; i += 2) {
+      setSetting(null, properties[i], properties[i + 1]);
+    }
+  }
+
+  public void setProjectSetting(String componentKey, String key, @Nullable String value) {
+    setSetting(componentKey, key, value);
+  }
+
+  public void setProjectSettings(String componentKey, String... properties) {
+    for (int i = 0; i < properties.length; i += 2) {
+      setSetting(componentKey, properties[i], properties[i + 1]);
+    }
+  }
+
+  private void setSetting(@Nullable String componentKey, String key, @Nullable String value) {
+    if (value == null) {
+      session.wsClient().settings().reset(ResetRequest.builder().setKeys(key).setComponent(componentKey).build());
+    } else {
+      session.wsClient().settings().set(SetRequest.builder().setKey(key).setValue(value).setComponent(componentKey).build());
+    }
+  }
+
+}
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java
new file mode 100644 (file)
index 0000000..50412d8
--- /dev/null
@@ -0,0 +1,242 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.qa.util;
+
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.container.Server;
+import javax.annotation.Nullable;
+import org.apache.commons.lang.StringUtils;
+import org.junit.rules.ExternalResource;
+import org.sonarqube.qa.util.pageobjects.Navigation;
+import org.sonarqube.ws.client.HttpConnector;
+import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.ws.client.WsClientFactories;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * 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>
+ * <p>
+ * 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 TesterSession {
+
+  private final Orchestrator orchestrator;
+
+  // configuration before startup
+  private boolean disableOrganizations = false;
+  private Elasticsearch elasticsearch = null;
+
+  // initialized in #before()
+  private boolean beforeCalled = false;
+  private TesterSession rootSession;
+
+  public Tester(Orchestrator orchestrator) {
+    this.orchestrator = orchestrator;
+    String elasticsearchHttpPort = orchestrator.getDistribution().getServerProperty("sonar.search.httpPort");
+    if (StringUtils.isNotBlank(elasticsearchHttpPort)) {
+      this.elasticsearch = new Elasticsearch(Integer.parseInt(elasticsearchHttpPort));
+    }
+  }
+
+  public Tester disableOrganizations() {
+    verifyNotStarted();
+    disableOrganizations = true;
+    return this;
+  }
+
+  /**
+   * Enables Elasticsearch debugging, see {@link #elasticsearch()}.
+   * <p>
+   * The property "sonar.search.httpPort" must be defined before
+   * starting SonarQube server.
+   */
+  public Tester setElasticsearchHttpPort(int port) {
+    verifyNotStarted();
+    elasticsearch = new Elasticsearch(port);
+    return this;
+  }
+
+  @Override
+  public void before() {
+    verifyNotStarted();
+    rootSession = new TesterSessionImpl(orchestrator, "admin", "admin");
+
+    if (!disableOrganizations) {
+      organizations().enableSupport();
+    }
+
+    beforeCalled = true;
+  }
+
+  @Override
+  public void after() {
+    if (!disableOrganizations) {
+      organizations().deleteNonGuardedOrganizations();
+    }
+    users().deleteAll();
+    projects().deleteAll();
+    settings().deleteAll();
+    qGates().deleteAll();
+  }
+
+  public TesterSession asAnonymous() {
+    return as(null, null);
+  }
+
+  public TesterSession as(String login) {
+    return as(login, login);
+  }
+
+  public TesterSession as(String login, String password) {
+    verifyStarted();
+    return new TesterSessionImpl(orchestrator, login, password);
+  }
+
+  public Elasticsearch elasticsearch() {
+    return requireNonNull(elasticsearch, "Elasticsearch HTTP port is not defined. See #setElasticsearchHttpPort()");
+  }
+
+  /**
+   * Open a new browser session. Cookies are deleted.
+   */
+  public Navigation openBrowser() {
+    verifyStarted();
+    return Navigation.create(orchestrator);
+  }
+
+  private void verifyNotStarted() {
+    if (beforeCalled) {
+      throw new IllegalStateException("Orchestrator should not be already started");
+    }
+  }
+
+  private void verifyStarted() {
+    if (!beforeCalled) {
+      throw new IllegalStateException("Orchestrator is not started yet");
+    }
+  }
+
+  /**
+   * Web service client configured with root access
+   */
+  @Override
+  public WsClient wsClient() {
+    verifyStarted();
+    return rootSession.wsClient();
+  }
+
+  @Override
+  public GroupTester groups() {
+    return rootSession.groups();
+  }
+
+  @Override
+  public OrganizationTester organizations() {
+    return rootSession.organizations();
+  }
+
+  @Override
+  public ProjectTester projects() {
+    return rootSession.projects();
+  }
+
+  @Override
+  public QProfileTester qProfiles() {
+    return rootSession.qProfiles();
+  }
+
+  @Override
+  public UserTester users() {
+    return rootSession.users();
+  }
+
+  @Override
+  public SettingTester settings() {
+    return rootSession.settings();
+  }
+
+  @Override
+  public QGateTester qGates() {
+    return rootSession.qGates();
+  }
+
+  private static class TesterSessionImpl implements TesterSession {
+    private final WsClient client;
+
+    private TesterSessionImpl(Orchestrator orchestrator, @Nullable String login, @Nullable String password) {
+      Server server = orchestrator.getServer();
+      this.client = WsClientFactories.getDefault().newClient(HttpConnector.newBuilder()
+        .url(server.getUrl())
+        .credentials(login, password)
+        .build());
+    }
+
+    @Override
+    public WsClient wsClient() {
+      return client;
+    }
+
+    @Override
+    public GroupTester groups() {
+      return new GroupTester(this);
+    }
+
+    @Override
+    public OrganizationTester organizations() {
+      return new OrganizationTester(this);
+    }
+
+    @Override
+    public ProjectTester projects() {
+      return new ProjectTester(this);
+    }
+
+    @Override
+    public QProfileTester qProfiles() {
+      return new QProfileTester(this);
+    }
+
+    @Override
+    public UserTester users() {
+      return new UserTester(this);
+    }
+
+    @Override
+    public SettingTester settings() {
+      return new SettingTester(this);
+    }
+
+    @Override
+    public QGateTester qGates() {
+      return new QGateTester(this);
+    }
+  }
+}
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/TesterSession.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/TesterSession.java
new file mode 100644 (file)
index 0000000..6c2673a
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.qa.util;
+
+import org.sonarqube.ws.client.WsClient;
+
+public interface TesterSession {
+
+  WsClient wsClient();
+
+  GroupTester groups();
+
+  OrganizationTester organizations();
+
+  ProjectTester projects();
+
+  QProfileTester qProfiles();
+
+  UserTester users();
+
+  SettingTester settings();
+
+  QGateTester qGates();
+
+}
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java
new file mode 100644 (file)
index 0000000..5f4f4a9
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonarqube.qa.util;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+import org.sonarqube.ws.Organizations;
+import org.sonarqube.ws.WsUsers;
+import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
+import org.sonarqube.ws.client.PostRequest;
+import org.sonarqube.ws.client.user.CreateRequest;
+import org.sonarqube.ws.client.user.SearchRequest;
+import org.sonarqube.ws.client.user.UsersService;
+import org.sonarqube.ws.client.usergroup.AddUserWsRequest;
+
+import static java.util.Arrays.stream;
+
+public class UserTester {
+
+  private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
+
+  private final TesterSession session;
+
+  UserTester(TesterSession session) {
+    this.session = session;
+  }
+
+  void deleteAll() {
+    session.wsClient().users().search(SearchRequest.builder().build()).getUsersList()
+      .stream()
+      .filter(u -> !"admin".equals(u.getLogin()))
+      .forEach(u -> {
+        PostRequest request = new PostRequest("api/users/deactivate").setParam("login", u.getLogin());
+        session.wsClient().wsConnector().call(request);
+      });
+  }
+
+  @SafeVarargs
+  public final User generate(Consumer<CreateRequest.Builder>... populators) {
+    int id = ID_GENERATOR.getAndIncrement();
+    String login = "login" + id;
+    CreateRequest.Builder request = CreateRequest.builder()
+      .setLogin(login)
+      .setPassword(login)
+      .setName("name" + id)
+      .setEmail(id + "@test.com");
+    stream(populators).forEach(p -> p.accept(request));
+    return service().create(request.build()).getUser();
+  }
+
+  @SafeVarargs
+  public final User generateAdministrator(Consumer<CreateRequest.Builder>... populators) {
+    User user = generate(populators);
+    session.wsClient().permissions().addUser(new org.sonarqube.ws.client.permission.AddUserWsRequest().setLogin(user.getLogin()).setPermission("admin"));
+    session.wsClient().userGroups().addUser(AddUserWsRequest.builder().setLogin(user.getLogin()).setName("sonar-administrators").build());
+    return user;
+  }
+
+  @SafeVarargs
+  public final User generateAdministrator(Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) {
+    User user = generate(populators);
+    session.wsClient().organizations().addMember(organization.getKey(), user.getLogin());
+    session.wsClient().userGroups().addUser(AddUserWsRequest.builder()
+      .setOrganization(organization.getKey())
+      .setLogin(user.getLogin())
+      .setName("Owners")
+      .build());
+    return user;
+  }
+
+  @SafeVarargs
+  public final User generateMember(Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) {
+    User user = generate(populators);
+    session.wsClient().organizations().addMember(organization.getKey(), user.getLogin());
+    return user;
+  }
+
+  public UsersService service() {
+    return session.wsClient().users();
+  }
+
+  public Optional<WsUsers.SearchWsResponse.User> getByLogin(String login) {
+    List<WsUsers.SearchWsResponse.User> users = session.wsClient().users().search(SearchRequest.builder().setQuery(login).build()).getUsersList();
+    if (users.size() == 1) {
+      return Optional.of(users.get(0));
+    }
+    return Optional.empty();
+  }
+}
index 0c86d3293b1c22d4d7cb004e8243aef49e5d40a1..d5e09d103a44b23c4a4bf816d33d1215d16b0dfd 100644 (file)
@@ -48,7 +48,7 @@ public class BackgroundTaskItem {
   }
 
   public BackgroundTaskItem assertScannerContextContains(String text) {
-    Selenide.$(".js-task-scanner-context").should(Condition.hasText(text));
+    Selenide.$(".js-task-scanner-context").should(Condition.text(text));
     return this;
   }
 
@@ -59,7 +59,7 @@ public class BackgroundTaskItem {
   }
 
   public BackgroundTaskItem assertErrorStacktraceContains(String text) {
-    Selenide.$(".js-task-stacktrace").should(Condition.hasText(text));
+    Selenide.$(".js-task-stacktrace").should(Condition.text(text));
     return this;
   }
 }
index b210e01fb2ebe6229c838cae713f744f0f9ab8d0..8fb508c4ed30a9bd1aa922bc6cb21a583d5435b0 100644 (file)
@@ -54,7 +54,7 @@ public class LoginPage {
     return Selenide.$(".process-spinner-failed");
   }
 
-  private <T> T submitCredentials(String login, String password, Class<T> expectedResultPage) {
+  private static <T> T submitCredentials(String login, String password, Class<T> expectedResultPage) {
     Selenide.$("#login").val(login);
     Selenide.$("#password").val(password);
     Selenide.$(By.name("commit")).click();
index 908bad3b3e9b9d4efe6c194765db8a7884fd9556..dac1b28ca8cca76b44815fdbe0d8a3b29ee64798 100644 (file)
@@ -54,7 +54,7 @@ public class MarketplacePage {
     return this;
   }
 
-  private SelenideElement getPlugin(String name) {
+  private static SelenideElement getPlugin(String name) {
     return Selenide.$$(".js-plugin-name").findBy(Condition.text(name)).should(Condition.exist).parent().parent().parent();
   }
 }
index 67cea197772ad2b58146ec899e4f919668518336..fbfb8862fe7d2f17976d047b6f90331ffa1c867c 100644 (file)
@@ -164,7 +164,7 @@ public class Navigation {
   }
 
   public SettingsPage openSettings(@Nullable String projectKey) throws UnsupportedEncodingException {
-    String url = projectKey != null ? "/project/settings?id=" + URLEncoder.encode(projectKey, "UTF-8") : "/settings";
+    String url = projectKey != null ? ("/project/settings?id=" + URLEncoder.encode(projectKey, "UTF-8")) : "/settings";
     return open(url, SettingsPage.class);
   }
 
@@ -249,11 +249,11 @@ public class Navigation {
     return Selenide.$("#error");
   }
 
-  private SelenideElement logInLink() {
+  private static SelenideElement logInLink() {
     return Selenide.$(By.linkText("Log in"));
   }
 
-  private SelenideElement loggedInDropdown() {
+  private static SelenideElement loggedInDropdown() {
     return Selenide.$(".js-user-authenticated");
   }
 
index bd4911a94c661fd8ac26afdd580138f96affd473..06939de713c024f3ad2a7f67ffe4b5a6c5c8c95b 100644 (file)
@@ -24,7 +24,7 @@ import com.codeborne.selenide.Selenide;
 
 public class NotificationsPage extends Navigation {
 
-  private final String EMAIL = "EmailNotificationChannel";
+  private static final String EMAIL = "EmailNotificationChannel";
 
   public NotificationsPage() {
     Selenide.$("#account-page").shouldHave(Condition.text("Overall notifications"));
@@ -90,11 +90,11 @@ public class NotificationsPage extends Navigation {
     return this;
   }
 
-  private String globalCheckboxSelector(String type, String channel) {
+  private static String globalCheckboxSelector(String type, String channel) {
     return "#global-notification-" + type + "-" + channel;
   }
 
-  private String projectCheckboxSelector(String project, String type, String channel) {
+  private static String projectCheckboxSelector(String project, String type, String channel) {
     return "#project-notification-" + project + "-" + type + "-" + channel;
   }
 
@@ -112,7 +112,7 @@ public class NotificationsPage extends Navigation {
     return this;
   }
 
-  private void toggleCheckbox(String selector) {
+  private static void toggleCheckbox(String selector) {
     Selenide.$(selector).click();
   }
 }
index ad8206cd47d135b35d5f0a42a42f3f7b171bbba1..05a7fbc6bfbaddafee7c969df1bbfcd041f846ab 100644 (file)
@@ -54,7 +54,7 @@ public class ProjectActivityPage {
     Selenide.$("#project-activity")
       .find(".project-activity-day[data-day=\"" + day + "\"]")
       .find(".project-activity-analysis")
-      .should(Condition.hasText(text));
+      .should(Condition.text(text));
     return this;
   }
 }
index 42bb86748a2cffc5c51c9e555a1417ba92aea030..dfdd972427a298f4b0fc1749eb17f29e395fac5e 100644 (file)
@@ -24,9 +24,6 @@ import com.codeborne.selenide.Selenide;
 
 public class ProjectCodePage {
 
-  public ProjectCodePage() {
-  }
-
   public ProjectCodePage openFirstComponent() {
     Selenide.$$(".code-name-cell a").first().click();
     return this;
index 4db286489dd08d8e406138b20b7364776ddc7b0f..c30abb9890169993c502e6029ac68f45b03b2d63 100644 (file)
@@ -49,11 +49,10 @@ public class ProjectDashboardPage {
 
   public SelenideElement getOverviewMeasure(String measure) {
     ElementsCollection measures = Selenide.$$(".overview-domain-measure");
-    SelenideElement element = measures.find(Condition.text(measure)).shouldBe(Condition.visible);
-    return element;
+    return measures.find(Condition.text(measure)).shouldBe(Condition.visible);
   }
 
-  private SelenideElement getTagsMeta() {
+  private static SelenideElement getTagsMeta() {
     SelenideElement element = Selenide.$(".overview-meta-tags");
     element.shouldBe(Condition.visible);
     return element;
@@ -61,38 +60,38 @@ public class ProjectDashboardPage {
 
   public ProjectDashboardPage shouldHaveTags(String... tags) {
     String tagsList = String.join(", ", Arrays.asList(tags));
-    this.getTagsMeta().$(".tags-list > span").should(Condition.hasText(tagsList));
+    getTagsMeta().$(".tags-list > span").should(Condition.text(tagsList));
     return this;
   }
 
   public ProjectDashboardPage shouldNotBeEditable() {
-    SelenideElement tagsElem = this.getTagsMeta();
+    SelenideElement tagsElem = getTagsMeta();
     tagsElem.$("button").shouldNot(Condition.exist);
     tagsElem.$("div.multi-select").shouldNot(Condition.exist);
     return this;
   }
 
   public ProjectDashboardPage shouldBeEditable() {
-    SelenideElement tagsElem = this.getTagsMeta();
+    SelenideElement tagsElem = getTagsMeta();
     tagsElem.$("button").shouldBe(Condition.visible);
     return this;
   }
 
   public ProjectDashboardPage openTagEditor() {
-    SelenideElement tagsElem = this.getTagsMeta();
+    SelenideElement tagsElem = getTagsMeta();
     tagsElem.$("button").shouldBe(Condition.visible).click();
     tagsElem.$("div.multi-select").shouldBe(Condition.visible);
     return this;
   }
 
   public SelenideElement getTagAtIdx(Integer idx) {
-    SelenideElement tagsElem = this.getTagsMeta();
+    SelenideElement tagsElem = getTagsMeta();
     tagsElem.$("div.multi-select").shouldBe(Condition.visible);
     return tagsElem.$$("ul.menu a").get(idx);
   }
 
   public ProjectDashboardPage sendKeysToTagsInput(CharSequence... charSequences) {
-    SelenideElement tagsInput = this.getTagsMeta().find("input");
+    SelenideElement tagsInput = getTagsMeta().find("input");
     tagsInput.sendKeys(charSequences);
     return this;
   }
index 5a3e5ec678be8156e4fba112f48cdde0647e58f2..cfc2e8137ab177bdcb16731da2f9fbf3d4b6186d 100644 (file)
@@ -77,8 +77,8 @@ public class ProjectKeyPage {
 
   public ProjectKeyPage assertBulkChangeSimulationResult(String oldKey, String newKey) {
     SelenideElement row = Selenide.$("#bulk-update-results").$("[data-key=\"" + oldKey + "\"]");
-    row.$(".js-old-key").should(Condition.hasText(oldKey));
-    row.$(".js-new-key").should(Condition.hasText(newKey));
+    row.$(".js-old-key").should(Condition.text(oldKey));
+    row.$(".js-new-key").should(Condition.text(newKey));
     return this;
   }
 
index 55d9c84092e5048233fac8171a38f46a029c15d7..c047a7be28c0372a917b89da3c2d3f4e53f67786 100644 (file)
@@ -26,8 +26,8 @@ public class SystemInfoPageItem {
   private final SelenideElement elt;
 
   public SystemInfoPageItem(SelenideElement elt) {
-      this.elt = elt;
-    }
+    this.elt = elt;
+  }
 
   public SystemInfoPageItem shouldHaveHealth() {
     elt.$(".system-info-health-info .status-indicator").should(Condition.exist);
@@ -72,7 +72,7 @@ public class SystemInfoPageItem {
   }
 
   public SystemInfoPageItem ensureOpen() {
-    if(!isOpen()) {
+    if (!isOpen()) {
       elt.click();
       elt.$(".boxed-group-inner").should(Condition.exist);
     }
index 92755921f3777fc6b48e663af48be08f2e869175..8da8149bcf62b57b7461e5338d45188b8b575f03 100644 (file)
@@ -32,14 +32,6 @@ public class IssuesPage {
     Selenide.$(".issues").should(Condition.exist);
   }
 
-  private ElementsCollection getIssuesElements() {
-    return Selenide.$$(".issues .issue");
-  }
-
-  private ElementsCollection getIssuesPathComponents() {
-    return Selenide.$$(".issues-workspace-list-component");
-  }
-
   public List<Issue> getIssues() {
     return getIssuesElements()
       .stream()
@@ -48,7 +40,7 @@ public class IssuesPage {
   }
 
   public IssuesPage issuesCount(Integer count) {
-    this.getIssuesElements().shouldHaveSize(count);
+    getIssuesElements().shouldHaveSize(count);
     return this;
   }
 
@@ -58,12 +50,12 @@ public class IssuesPage {
   }
 
   public IssuesPage componentsShouldContain(String path) {
-    this.getIssuesPathComponents().forEach(element -> element.shouldHave(Condition.text(path)));
+    getIssuesPathComponents().forEach(element -> element.shouldHave(Condition.text(path)));
     return this;
   }
 
   public IssuesPage componentsShouldNotContain(String path) {
-    this.getIssuesPathComponents().forEach(element -> element.shouldNotHave(Condition.text(path)));
+    getIssuesPathComponents().forEach(element -> element.shouldNotHave(Condition.text(path)));
     return this;
   }
 
@@ -79,4 +71,12 @@ public class IssuesPage {
     Selenide.$("#issues-bulk-change-assignee .Select-input input").pressEscape();
     return this;
   }
+
+  private static ElementsCollection getIssuesElements() {
+    return Selenide.$$(".issues .issue");
+  }
+
+  private static ElementsCollection getIssuesPathComponents() {
+    return Selenide.$$(".issues-workspace-list-component");
+  }
 }
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/package-info.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/package-info.java
new file mode 100644 (file)
index 0000000..a035971
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonarqube.qa.util.pageobjects.issues;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index de052a403defed1d3bf39ade9c4d07a0c9afe350..f3cd21aac1beaf1ea48229a4c5d793c89910467f 100644 (file)
@@ -37,14 +37,14 @@ public class MeasuresPage {
   }
 
   public MeasuresPage measureHasValue(String measure, Integer value) {
-    SelenideElement sidebar = this.getSideBar();
+    SelenideElement sidebar = getSideBar();
     sidebar.$("#measure-" + measure + "-name").should(Condition.exist);
     sidebar.$("#measure-" + measure + "-value").should(Condition.exist).shouldHave(Condition.text(value.toString()));
     return this;
   }
 
   public MeasuresPage measureHasLeak(String measure, Integer value) {
-    SelenideElement sidebar = this.getSideBar();
+    SelenideElement sidebar = getSideBar();
     sidebar.$("#measure-" + measure + "-name").should(Condition.exist);
     sidebar.$("#measure-" + measure + "-leak").should(Condition.exist).shouldHave(Condition.text(value.toString()));
     return this;
@@ -83,7 +83,7 @@ public class MeasuresPage {
   }
 
   public MeasureContent openMeasureContent(String measure) {
-    SelenideElement sidebar = this.getSideBar();
+    SelenideElement sidebar = getSideBar();
     SelenideElement facetItem = sidebar.$("#measure-" + measure + "-name");
     facetItem.click();
     MeasureContent content = new MeasureContent(Selenide.$("#component-measures .measure-details-content").should(Condition.exist));
@@ -91,7 +91,7 @@ public class MeasuresPage {
     return content;
   }
 
-  private SelenideElement getSideBar() {
+  private static SelenideElement getSideBar() {
     return Selenide.$("#component-measures .layout-page-side").should(Condition.exist);
   }
 }
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/package-info.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/package-info.java
new file mode 100644 (file)
index 0000000..64041b2
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonarqube.qa.util.pageobjects.measures;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index fd02dfb1f11620f9e77238e6bbe80a3b412fbf6e..e25ff4a441cc631de317b191a3036c4dde79a917 100644 (file)
@@ -85,7 +85,7 @@ public class MemberItem {
     return this;
   }
 
-  private SelenideElement getModal(String title) {
+  private static SelenideElement getModal(String title) {
     Selenide.$(".modal-head").should(Condition.exist).shouldHave(Condition.text(title));
     SelenideElement form = Selenide.$(".ReactModalPortal form");
     form.should(Condition.exist);
index 21816aea1c1dfd3443ae8e1a284606af419edfd5..d2b560f6db42d7b42a3f7b177e4fb633d1497017 100644 (file)
@@ -63,7 +63,7 @@ public class MembersPage {
     this.canAddMember();
     Selenide.$(".page-actions button").click();
 
-    SelenideElement modal = this.getModal("Add user");
+    SelenideElement modal = getModal("Add user");
     SelenideElement input = modal.$(".Select-input input");
     input.val(login);
     modal.$("div.Select-option.is-focused").should(Condition.exist);
@@ -72,7 +72,7 @@ public class MembersPage {
     return this;
   }
 
-  private SelenideElement getModal(String title) {
+  private static SelenideElement getModal(String title) {
     Selenide.$(".modal-head").should(Condition.exist).shouldHave(Condition.text(title));
     SelenideElement form = Selenide.$(".ReactModalPortal form");
     form.should(Condition.exist);
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/package-info.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/package-info.java
new file mode 100644 (file)
index 0000000..3928f01
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonarqube.qa.util.pageobjects.organization;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index cc55ce2d619a5d7818ed0c9dd507696512673ea3..a006d627084259d6077ff424ca8c8837373d51af 100644 (file)
@@ -110,7 +110,7 @@ public class ProjectsPage {
     return this;
   }
 
-  private SelenideElement getOpenTopBar() {
+  private static SelenideElement getOpenTopBar() {
     return Selenide.$(".projects-topbar-items").should(Condition.exist);
   }
 }
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/package-info.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/package-info.java
new file mode 100644 (file)
index 0000000..20aa8b7
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonarqube.qa.util.pageobjects.projects;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/package-info.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/package-info.java
new file mode 100644 (file)
index 0000000..f60e348
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonarqube.qa.util.pageobjects.settings;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/tests/src/test/java/org/sonarqube/tests/Elasticsearch.java b/tests/src/test/java/org/sonarqube/tests/Elasticsearch.java
deleted file mode 100644 (file)
index 4bc4620..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests;
-
-import java.net.InetAddress;
-import okhttp3.MediaType;
-import okhttp3.OkHttpClient;
-import okhttp3.Request;
-import okhttp3.RequestBody;
-import okhttp3.Response;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * Helper to directly access Elasticsearch. It requires the HTTP port
- * to be open.
- */
-public class Elasticsearch {
-
-  private final int httpPort;
-
-  public Elasticsearch(int httpPort) {
-    this.httpPort = httpPort;
-  }
-
-  /**
-   * Forbid indexing requests on the specified index. Index becomes read-only.
-   */
-  public void lockWrites(String index) throws Exception {
-    putIndexSetting(httpPort, index, "blocks.write", "true");
-  }
-
-  /**
-   * Enable indexing requests on the specified index.
-   * @see #lockWrites(String)
-   */
-  public void unlockWrites(String index) throws Exception {
-    putIndexSetting(httpPort, index, "blocks.write", "false");
-  }
-
-  public void makeYellow() throws Exception {
-    putIndexSetting(httpPort, "issues", "number_of_replicas", "5");
-  }
-
-  public void makeGreen() throws Exception {
-    putIndexSetting(httpPort, "issues", "number_of_replicas", "0");
-  }
-
-  private void putIndexSetting(int searchHttpPort, String index, String key, String value) throws Exception {
-    Request.Builder request = new Request.Builder()
-      .url(baseUrl(searchHttpPort) + index + "/_settings")
-      .put(RequestBody.create(MediaType.parse("application/json"), "{" +
-        "    \"index\" : {" +
-        "        \"" + key + "\" : \"" + value + "\"" +
-        "    }" +
-        "}"));
-    OkHttpClient okClient = new OkHttpClient.Builder().build();
-    Response response = okClient.newCall(request.build()).execute();
-    assertThat(response.isSuccessful()).isTrue();
-  }
-
-  private String baseUrl(int searchHttpPort) {
-    return "http://" + InetAddress.getLoopbackAddress().getHostAddress() + ":" + searchHttpPort + "/";
-  }
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/GroupTester.java b/tests/src/test/java/org/sonarqube/tests/GroupTester.java
deleted file mode 100644 (file)
index 14568da..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests;
-
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import javax.annotation.Nullable;
-import org.sonarqube.ws.Organizations;
-import org.sonarqube.ws.WsUserGroups;
-import org.sonarqube.ws.WsUsers;
-import org.sonarqube.ws.WsUsers.GroupsWsResponse.Group;
-import org.sonarqube.ws.client.user.GroupsRequest;
-import org.sonarqube.ws.client.usergroup.AddUserWsRequest;
-import org.sonarqube.ws.client.usergroup.CreateWsRequest;
-
-import static java.util.Arrays.stream;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class GroupTester {
-
-  private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
-
-  private final Session session;
-
-  GroupTester(Session session) {
-    this.session = session;
-  }
-
-  @SafeVarargs
-  public final WsUserGroups.Group generate(@Nullable Organizations.Organization organization, Consumer<CreateWsRequest.Builder>... populators) {
-    int id = ID_GENERATOR.getAndIncrement();
-    CreateWsRequest.Builder request = CreateWsRequest.builder()
-      .setName("Group" + id)
-      .setDescription("Description " + id)
-      .setOrganization(organization != null ? organization.getKey() : null);
-    stream(populators).forEach(p -> p.accept(request));
-    return session.wsClient().userGroups().create(request.build()).getGroup();
-  }
-
-  public List<Group> getGroupsOfUser(@Nullable Organizations.Organization organization, String userLogin) {
-    GroupsRequest request = GroupsRequest.builder()
-      .setOrganization(organization != null ? organization.getKey() : null)
-      .setLogin(userLogin)
-      .build();
-    WsUsers.GroupsWsResponse response = session.users().service().groups(request);
-    return response.getGroupsList();
-  }
-
-  public GroupTester addMemberToGroups(Organizations.Organization organization, String userLogin, String... groups) {
-    for (String group : groups) {
-      AddUserWsRequest request = AddUserWsRequest.builder()
-        .setLogin(userLogin)
-        .setOrganization(organization.getKey())
-        .setName(group)
-        .build();
-      session.wsClient().userGroups().addUser(request);
-    }
-    return this;
-  }
-
-  public GroupTester assertThatUserIsMemberOf(@Nullable Organizations.Organization organization, String userLogin, String expectedGroup, String... otherExpectedGroups) {
-    List<String> groups = getGroupsOfUser(organization, userLogin)
-      .stream()
-      .map(Group::getName)
-      .collect(Collectors.toList());
-
-    assertThat(groups).contains(expectedGroup);
-    if (otherExpectedGroups.length > 0) {
-      assertThat(groups).contains(otherExpectedGroups);
-    }
-    return this;
-  }
-
-  public GroupTester assertThatUserIsOnlyMemberOf(@Nullable Organizations.Organization organization, String userLogin, String... expectedGroups) {
-    Set<String> groups = getGroupsOfUser(organization, userLogin)
-      .stream()
-      .map(Group::getName)
-      .collect(Collectors.toSet());
-    assertThat(groups).containsExactlyInAnyOrder(expectedGroups);
-    return this;
-  }
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/LogsTailer.java b/tests/src/test/java/org/sonarqube/tests/LogsTailer.java
deleted file mode 100644 (file)
index eb093b1..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Consumer;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import org.apache.commons.io.input.Tailer;
-import org.apache.commons.io.input.TailerListenerAdapter;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * Watch log files, usually server logs (see Orchestrator.getServer().get*Logs()).
- * This class allows to not load the full content in memory.
- */
-public class LogsTailer implements AutoCloseable {
-
-  private final List<Tailer> tailers;
-  private final LogConsumer logConsumer;
-
-  private LogsTailer(Builder builder) {
-    logConsumer = new LogConsumer(builder.consumers);
-    tailers = builder.files.stream()
-      .map(file -> Tailer.create(file, logConsumer, 500))
-      .collect(Collectors.toList());
-  }
-
-  public Watch watch(String text) {
-    return new Watch(text);
-  }
-
-  @Override
-  public void close() {
-    for (Tailer tailer : tailers) {
-      tailer.stop();
-    }
-  }
-
-  public static Builder builder() {
-    return new Builder();
-  }
-
-  public static class Builder {
-    private final List<File> files = new ArrayList<>();
-    private final List<Consumer<String>> consumers = new ArrayList<>();
-
-    public Builder addFile(File file) {
-      this.files.add(file);
-      return this;
-    }
-
-    public Builder addFiles(File file, File... otherFiles) {
-      this.files.add(file);
-      Collections.addAll(this.files, otherFiles);
-      return this;
-    }
-
-    /**
-     * Adds a consumer that is called on each new line appended
-     * to the files.
-     * Note that the consumer {@link Content} allows to keep
-     * all past logs in memory.
-     */
-    public Builder addConsumer(Consumer<String> consumer) {
-      this.consumers.add(consumer);
-      return this;
-    }
-
-    public LogsTailer build() {
-      return new LogsTailer(this);
-    }
-  }
-
-  private static class LogConsumer extends TailerListenerAdapter {
-    private final List<Consumer<String>> consumers = Collections.synchronizedList(new ArrayList<>());
-
-    private LogConsumer(List<Consumer<String>> consumers) {
-      this.consumers.addAll(consumers);
-    }
-
-    @Override
-    public void handle(String line) {
-      synchronized (consumers) {
-        for (Consumer<String> consumer : consumers) {
-          try {
-            consumer.accept(line);
-          } catch (Exception e) {
-            // do not prevent other consumers to handle the log
-            e.printStackTrace();
-          }
-        }
-      }
-    }
-
-    public void add(Consumer<String> consumer) {
-      this.consumers.add(consumer);
-    }
-
-    public void remove(Consumer<String> consumer) {
-      this.consumers.remove(consumer);
-    }
-  }
-
-  public class Watch implements AutoCloseable {
-    private final String expectedText;
-    private final CountDownLatch foundSignal = new CountDownLatch(1);
-    private String log = null;
-    private final Consumer<String> consumer;
-
-    private Watch(String expectedText) {
-      this.expectedText = requireNonNull(expectedText);
-      this.consumer = log -> {
-        if (log.contains(this.expectedText)) {
-          this.log = log;
-          foundSignal.countDown();
-        }
-      };
-      logConsumer.add(consumer);
-    }
-
-    /**
-     * Blocks until the expected log appears in watched files.
-     */
-    public void waitForLog() throws InterruptedException {
-      foundSignal.await();
-    }
-
-    /**
-     * Blocks until the expected log appears in watched files with timeout
-     */
-    public void waitForLog(long timeout, TimeUnit timeUnit) throws InterruptedException {
-      foundSignal.await(timeout, timeUnit);
-    }
-
-    public Optional<String> getLog() {
-      return Optional.ofNullable(log);
-    }
-
-    @Override
-    public void close() {
-      logConsumer.remove(consumer);
-    }
-  }
-
-  public static class Content implements Consumer<String> {
-    private final List<String> lines = Collections.synchronizedList(new ArrayList<>());
-
-    @Override
-    public void accept(String s) {
-      lines.add(s);
-    }
-
-    public boolean hasText(String text) {
-      synchronized (lines) {
-        for (String line : lines) {
-          if (line.contains(text)) {
-            return true;
-          }
-        }
-      }
-      return false;
-    }
-
-    public boolean hasLineMatching(Pattern pattern) {
-      synchronized (lines) {
-        for (String line : lines) {
-          if (pattern.matcher(line).matches()) {
-            return true;
-          }
-        }
-      }
-      return false;
-    }
-  }
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/OrganizationTester.java b/tests/src/test/java/org/sonarqube/tests/OrganizationTester.java
deleted file mode 100644 (file)
index 5550cd5..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests;
-
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Consumer;
-import javax.annotation.Nullable;
-import org.sonarqube.ws.Organizations;
-import org.sonarqube.ws.WsUsers;
-import org.sonarqube.ws.client.HttpException;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.organization.CreateWsRequest;
-import org.sonarqube.ws.client.organization.OrganizationService;
-import org.sonarqube.ws.client.organization.SearchMembersWsRequest;
-import org.sonarqube.ws.client.organization.SearchWsRequest;
-import org.sonarqube.ws.client.user.GroupsRequest;
-
-import static java.util.Arrays.stream;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class OrganizationTester {
-
-  private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
-
-  private final Session session;
-
-  OrganizationTester(Session session) {
-    this.session = session;
-  }
-
-  void enableSupport() {
-    session.wsClient().wsConnector().call(new PostRequest("api/organizations/enable_support"));
-  }
-
-  void deleteNonGuardedOrganizations() {
-    service().search(SearchWsRequest.builder().build()).getOrganizationsList()
-      .stream()
-      .filter(o -> !o.getKey().equals("default-organization"))
-      .forEach(organization -> service().delete(organization.getKey()));
-  }
-
-  @SafeVarargs
-  public final Organizations.Organization generate(Consumer<CreateWsRequest.Builder>... populators) {
-    int id = ID_GENERATOR.getAndIncrement();
-    CreateWsRequest.Builder request = new CreateWsRequest.Builder()
-      .setKey("org" + id)
-      .setName("Org " + id)
-      .setDescription("Description " + id)
-      .setUrl("http://test" + id);
-    stream(populators).forEach(p -> p.accept(request));
-    return service().create(request.build()).getOrganization();
-  }
-
-  public OrganizationTester addMember(Organizations.Organization organization, WsUsers.CreateWsResponse.User user) {
-    service().addMember(organization.getKey(), user.getLogin());
-    return this;
-  }
-
-  public Organizations.Organization getDefaultOrganization() {
-    return service().search(SearchWsRequest.builder().build()).getOrganizationsList()
-      .stream()
-      .filter(o -> o.getKey().equals("default-organization"))
-      .findFirst().orElseThrow(() -> new IllegalStateException("Can't find default organization"));
-  }
-
-  public OrganizationTester assertThatOrganizationDoesNotExist(String organizationKey) {
-    SearchWsRequest request = new SearchWsRequest.Builder().setOrganizations(organizationKey).build();
-    Organizations.SearchWsResponse searchWsResponse = service().search(request);
-    assertThat(searchWsResponse.getOrganizationsList()).isEmpty();
-    return this;
-  }
-
-  public OrganizationTester assertThatMemberOf(Organizations.Organization organization, WsUsers.CreateWsResponse.User user) {
-    return assertThatMemberOf(organization, user.getLogin());
-  }
-
-  public OrganizationTester assertThatMemberOf(Organizations.Organization organization, String userLogin) {
-    verifyOrganizationMembership(organization, userLogin, true);
-    verifyMembersGroupMembership(userLogin, organization, true);
-    return this;
-  }
-
-  public OrganizationTester assertThatNotMemberOf(Organizations.Organization organization, WsUsers.CreateWsResponse.User user) {
-    return assertThatNotMemberOf(organization, user.getLogin());
-  }
-
-  public OrganizationTester assertThatNotMemberOf(Organizations.Organization organization, String userLogin) {
-    verifyOrganizationMembership(organization, userLogin, false);
-    try {
-      verifyMembersGroupMembership(userLogin, organization, false);
-    } catch (HttpException e) {
-      // do not fail if user does not exist
-      if (e.code() != 404) {
-        throw e;
-      }
-    }
-    return this;
-  }
-
-  private void verifyOrganizationMembership(@Nullable Organizations.Organization organization, String userLogin, boolean isMember) {
-    List<Organizations.User> users = service().searchMembers(new SearchMembersWsRequest()
-      .setQuery(userLogin)
-      .setSelected("selected")
-      .setOrganization(organization != null ? organization.getKey() : null))
-      .getUsersList();
-    assertThat(users).hasSize(isMember ? 1 : 0);
-  }
-
-  private void verifyMembersGroupMembership(String userLogin, @Nullable Organizations.Organization organization, boolean isMember) {
-    List<WsUsers.GroupsWsResponse.Group> groups = session.wsClient().users().groups(GroupsRequest.builder()
-      .setLogin(userLogin)
-      .setOrganization(organization != null ? organization.getKey() : null)
-      .setQuery("Members")
-      .setSelected("selected")
-      .build())
-      .getGroupsList();
-    assertThat(groups).hasSize(isMember ? 1 : 0);
-  }
-
-  public OrganizationService service() {
-    return session.wsClient().organizations();
-  }
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/ProjectTester.java b/tests/src/test/java/org/sonarqube/tests/ProjectTester.java
deleted file mode 100644 (file)
index 781500a..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests;
-
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Consumer;
-import javax.annotation.Nullable;
-import org.sonarqube.ws.Organizations;
-import org.sonarqube.ws.WsProjects;
-import org.sonarqube.ws.client.project.CreateRequest;
-import org.sonarqube.ws.client.project.DeleteRequest;
-import org.sonarqube.ws.client.project.ProjectsService;
-import org.sonarqube.ws.client.project.SearchWsRequest;
-
-import static java.util.Arrays.stream;
-import static java.util.Collections.singletonList;
-
-public class ProjectTester {
-
-  private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
-
-  private final Session session;
-
-  ProjectTester(Session session) {
-    this.session = session;
-  }
-
-  void deleteAll() {
-    ProjectsService service = session.wsClient().projects();
-    service.search(SearchWsRequest.builder().setQualifiers(singletonList("TRK")).build()).getComponentsList().forEach(p -> {
-      service.delete(DeleteRequest.builder().setKey(p.getKey()).build());
-    });
-  }
-
-  @SafeVarargs
-  public final WsProjects.CreateWsResponse.Project generate(@Nullable Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) {
-    int id = ID_GENERATOR.getAndIncrement();
-    CreateRequest.Builder request = CreateRequest.builder()
-      .setKey("key" + id)
-      .setName("Name " + id)
-      .setOrganization(organization != null ? organization.getKey() : null);
-    stream(populators).forEach(p -> p.accept(request));
-
-    return session.wsClient().projects().create(request.build()).getProject();
-  }
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/QGateTester.java b/tests/src/test/java/org/sonarqube/tests/QGateTester.java
deleted file mode 100644 (file)
index 8bf99d3..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests;
-
-import com.google.gson.Gson;
-import com.google.gson.annotations.SerializedName;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.sonarqube.ws.WsProjects.CreateWsResponse.Project;
-import org.sonarqube.ws.WsQualityGates.CreateWsResponse;
-import org.sonarqube.ws.client.GetRequest;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.qualitygate.QualityGatesService;
-import org.sonarqube.ws.client.qualitygate.SelectWsRequest;
-
-public class QGateTester {
-  private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
-
-  private final Session session;
-
-  QGateTester(Session session) {
-    this.session = session;
-  }
-
-  public QualityGatesService service() {
-    return session.wsClient().qualityGates();
-  }
-
-  void deleteAll() {
-    String json = session.wsClient().wsConnector().call(new GetRequest("api/qualitygates/list")).failIfNotSuccessful().content();
-    ListResponse response = ListResponse.parse(json);
-    response.getQualityGates().stream()
-      .filter(qualityGate -> !qualityGate.getId().equals(response.getDefault()))
-      .forEach(qualityGate -> session.wsClient().wsConnector().call(new PostRequest("api/qualitygates/destroy").setParam("id", qualityGate.getId())).failIfNotSuccessful());
-  }
-
-  public CreateWsResponse generate() {
-    int id = ID_GENERATOR.getAndIncrement();
-    return session.wsClient().qualityGates().create("QualityGate" + id);
-  }
-
-  public void associateProject(CreateWsResponse qualityGate, Project project){
-    service().associateProject(new SelectWsRequest().setGateId(qualityGate.getId()).setProjectKey(project.getKey()));
-  }
-
-  public static class ListResponse {
-
-    @SerializedName("default")
-    private final String defaultQGate;
-    @SerializedName("qualitygates")
-    private final List<QGate> qualityGates = new ArrayList<>();
-
-    public ListResponse(String defaultQGate) {
-      this.defaultQGate = defaultQGate;
-    }
-
-    public List<QGate> getQualityGates() {
-      return qualityGates;
-    }
-
-    public String getDefault() {
-      return defaultQGate;
-    }
-
-    public static ListResponse parse(String json) {
-      Gson gson = new Gson();
-      return gson.fromJson(json, ListResponse.class);
-    }
-
-    public static class QGate {
-      @SerializedName("id")
-      private final String id;
-      @SerializedName("name")
-      private final String name;
-
-      public QGate(String id, String name) {
-        this.id = id;
-        this.name = name;
-      }
-
-      public String getId() {
-        return id;
-      }
-
-      public String getName() {
-        return name;
-      }
-    }
-  }
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/QProfileTester.java b/tests/src/test/java/org/sonarqube/tests/QProfileTester.java
deleted file mode 100644 (file)
index 29656d6..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests;
-
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Consumer;
-import org.sonarqube.ws.Common;
-import org.sonarqube.ws.Organizations.Organization;
-import org.sonarqube.ws.QualityProfiles.CreateWsResponse.QualityProfile;
-import org.sonarqube.ws.Rules;
-import org.sonarqube.ws.WsProjects.CreateWsResponse.Project;
-import org.sonarqube.ws.client.HttpException;
-import org.sonarqube.ws.client.qualityprofile.ActivateRuleWsRequest;
-import org.sonarqube.ws.client.qualityprofile.AddProjectRequest;
-import org.sonarqube.ws.client.qualityprofile.CreateRequest;
-import org.sonarqube.ws.client.qualityprofile.QualityProfilesService;
-import org.sonarqube.ws.client.rule.SearchWsRequest;
-
-import static java.util.Arrays.asList;
-import static java.util.Arrays.stream;
-import static java.util.Collections.singletonList;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class QProfileTester {
-  private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
-
-  private final Session session;
-
-  QProfileTester(Session session) {
-    this.session = session;
-  }
-
-  public QualityProfilesService service() {
-    return session.wsClient().qualityProfiles();
-  }
-
-  @SafeVarargs
-  public final QualityProfile createXooProfile(Organization organization, Consumer<CreateRequest.Builder>... populators) {
-    int id = ID_GENERATOR.getAndIncrement();
-    CreateRequest.Builder request = CreateRequest.builder()
-      .setOrganizationKey(organization.getKey())
-      .setLanguage("xoo")
-      .setName("Profile" + id);
-    stream(populators).forEach(p -> p.accept(request));
-    return service().create(request.build()).getProfile();
-  }
-
-  public QProfileTester activateRule(QualityProfile profile, String ruleKey) {
-    return activateRule(profile.getKey(), ruleKey);
-  }
-
-  public QProfileTester activateRule(String profileKey, String ruleKey) {
-    ActivateRuleWsRequest request = ActivateRuleWsRequest.builder()
-      .setKey(profileKey)
-      .setRuleKey(ruleKey)
-      .build();
-    service().activateRule(request);
-    return this;
-  }
-
-  public QProfileTester deactivateRule(QualityProfile profile, String ruleKey) {
-    service().deactivateRule(profile.getKey(), ruleKey);
-    return this;
-  }
-
-  public QProfileTester assignQProfileToProject(QualityProfile profile, Project project) {
-    service().addProject(AddProjectRequest.builder()
-      .setProjectKey(project.getKey())
-      .setKey(profile.getKey())
-      .build());
-    return this;
-  }
-
-  public QProfileTester assertThatNumberOfActiveRulesEqualsTo(QualityProfile profile, int expectedActiveRules) {
-    return assertThatNumberOfActiveRulesEqualsTo(profile.getKey(), expectedActiveRules);
-  }
-
-  public QProfileTester assertThatNumberOfActiveRulesEqualsTo(String profileKey, int expectedActiveRules) {
-    try {
-      List<String> facetIds = asList("active_severities", "repositories", "languages", "severities", "statuses", "types");
-      SearchWsRequest request = new SearchWsRequest()
-        .setQProfile(profileKey)
-        .setActivation(true)
-        .setFacets(facetIds)
-        .setFields(singletonList("actives"));
-      Rules.SearchResponse response = session.wsClient().rules().search(request);
-
-      // assume that expectedActiveRules fits in first page of results
-      assertThat(response.getRulesCount()).isEqualTo(expectedActiveRules);
-      assertThat(response.getTotal()).isEqualTo(expectedActiveRules);
-      assertThat(response.getActives().getActives()).as(response.toString()).hasSize(expectedActiveRules);
-
-      // verify facets
-      assertThat(response.getFacets().getFacetsCount()).isEqualTo(facetIds.size());
-      response.getFacets().getFacetsList().forEach(facet -> {
-        long total = facet.getValuesList().stream()
-          .mapToLong(Common.FacetValue::getCount)
-          .sum();
-        assertThat(total).as("Facet " + facet.getProperty()).isEqualTo((long) expectedActiveRules);
-      });
-    } catch (HttpException e) {
-      if (expectedActiveRules == 0 && e.code() == 404) {
-        // profile does not exist, do nothing
-        return this;
-      }
-      throw e;
-    }
-    return this;
-  }
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/Session.java b/tests/src/test/java/org/sonarqube/tests/Session.java
deleted file mode 100644 (file)
index 23b0b65..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests;
-
-import org.sonarqube.ws.client.WsClient;
-
-public interface Session {
-
-  WsClient wsClient();
-
-  GroupTester groups();
-
-  OrganizationTester organizations();
-
-  ProjectTester projects();
-
-  QProfileTester qProfiles();
-
-  UserTester users();
-
-  SettingTester settings();
-
-  QGateTester qGates();
-
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/SettingTester.java b/tests/src/test/java/org/sonarqube/tests/SettingTester.java
deleted file mode 100644 (file)
index b05dc16..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import javax.annotation.Nullable;
-import org.sonarqube.ws.Settings;
-import org.sonarqube.ws.client.setting.ListDefinitionsRequest;
-import org.sonarqube.ws.client.setting.ResetRequest;
-import org.sonarqube.ws.client.setting.SetRequest;
-import org.sonarqube.ws.client.setting.SettingsService;
-
-import static org.sonarqube.ws.Settings.Type.LICENSE;
-
-public class SettingTester {
-
-  private static final Set<String> EMAIL_SETTINGS = ImmutableSet.of("email.smtp_host.secured", "email.smtp_port.secured", "email.smtp_secure_connection.secured",
-    "email.smtp_username.secured", "email.smtp_password.secured", "email.from", "email.prefix");
-
-  private final Session session;
-
-  SettingTester(Session session) {
-    this.session = session;
-  }
-
-  public SettingsService service() {
-    return session.wsClient().settings();
-  }
-
-  void deleteAll() {
-    List<String> settingKeys = Stream.concat(
-      session.wsClient().settings().listDefinitions(ListDefinitionsRequest.builder().build()).getDefinitionsList()
-        .stream()
-        .filter(def -> def.getType() != LICENSE)
-        .map(Settings.Definition::getKey),
-      EMAIL_SETTINGS.stream())
-      .collect(Collectors.toList());
-    session.wsClient().settings().reset(ResetRequest.builder().setKeys(settingKeys).build());
-  }
-
-  public void resetSettings(String... keys){
-    session.wsClient().settings().reset(ResetRequest.builder().setKeys(keys).build());
-  }
-
-  public void setGlobalSetting(String key, @Nullable String value) {
-    setSetting(null, key, value);
-  }
-
-  public void setGlobalSettings(String... properties) {
-    for (int i = 0; i < properties.length; i += 2) {
-      setSetting(null, properties[i], properties[i + 1]);
-    }
-  }
-
-  public void setProjectSetting(String componentKey, String key, @Nullable String value) {
-    setSetting(componentKey, key, value);
-  }
-
-  public void setProjectSettings(String componentKey, String... properties) {
-    for (int i = 0; i < properties.length; i += 2) {
-      setSetting(componentKey, properties[i], properties[i + 1]);
-    }
-  }
-
-  private void setSetting(@Nullable String componentKey, String key, @Nullable String value) {
-    if (value == null) {
-      session.wsClient().settings().reset(ResetRequest.builder().setKeys(key).setComponent(componentKey).build());
-    } else {
-      session.wsClient().settings().set(SetRequest.builder().setKey(key).setValue(value).setComponent(componentKey).build());
-    }
-  }
-
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/Tester.java b/tests/src/test/java/org/sonarqube/tests/Tester.java
deleted file mode 100644 (file)
index 8f5e58f..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests;
-
-import com.sonar.orchestrator.Orchestrator;
-import javax.annotation.Nullable;
-import org.apache.commons.lang.StringUtils;
-import org.junit.rules.ExternalResource;
-import org.sonarqube.qa.util.pageobjects.Navigation;
-import org.sonarqube.ws.client.WsClient;
-import util.selenium.Selenese;
-
-import static java.util.Objects.requireNonNull;
-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>
- * <p>
- * 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 Elasticsearch elasticsearch = null;
-
-  // initialized in #before()
-  private boolean beforeCalled = false;
-  private Session rootSession;
-
-  public Tester(Orchestrator orchestrator) {
-    this.orchestrator = orchestrator;
-    String elasticsearchHttpPort = orchestrator.getDistribution().getServerProperty("sonar.search.httpPort");
-    if (StringUtils.isNotBlank(elasticsearchHttpPort)) {
-      this.elasticsearch = new Elasticsearch(Integer.parseInt(elasticsearchHttpPort));
-    }
-  }
-
-  public Tester disableOrganizations() {
-    verifyNotStarted();
-    disableOrganizations = true;
-    return this;
-  }
-
-  /**
-   * Enables Elasticsearch debugging, see {@link #elasticsearch()}.
-   *
-   * The property "sonar.search.httpPort" must be defined before
-   * starting SonarQube server.
-   */
-  public Tester setElasticsearchHttpPort(int port) {
-    verifyNotStarted();
-    elasticsearch = new Elasticsearch(port);
-    return this;
-  }
-
-  @Override
-  public void before() {
-    verifyNotStarted();
-    rootSession = new SessionImpl(orchestrator, "admin", "admin");
-
-    if (!disableOrganizations) {
-      organizations().enableSupport();
-    }
-
-    beforeCalled = true;
-  }
-
-  @Override
-  public void after() {
-    if (!disableOrganizations) {
-      organizations().deleteNonGuardedOrganizations();
-    }
-    users().deleteAll();
-    projects().deleteAll();
-    settings().deleteAll();
-    qGates().deleteAll();
-  }
-
-  public Session asAnonymous() {
-    return as(null, null);
-  }
-
-  public Session as(String login) {
-    return as(login, login);
-  }
-
-  public Session as(String login, String password) {
-    verifyStarted();
-    return new SessionImpl(orchestrator, login, password);
-  }
-
-  public Elasticsearch elasticsearch() {
-    return requireNonNull(elasticsearch, "Elasticsearch HTTP port is not defined. See #setElasticsearchHttpPort()");
-  }
-
-  /**
-   * Open a new browser session. Cookies are deleted.
-   */
-  public Navigation openBrowser() {
-    verifyStarted();
-    return Navigation.create(orchestrator);
-  }
-
-  /**
-   * @deprecated use Selenide tests with {@link #openBrowser()}
-   */
-  @Deprecated
-  public Tester runHtmlTests(String... htmlTests) {
-    Selenese.runSelenese(orchestrator, htmlTests);
-    return this;
-  }
-
-  private void verifyNotStarted() {
-    if (beforeCalled) {
-      throw new IllegalStateException("Orchestrator should not be already started");
-    }
-  }
-
-  private void verifyStarted() {
-    if (!beforeCalled) {
-      throw new IllegalStateException("Orchestrator is not started yet");
-    }
-  }
-
-  /**
-   * Web service client configured with root access
-   */
-  @Override
-  public WsClient wsClient() {
-    verifyStarted();
-    return rootSession.wsClient();
-  }
-
-  @Override
-  public GroupTester groups() {
-    return rootSession.groups();
-  }
-
-  @Override
-  public OrganizationTester organizations() {
-    return rootSession.organizations();
-  }
-
-  @Override
-  public ProjectTester projects() {
-    return rootSession.projects();
-  }
-
-  @Override
-  public QProfileTester qProfiles() {
-    return rootSession.qProfiles();
-  }
-
-  @Override
-  public UserTester users() {
-    return rootSession.users();
-  }
-
-  @Override
-  public SettingTester settings() {
-    return rootSession.settings();
-  }
-
-  @Override
-  public QGateTester qGates() {
-    return rootSession.qGates();
-  }
-
-  private static class SessionImpl implements Session {
-    private final WsClient client;
-
-    private SessionImpl(Orchestrator orchestrator, @Nullable String login, @Nullable String password) {
-      this.client = newUserWsClient(orchestrator, login, password);
-    }
-
-    @Override
-    public WsClient wsClient() {
-      return client;
-    }
-
-    @Override
-    public GroupTester groups() {
-      return new GroupTester(this);
-    }
-
-    @Override
-    public OrganizationTester organizations() {
-      return new OrganizationTester(this);
-    }
-
-    @Override
-    public ProjectTester projects() {
-      return new ProjectTester(this);
-    }
-
-    @Override
-    public QProfileTester qProfiles() {
-      return new QProfileTester(this);
-    }
-
-    @Override
-    public UserTester users() {
-      return new UserTester(this);
-    }
-
-    @Override
-    public SettingTester settings() {
-      return new SettingTester(this);
-    }
-
-    @Override
-    public QGateTester qGates() {
-      return new QGateTester(this);
-    }
-  }
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/UserTester.java b/tests/src/test/java/org/sonarqube/tests/UserTester.java
deleted file mode 100644 (file)
index 8dc964f..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.tests;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Consumer;
-import org.sonarqube.ws.Organizations;
-import org.sonarqube.ws.WsUsers;
-import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.user.CreateRequest;
-import org.sonarqube.ws.client.user.SearchRequest;
-import org.sonarqube.ws.client.user.UsersService;
-import org.sonarqube.ws.client.usergroup.AddUserWsRequest;
-
-import static java.util.Arrays.stream;
-
-public class UserTester {
-
-  private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
-
-  private final Session session;
-
-  UserTester(Session session) {
-    this.session = session;
-  }
-
-  void deleteAll() {
-    session.wsClient().users().search(SearchRequest.builder().build()).getUsersList()
-      .stream()
-      .filter(u -> !"admin".equals(u.getLogin()))
-      .forEach(u -> {
-        PostRequest request = new PostRequest("api/users/deactivate").setParam("login", u.getLogin());
-        session.wsClient().wsConnector().call(request);
-      });
-  }
-
-  @SafeVarargs
-  public final User generate(Consumer<CreateRequest.Builder>... populators) {
-    int id = ID_GENERATOR.getAndIncrement();
-    String login = "login" + id;
-    CreateRequest.Builder request = CreateRequest.builder()
-      .setLogin(login)
-      .setPassword(login)
-      .setName("name" + id)
-      .setEmail(id + "@test.com");
-    stream(populators).forEach(p -> p.accept(request));
-    return service().create(request.build()).getUser();
-  }
-
-  @SafeVarargs
-  public final User generateAdministrator(Consumer<CreateRequest.Builder>... populators) {
-    User user = generate(populators);
-    session.wsClient().permissions().addUser(new org.sonarqube.ws.client.permission.AddUserWsRequest().setLogin(user.getLogin()).setPermission("admin"));
-    session.wsClient().userGroups().addUser(org.sonarqube.ws.client.usergroup.AddUserWsRequest.builder().setLogin(user.getLogin()).setName("sonar-administrators").build());
-    return user;
-  }
-
-  @SafeVarargs
-  public final User generateAdministrator(Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) {
-    User user = generate(populators);
-    session.wsClient().organizations().addMember(organization.getKey(), user.getLogin());
-    session.wsClient().userGroups().addUser(AddUserWsRequest.builder()
-      .setOrganization(organization.getKey())
-      .setLogin(user.getLogin())
-      .setName("Owners")
-      .build());
-    return user;
-  }
-
-  @SafeVarargs
-  public final User generateMember(Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) {
-    User user = generate(populators);
-    session.wsClient().organizations().addMember(organization.getKey(), user.getLogin());
-    return user;
-  }
-
-  public UsersService service() {
-    return session.wsClient().users();
-  }
-
-  public Optional<WsUsers.SearchWsResponse.User> getByLogin(String login) {
-    List<WsUsers.SearchWsResponse.User> users = session.wsClient().users().search(SearchRequest.builder().setQuery(login).build()).getUsersList();
-    if (users.size() == 1) {
-      return Optional.of(users.get(0));
-    }
-    return Optional.empty();
-  }
-}
index 226c736032feec6222b6e7236fc539718b8c98e9..db55ef7f23f7b5a664599e62e372ef8f3c68401f 100644 (file)
@@ -36,7 +36,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Byteman;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Common;
 import org.sonarqube.ws.Issues;
 import org.sonarqube.ws.Organizations.Organization;
index 4e1ffec8f2a00ec1e0e793e6652c483df576d0ce..bdcac11098fc6e975123cada836744e5886fd6f9 100644 (file)
@@ -36,7 +36,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
 import org.sonarqube.tests.Category3Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import util.ItUtils;
 
 import static org.assertj.core.api.Assertions.assertThat;
index 366632b06446ea2e55605970e0b80dd10f0ed801..b0a82a81dc3c87d59ffda281cfd9b1a783fa9c9e 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.WsPermissions;
 import org.sonarqube.ws.WsPermissions.CreateTemplateWsResponse;
index 11fe9c49637c8df6d0231d4448972017ce2d7e49..b96d5cc719c4636f480a719a552b927e7cbcaecd 100644 (file)
@@ -24,9 +24,10 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category1Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.client.permission.AddUserWsRequest;
 import org.sonarqube.ws.client.qualityprofile.CreateRequest;
+import util.selenium.Selenese;
 
 import static util.ItUtils.runProjectAnalysis;
 
@@ -50,7 +51,7 @@ public class QualityProfileAdminPermissionTest {
     tester.wsClient().permissions().addUser(new AddUserWsRequest().setLogin("profileadm").setPermission("profileadmin"));
     createProfile("xoo", "foo");
 
-    tester.runHtmlTests(
+    Selenese.runSelenese(orchestrator,
       // Verify normal user is not allowed to do any modification
       "/authorisation/QualityProfileAdminPermissionTest/normal-user.html",
       // Verify profile admin is allowed to do modifications
index 32fa0cba328392a413b3abd6f4ff96b055dd5dc3..b7fabd3bb925ec231df9864174680f89ee089742 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.WsRequest;
 import org.sonarqube.ws.client.WsResponse;
index 13dcb0b396f9abaaacaa451dfe82be38ae397d22..aef3ab0696ade21139bf1040fb30b2902bc4106c 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category2Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Common;
 import org.sonarqube.ws.WsBranches;
 import org.sonarqube.ws.client.GetRequest;
index 10a4fbfdc6b03e8bc26998bfb7d23ef5b9942436..07ae9a9c5963b5b1ad590db3bb0bc8b8cc5d2a10 100644 (file)
@@ -32,7 +32,7 @@ import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TemporaryFolder;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
-import org.sonarqube.tests.LogsTailer;
+import org.sonarqube.qa.util.LogsTailer;
 import org.sonarqube.ws.client.WsClient;
 import org.sonarqube.ws.client.ce.ActivityStatusWsRequest;
 import util.ItUtils;
index 46727f2c3756a7b1a99d17dfdab2bd9a02b96e6f..411c753b9bdb591e167303d839b39078fd46c83f 100644 (file)
@@ -42,7 +42,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsProjects;
 import org.sonarqube.ws.WsUsers;
index 2b3115564e8c1fa825a65f23ae4c589317005b22..c2bedf5426b05009d367d7e12f76e8bd67d8fbe3 100644 (file)
@@ -35,7 +35,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ErrorCollector;
 import org.sonarqube.tests.Category4Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.ProjectAnalyses;
 import org.sonarqube.ws.WsMeasures;
 import org.sonarqube.ws.WsMeasures.SearchHistoryResponse.HistoryValue;
index e05168fb4976f75e914d4960f50d41a3779d2d5c..ce98ec258f1f9c064e8cec7a9249738480985e31 100644 (file)
@@ -37,7 +37,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.wsclient.issue.Issue;
 import org.sonar.wsclient.issue.IssueQuery;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.WsClient;
 import org.subethamail.wiser.Wiser;
index 62b6117fdaf701428cf1c06d0ea1ff57aabbb1bf..fbeeb637d60d3d5fe1afa564e121168d5a930c46 100644 (file)
@@ -40,7 +40,7 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
 import org.junit.runners.Parameterized.Parameters;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Issues.Issue;
 import org.sonarqube.ws.Issues.SearchWsResponse;
 import org.sonarqube.ws.Organizations.Organization;
index aa1f987c565d4792a3b6da9b783b4cb375d03179..c44fcafaf7336581dd7633321f980de399014767 100644 (file)
@@ -29,7 +29,7 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 import org.sonarqube.ws.client.issue.SearchWsRequest;
index a9e5bcf3eee8bc7cf14072444dfabbdb7134fac7..8ca101b9feec654b7bb51dcdd83fc9832c6d5f1c 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Issues;
 import org.sonarqube.ws.Issues.Issue;
 import org.sonarqube.ws.Organizations;
index df0e4c58dd9bc5de6f7c752285f5397ffa5777b5..13e7c26f8c3d1bf40da3a1c473f416cbf162b25e 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.qa.util.pageobjects.Navigation;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsUsers;
 import util.issue.IssueRule;
index e60adfdbc2b9cef8c904ec7cb6f021f68b97de70..2585f27d65ae20d5b4110a1616f77071c03df4cc 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Issues;
 import org.sonarqube.ws.WsComponents;
 import org.sonarqube.ws.WsMeasures;
index 2ea1009b617e71dc5cebe0f8b393978716e2986c..080d9e059a8de8c24bd1771c4bcdaba1f7d36cbb 100644 (file)
@@ -29,7 +29,7 @@ import org.sonarqube.qa.util.pageobjects.Navigation;
 import org.sonarqube.qa.util.pageobjects.measures.MeasureContent;
 import org.sonarqube.qa.util.pageobjects.measures.MeasuresPage;
 import org.sonarqube.tests.Category1Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 
 import static com.codeborne.selenide.Condition.visible;
 import static com.codeborne.selenide.Selenide.$;
index 730298db1e6ef59c5ee7fafecf18abe9af8c475f..e0a8d9c2ea1309ec2e606c67f469dba760a1b854 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 import org.sonarqube.ws.client.GetRequest;
index 256b30b7271bcd230a72e8a67348e80cff649392..1903f3c733600a03c2c8c6cf93358f7bcf52314c 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 import org.sonarqube.ws.client.HttpException;
index 817248a14fb54eb83f035614d630957af721b671..bec9b244087aae420a72edab813eda59a20566ef 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.qa.util.pageobjects.organization.MembersPage;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 
index 7ea671d5928df6a2f579084a26f2679b1f730bd7..39750b1e9c1c0e125b44b1d5f03bbd4db6edafca 100644 (file)
@@ -29,8 +29,8 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonarqube.tests.OrganizationTester;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.OrganizationTester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.QualityProfiles;
 import org.sonarqube.ws.Rules;
index 5f6320c6397ba8d8e4bddaaa9dce7d2c4ade4011..9faddde8421e5e15272a1050dd090d24363e7cdb 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsUsers;
 import org.sonarqube.ws.client.organization.SearchWsRequest;
index e462fb709c56949ce1cb28799154d18b0c8e622d..5b326210fa3d11f9352c66d00b7dbee5b8767f18 100644 (file)
@@ -25,8 +25,8 @@ import java.sql.SQLException;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Session;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.TesterSession;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsRoot;
 import org.sonarqube.ws.WsUsers;
 import util.user.UserRule;
@@ -69,8 +69,8 @@ public class RootUserOnOrganizationTest {
   public void root_can_be_set_and_unset_via_web_services() {
     WsUsers.CreateWsResponse.User user1 = tester.users().generate();
     WsUsers.CreateWsResponse.User user2 = tester.users().generate();
-    Session user1Session = tester.as(user1.getLogin());
-    Session user2Session = tester.as(user2.getLogin());
+    TesterSession user1Session = tester.as(user1.getLogin());
+    TesterSession user2Session = tester.as(user2.getLogin());
 
     // non root can not set or unset root another user not itself
     expectForbiddenError(() -> user1Session.wsClient().roots().setRoot(user2.getLogin()));
index 517fc94d0f1faf8d49432128a03dcdcd00e83e73..6d66e5fc33c6b46d10350c0a7899e8c396a48772 100644 (file)
@@ -24,7 +24,7 @@ import org.sonarqube.tests.Category4Suite;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 
 import static util.ItUtils.expectForbiddenError;
 
index 88f75d55db56dbd520229f11a5dfa931ffafb68f..7612667cf628182fceb4319cded6b7801218d772 100644 (file)
@@ -42,7 +42,7 @@ import org.sonarqube.qa.util.pageobjects.Navigation;
 import org.sonarqube.qa.util.pageobjects.ProjectsManagementPage;
 import org.sonarqube.qa.util.pageobjects.settings.SettingsPage;
 import org.sonarqube.tests.Category1Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsPermissions;
 import org.sonarqube.ws.client.permission.AddUserToTemplateWsRequest;
 import org.sonarqube.ws.client.permission.CreateTemplateWsRequest;
index 28d601e0e2123d0249b49c0cb87f63e779a6164a..71ac12d965c6193c60b9997d3a8d9a704ba29061 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsProjects.CreateWsResponse;
 import org.sonarqube.ws.WsProjects.SearchWsResponse.Component;
index bf087c2917d5394567871a77da86adab64d4f0a3..988f37703f8ca37579dc39216b9fcca9b02c4373 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category1Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsProjects.CreateWsResponse.Project;
 import org.sonarqube.ws.client.component.SearchProjectsRequest;
 
index b0b43103ac63dd36616ea5118b792fc9e67a4452..788a94dfbf33ad6d50f6e81fc1c624e20ab4fae2 100644 (file)
@@ -31,7 +31,7 @@ import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsComponents;
 import org.sonarqube.ws.WsProjects;
index 79a8902f58254ceb694d76ff437abd14e7f4639f..f1e1ba47ce471034143dddbc8fb4fca345cdabd4 100644 (file)
@@ -34,7 +34,7 @@ import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsComponents;
 import org.sonarqube.ws.WsProjects;
index 1ff7a8f24d6106b0d3d6b58d6455b9df4c245189..40140448b55f6b5a16ec467dbe1574c0adb26df3 100644 (file)
@@ -29,7 +29,7 @@ import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsComponents;
 import org.sonarqube.ws.WsProjects;
index 6a3bdbbe8bcfeaa91184186b8cdd36b487b1db76..60500c79fd59ef3fb646f7af6aa52191b76199ad 100644 (file)
@@ -69,8 +69,8 @@ public class ProjectQualityGatePageTest {
     try {
       ProjectQualityGatePage page = openPage();
       SelenideElement selectedQualityGate = page.getSelectedQualityGate();
-      selectedQualityGate.should(Condition.hasText("Default"));
-      selectedQualityGate.should(Condition.hasText(customQualityGate.name()));
+      selectedQualityGate.should(Condition.text("Default"));
+      selectedQualityGate.should(Condition.text(customQualityGate.name()));
     } finally {
       qualityGateClient().unsetDefault();
       qualityGateClient().destroy(customQualityGate.id());
@@ -84,8 +84,8 @@ public class ProjectQualityGatePageTest {
 
     ProjectQualityGatePage page = openPage();
     SelenideElement selectedQualityGate = page.getSelectedQualityGate();
-    selectedQualityGate.shouldNot(Condition.hasText("Default"));
-    selectedQualityGate.should(Condition.hasText(customQualityGate.name()));
+    selectedQualityGate.shouldNot(Condition.text("Default"));
+    selectedQualityGate.should(Condition.text(customQualityGate.name()));
   }
 
   @Test
@@ -104,7 +104,7 @@ public class ProjectQualityGatePageTest {
     page.setQualityGate(customQualityGate.name());
 
     SelenideElement selectedQualityGate = page.getSelectedQualityGate();
-    selectedQualityGate.should(Condition.hasText(customQualityGate.name()));
+    selectedQualityGate.should(Condition.text(customQualityGate.name()));
   }
 
   @Test
@@ -117,8 +117,8 @@ public class ProjectQualityGatePageTest {
       page.setQualityGate(customQualityGate.name());
 
       SelenideElement selectedQualityGate = page.getSelectedQualityGate();
-      selectedQualityGate.should(Condition.hasText("Default"));
-      selectedQualityGate.should(Condition.hasText(customQualityGate.name()));
+      selectedQualityGate.should(Condition.text("Default"));
+      selectedQualityGate.should(Condition.text(customQualityGate.name()));
     } finally {
       qualityGateClient().unsetDefault();
       qualityGateClient().destroy(customQualityGate.id());
index 23313f49d1d48b48da43e1ff83d73c68a35c941f..cd1c0107c8cf2b88e113baeab532419c63e54882 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsProjects.CreateWsResponse;
 import org.sonarqube.ws.WsProjects.SearchWsResponse;
index b09816c222cc4acb96ee3b0cd352f9125dec01e6..54ff1ce9bf61f3310ce751c0d46a9d20ad5e975e 100644 (file)
@@ -31,7 +31,7 @@ import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.qa.util.pageobjects.projects.ProjectsPage;
 
index 1a9b5a4a0a4439ef34d70949037afd33328bf154..2843898a8865ef8bd3adbbf800bdc2486e9f0755 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.rules.RuleChain;
 import org.sonarqube.qa.util.pageobjects.Navigation;
 import org.sonarqube.qa.util.pageobjects.projects.ProjectsPage;
 import org.sonarqube.tests.Category1Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsUsers;
 import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.WsClient;
index c466b813e11bb7bc57a14e8848e26616bf727182..2e4e6f159c2f86aa176948c5bc0d42941672ed12 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Common;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.WsComponents.Component;
index 02e99e90a8878771bd0edec4ef75373259bca332..a859558d04e1e62d6939ccc19becf362fcad2972 100644 (file)
@@ -30,7 +30,7 @@ import org.openqa.selenium.By;
 import org.sonarqube.qa.util.pageobjects.ProjectDashboardPage;
 import org.sonarqube.qa.util.pageobjects.QualityGatePage;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsUsers;
 import util.issue.IssueRule;
index ca4c99e47dc539d4bcfbc6656b8b3df98fbe0b43..f41911e4e2bce5694401db5b7541f17084f5199a 100644 (file)
@@ -31,7 +31,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.MediaTypes;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsCe;
index 9df387528bfe426673247658095213ecaf0a46be..de000ee5e616aa111361cfb78e73eaa0c12ad594 100644 (file)
@@ -29,7 +29,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category1Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsProjects.CreateWsResponse.Project;
 import org.sonarqube.ws.WsQualityGates;
 import org.sonarqube.ws.client.PostRequest;
index c1005e3683ce3070008a8be8da25d94b02ef3031..a90b54cbc1ac5b7f230b6462943a40673a04befb 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category1Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsMeasures;
 import org.sonarqube.ws.WsProjects.CreateWsResponse.Project;
 import org.sonarqube.ws.WsQualityGates;
index 75e6a8976545c6dc1209ba6b8ec643796a857e5c..400b897fadd0ae81fdde0963b2608189f9a792a2 100644 (file)
@@ -43,8 +43,8 @@ import org.sonar.wsclient.qualitygate.NewCondition;
 import org.sonar.wsclient.qualitygate.QualityGate;
 import org.sonar.wsclient.qualitygate.QualityGateClient;
 import org.sonarqube.tests.Category1Suite;
-import org.sonarqube.tests.Session;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.TesterSession;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.MediaTypes;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.WsCe;
@@ -293,7 +293,7 @@ public class QualityGateTest {
     Organization organization = tester.organizations().getDefaultOrganization();
     WsUsers.CreateWsResponse.User user = tester.users().generateMember(organization);
     tester.wsClient().permissions().addUser(new AddUserWsRequest().setLogin(user.getLogin()).setPermission("gateadmin").setOrganization(organization.getKey()));
-    Session qGateAdminTester = tester.as(user.getLogin());
+    TesterSession qGateAdminTester = tester.as(user.getLogin());
     QualityGatesService qGateService = qGateAdminTester.qGates().service();
     // perform administration operations
     WsQualityGates.CreateWsResponse qualityGate = qGateAdminTester.qGates().generate();
index 5c342390d41fd2390790006690bdc597dddacd0c..1fb41c1145405a52dfc8dff3e747afffb0b9c7bd 100644 (file)
@@ -34,7 +34,7 @@ import org.openqa.selenium.By;
 import org.sonarqube.qa.util.pageobjects.Navigation;
 import org.sonarqube.qa.util.pageobjects.ProjectActivityPage;
 import org.sonarqube.tests.Category1Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsProjects.CreateWsResponse.Project;
 import org.sonarqube.ws.WsQualityGates;
 import org.sonarqube.ws.client.qualitygate.CreateConditionRequest;
index 226096b21897617f0c706e6b7efcc6586e4fc980..2bc320dc4755561978e5b9daad29162235384dcb 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.WsProjects.CreateWsResponse.Project;
 import org.sonarqube.ws.WsQualityGates.CreateWsResponse;
index 49be3215f074f8bc6f925a0e7ee44e180873c208..0f71864996ae98eb19f69fc0f488abf8d110869f 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
 import org.sonarqube.tests.Byteman;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.QualityProfiles;
 import org.sonarqube.ws.client.rule.SearchWsRequest;
index 6e9173e042a1560bb756fad4cf87c270bdb2625d..7b255b7894029e43ca08d66d39ed31c449707c11 100644 (file)
@@ -25,8 +25,8 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Session;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.TesterSession;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.QualityProfiles;
 import org.sonarqube.ws.QualityProfiles.CreateWsResponse;
@@ -110,7 +110,7 @@ public class BuiltInQualityProfilesTest {
     Organization org = tester.organizations().generate();
     User administrator = tester.users().generateAdministrator(org);
     QualityProfile builtInProfile = getProfile(org, p -> p.getIsBuiltIn() && "Basic".equals(p.getName()) && "xoo".equals(p.getLanguage()));
-    Session adminSession = tester.as(administrator.getLogin());
+    TesterSession adminSession = tester.as(administrator.getLogin());
 
     QualityProfiles.CopyWsResponse copyResponse = adminSession.qProfiles().service().copy(new CopyRequest(builtInProfile.getKey(), "My copy"));
 
@@ -132,7 +132,7 @@ public class BuiltInQualityProfilesTest {
     Organization org = tester.organizations().generate();
     User administrator = tester.users().generateAdministrator(org);
     QualityProfile builtInProfile = getProfile(org, p -> p.getIsBuiltIn() && "Basic".equals(p.getName()) && "xoo".equals(p.getLanguage()));
-    Session adminSession = tester.as(administrator.getLogin());
+    TesterSession adminSession = tester.as(administrator.getLogin());
 
     QualityProfiles.CopyWsResponse copyResponse = adminSession.qProfiles().service().copy(new CopyRequest(builtInProfile.getKey(), "My copy"));
     adminSession.qProfiles().service().changeParent(
index 76d707b38c62d1df0995319b191c665f9a4bd181..849744752619f26e54ff790d6f36a930a6518b98 100644 (file)
@@ -28,9 +28,9 @@ import java.util.function.Predicate;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.QProfileTester;
-import org.sonarqube.tests.Session;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.QProfileTester;
+import org.sonarqube.qa.util.TesterSession;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.QualityProfiles;
 import org.sonarqube.ws.QualityProfiles.CreateWsResponse.QualityProfile;
@@ -188,7 +188,7 @@ public class CustomQualityProfilesTest {
     Organization org = tester.organizations().generate();
     QualityProfile profile = tester.qProfiles().createXooProfile(org);
 
-    Session anonymousSession = tester.asAnonymous();
+    TesterSession anonymousSession = tester.asAnonymous();
 
     expectUnauthorizedError(() -> anonymousSession.qProfiles().createXooProfile(org));
     expectUnauthorizedError(() -> anonymousSession.qProfiles().service().delete(profile.getKey()));
@@ -201,7 +201,7 @@ public class CustomQualityProfilesTest {
     Organization org = tester.organizations().generate();
 
     User orgAdmin = tester.users().generateAdministrator(org);
-    Session adminSession = tester.as(orgAdmin.getLogin());
+    TesterSession adminSession = tester.as(orgAdmin.getLogin());
     QualityProfile profile = adminSession.qProfiles().createXooProfile(org);
 
     // root can activate rule and delete the profile
@@ -217,7 +217,7 @@ public class CustomQualityProfilesTest {
     Organization org = tester.organizations().generate();
     User user = tester.users().generateAdministrator(org);
 
-    Session adminSession = tester.as(user.getLogin());
+    TesterSession adminSession = tester.as(user.getLogin());
     QualityProfile parentProfile = adminSession.qProfiles().createXooProfile(org);
     QualityProfile inheritedProfile = adminSession.qProfiles().service().create(
       CreateRequest.builder()
@@ -250,7 +250,7 @@ public class CustomQualityProfilesTest {
     Organization org = tester.organizations().generate();
     User admin = tester.users().generateAdministrator(org);
 
-    Session adminSession = tester.as(admin.getLogin());
+    TesterSession adminSession = tester.as(admin.getLogin());
 
     String projectKey = randomAlphanumeric(10);
     String projectName = randomAlphanumeric(10);
@@ -286,7 +286,7 @@ public class CustomQualityProfilesTest {
     User admin = tester.users().generateAdministrator(org);
     String projectKey = randomAlphanumeric(10);
     String projectName = randomAlphanumeric(10);
-    Session adminSession = tester.as(admin.getLogin());
+    TesterSession adminSession = tester.as(admin.getLogin());
     QualityProfile newXooProfile = adminSession.qProfiles().createXooProfile(org);
 
     adminSession.wsClient().wsConnector().call(new PostRequest("api/projects/create")
index 5a55561549cb582a38bcc18509d7861e6db210ee..69a8e008f938f1c6c0c7a669ecedce3219830b0b 100644 (file)
@@ -27,17 +27,18 @@ import org.junit.ClassRule;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.qa.util.pageobjects.Navigation;
 import org.sonarqube.qa.util.pageobjects.QualityProfilePage;
 import org.sonarqube.qa.util.pageobjects.RulesPage;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.QualityProfiles;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.qualityprofile.AddProjectRequest;
 import org.sonarqube.ws.client.qualityprofile.ChangeParentRequest;
+import util.selenium.Selenese;
 
 import static com.codeborne.selenide.Selenide.$;
 import static util.ItUtils.projectDir;
@@ -73,7 +74,7 @@ public class OrganizationQualityProfilesUiTest {
 
   @Test
   public void testHomePage() {
-    tester.runHtmlTests(
+    Selenese.runSelenese(orchestrator, 
       "/organization/OrganizationQualityProfilesUiTest/should_display_list.html",
       "/organization/OrganizationQualityProfilesUiTest/should_open_from_list.html",
       "/organization/OrganizationQualityProfilesUiTest/should_filter_by_language.html");
@@ -81,7 +82,7 @@ public class OrganizationQualityProfilesUiTest {
 
   @Test
   public void testProfilePage() {
-    tester.runHtmlTests(
+    Selenese.runSelenese(orchestrator,
       "/organization/OrganizationQualityProfilesUiTest/should_display_profile_rules.html",
       "/organization/OrganizationQualityProfilesUiTest/should_display_profile_inheritance.html",
       "/organization/OrganizationQualityProfilesUiTest/should_display_profile_exporters.html");
@@ -104,46 +105,46 @@ public class OrganizationQualityProfilesUiTest {
 
   @Test
   public void testProfileChangelog() {
-    tester.runHtmlTests(
+    Selenese.runSelenese(orchestrator, 
       "/organization/OrganizationQualityProfilesUiTest/should_display_changelog.html");
   }
 
   @Ignore("to be replaced by selenide test in order to inject profile key")
   @Test
   public void testComparison() {
-    tester.runHtmlTests("/organization/OrganizationQualityProfilesUiTest/should_compare.html");
+    Selenese.runSelenese(orchestrator, "/organization/OrganizationQualityProfilesUiTest/should_compare.html");
   }
 
   @Test
   public void testCreation() {
-    tester.runHtmlTests("/organization/OrganizationQualityProfilesUiTest/should_create.html");
+    Selenese.runSelenese(orchestrator, "/organization/OrganizationQualityProfilesUiTest/should_create.html");
   }
 
   @Test
   public void testDeletion() {
-    tester.runHtmlTests("/organization/OrganizationQualityProfilesUiTest/should_delete.html");
+    Selenese.runSelenese(orchestrator, "/organization/OrganizationQualityProfilesUiTest/should_delete.html");
   }
 
   @Test
   public void testCopying() {
-    tester.runHtmlTests("/organization/OrganizationQualityProfilesUiTest/should_copy.html");
+    Selenese.runSelenese(orchestrator, "/organization/OrganizationQualityProfilesUiTest/should_copy.html");
   }
 
   @Test
   public void testRenaming() {
-    tester.runHtmlTests("/organization/OrganizationQualityProfilesUiTest/should_rename.html");
+    Selenese.runSelenese(orchestrator, "/organization/OrganizationQualityProfilesUiTest/should_rename.html");
   }
 
   @Test
   public void testSettingDefault() {
-    tester.runHtmlTests("/organization/OrganizationQualityProfilesUiTest/should_set_default.html");
+    Selenese.runSelenese(orchestrator, "/organization/OrganizationQualityProfilesUiTest/should_set_default.html");
   }
 
   @Test
   public void testRestoration() {
     deleteProfile("xoo", "empty");
 
-    tester.runHtmlTests("/organization/OrganizationQualityProfilesUiTest/should_restore.html");
+    Selenese.runSelenese(orchestrator, "/organization/OrganizationQualityProfilesUiTest/should_restore.html");
   }
 
   @Test
index 17298e222111b544b8d1274a9c0e1ccff1726fca..142fd1d2dffc45f2cebc8d5cab91df8537470022 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Common;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.QualityProfiles.CreateWsResponse;
index 5ad0041e602a66e6d43008897cb4c0fed72845d3..6de29578f620c6e9115a2d7b5cf9006df94e964c 100644 (file)
@@ -28,13 +28,14 @@ import org.junit.ClassRule;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.qa.util.pageobjects.Navigation;
 import org.sonarqube.tests.Category4Suite;
-import org.sonarqube.tests.Tester;
 import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.qualityprofile.AddProjectRequest;
 import org.sonarqube.ws.client.qualityprofile.ChangeParentRequest;
 import org.sonarqube.ws.client.qualityprofile.CreateRequest;
+import util.selenium.Selenese;
 import util.user.UserRule;
 
 import static com.codeborne.selenide.Selenide.$;
@@ -80,7 +81,7 @@ public class QualityProfilesUiTest {
 
   @Test
   public void testHomePage() {
-    tester.runHtmlTests(
+    Selenese.runSelenese(orchestrator,
       "/qualityProfile/QualityProfilesUiTest/should_display_list.html",
       "/qualityProfile/QualityProfilesUiTest/should_open_from_list.html",
       "/qualityProfile/QualityProfilesUiTest/should_filter_by_language.html");
@@ -88,7 +89,7 @@ public class QualityProfilesUiTest {
 
   @Test
   public void testProfilePage() {
-    tester.runHtmlTests(
+    Selenese.runSelenese(orchestrator,
       "/qualityProfile/QualityProfilesUiTest/should_display_profile_rules.html",
       "/qualityProfile/QualityProfilesUiTest/should_display_profile_inheritance.html",
       "/qualityProfile/QualityProfilesUiTest/should_display_profile_projects.html",
@@ -108,46 +109,46 @@ public class QualityProfilesUiTest {
 
   @Test
   public void testProfileChangelog() {
-    tester.runHtmlTests(
+    Selenese.runSelenese(orchestrator,
       "/qualityProfile/QualityProfilesUiTest/should_display_changelog.html");
   }
 
   @Ignore("find a way to know profile key inside selenium tests")
   @Test
   public void testComparison() {
-    tester.runHtmlTests("/qualityProfile/QualityProfilesUiTest/should_compare.html");
+    Selenese.runSelenese(orchestrator, "/qualityProfile/QualityProfilesUiTest/should_compare.html");
   }
 
   @Test
   public void testCreation() {
-    tester.runHtmlTests("/qualityProfile/QualityProfilesUiTest/should_create.html");
+    Selenese.runSelenese(orchestrator, "/qualityProfile/QualityProfilesUiTest/should_create.html");
   }
 
   @Test
   public void testDeletion() {
-    tester.runHtmlTests("/qualityProfile/QualityProfilesUiTest/should_delete.html");
+    Selenese.runSelenese(orchestrator, "/qualityProfile/QualityProfilesUiTest/should_delete.html");
   }
 
   @Test
   public void testCopying() {
-    tester.runHtmlTests("/qualityProfile/QualityProfilesUiTest/should_copy.html");
+    Selenese.runSelenese(orchestrator, "/qualityProfile/QualityProfilesUiTest/should_copy.html");
   }
 
   @Test
   public void testRenaming() {
-    tester.runHtmlTests("/qualityProfile/QualityProfilesUiTest/should_rename.html");
+    Selenese.runSelenese(orchestrator, "/qualityProfile/QualityProfilesUiTest/should_rename.html");
   }
 
   @Test
   public void testSettingDefault() {
-    tester.runHtmlTests("/qualityProfile/QualityProfilesUiTest/should_set_default.html");
+    Selenese.runSelenese(orchestrator, "/qualityProfile/QualityProfilesUiTest/should_set_default.html");
   }
 
   @Test
   public void testRestore() {
     deleteProfile("xoo", "empty");
 
-    tester.runHtmlTests("/qualityProfile/QualityProfilesUiTest/should_restore.html");
+    Selenese.runSelenese(orchestrator, "/qualityProfile/QualityProfilesUiTest/should_restore.html");
   }
 
   private void createProfile(String language, String name) {
index b88ad7121fbd1267642635828c2bd12b13f7a9db..4e1215201172eaa4cfd331dd8b19539333df2a41 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Test;
 import org.skyscreamer.jsonassert.JSONAssert;
 import org.skyscreamer.jsonassert.JSONCompareMode;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.QualityProfiles.CreateWsResponse;
 import org.sonarqube.ws.QualityProfiles.SearchWsResponse;
index c887cf652f30625b68bd10d66a28ad44cec7a189..770298e8180130322125c41174380aac93c58bf1 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
 import org.sonarqube.tests.Byteman;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.client.rule.CreateWsRequest;
 import org.sonarqube.ws.client.rule.SearchWsRequest;
 import util.ItUtils;
index 16e9397c7137eb9b0e395a3f75e965a9f1d2f490..16fd9ca3fb07d901abc5b6b90c465ccb7b2038ed 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TestRule;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.client.PostRequest;
 import util.ItUtils;
index 527dbe423ce5bb2fe07bbc5266a5f8c6f79dbd7d..97b2d2b205a28750ca74699b9a996332a5629c44 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.qa.util.pageobjects.RulesPage;
 import org.sonarqube.tests.Category2Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 
 public class RulesPageTest {
   @ClassRule
index 3b4d1482b949866d7d2927f42ff2addd98fe778a..77aca9652f43a2685d61a63f77e1dc68be00d8eb 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category6Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.QualityProfiles.CreateWsResponse;
 import org.sonarqube.ws.QualityProfiles.SearchWsResponse;
index 3ac1c50cdfe6214c0f60cdb984d6a49741d6253c..2e70f4e5c18734b77d1fd28bf4e3088c1a96391b 100644 (file)
@@ -31,9 +31,10 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category4Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsSystem;
 import util.ItUtils;
+import util.selenium.Selenese;
 
 import static org.apache.commons.lang.StringUtils.startsWithAny;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -72,7 +73,7 @@ public class ServerSystemTest {
   public void display_warnings_when_using_h2() {
     String dialect = orchestrator.getConfiguration().getString("sonar.jdbc.dialect");
     if (dialect == null || dialect.equals("h2") || dialect.equals("embedded")) {
-      tester.runHtmlTests("/serverSystem/ServerSystemTest/derby-warning.html");
+      Selenese.runSelenese(orchestrator, "/serverSystem/ServerSystemTest/derby-warning.html");
     }
   }
 
@@ -81,7 +82,7 @@ public class ServerSystemTest {
    */
   @Test
   public void hide_jdbc_settings_to_non_admin() {
-    tester.runHtmlTests("/serverSystem/ServerSystemTest/hide-jdbc-settings.html");
+    Selenese.runSelenese(orchestrator, "/serverSystem/ServerSystemTest/hide-jdbc-settings.html");
   }
 
   @Test
@@ -104,7 +105,7 @@ public class ServerSystemTest {
     orchestrator.executeBuild(SonarScanner.create(ItUtils.projectDir("shared/xoo-sample"))
       .setProperty("sonar.projectKey", "myproject.jsp"));
     // Access dashboard
-    tester.runHtmlTests("/serverSystem/ServerSystemTest/url_ending_by_jsp.html");
+    Selenese.runSelenese(orchestrator, "/serverSystem/ServerSystemTest/url_ending_by_jsp.html");
   }
 
   /**
index 60065d7195487969924d9d5d31d4db8077e7d833..8ba633a40f3719ae0a3fc44826dd54e17aa867ab 100644 (file)
@@ -29,7 +29,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.qa.util.pageobjects.SystemInfoPage;
 import org.sonarqube.tests.Category4Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.WsResponse;
 import util.ItUtils;
index a305187d88172dd92b1c119ad09740513f5f267d..62985921e4a5f191120bf59891aa0cbd919a19bc 100644 (file)
@@ -35,7 +35,7 @@ import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TemporaryFolder;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
-import org.sonarqube.tests.Elasticsearch;
+import org.sonarqube.qa.util.Elasticsearch;
 import org.sonarqube.ws.WsSystem;
 import org.sonarqube.ws.client.WsClient;
 
index 8ce6439178b99474d195a40f159851c5f105e215..78522a988a476ad7f672c4522e05555cf9a26707 100644 (file)
@@ -32,7 +32,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category1Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Settings;
 import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.setting.ValuesRequest;
index 985a361fb908d1c8a943e0aa156ca0a5a354a8b5..397b83d5fbd80b18ed5a344aeef34729c29a31a1 100644 (file)
@@ -24,7 +24,8 @@ import org.sonarqube.tests.Category1Suite;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
+import util.selenium.Selenese;
 
 import static util.ItUtils.runProjectAnalysis;
 
@@ -40,6 +41,6 @@ public class EncodingTest {
   public void support_japanese_charset() {
     runProjectAnalysis(orchestrator, "sourceCode/japanese-charset", "sonar.sourceEncoding", "Shift_JIS");
 
-    tester.runHtmlTests("/sourceCode/EncodingTest/japanese_sources.html");
+    Selenese.runSelenese(orchestrator, "/sourceCode/EncodingTest/japanese_sources.html");
   }
 }
index 6e682a7417609fcbcb9e6bfdeec3e96808642697..1f20c8c070046c45321fb280c7c8765b546fa352 100644 (file)
 package org.sonarqube.tests.sourceCode;
 
 import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category1Suite;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
+import org.sonarqube.tests.Category1Suite;
+import util.selenium.Selenese;
 
 import static util.ItUtils.runProjectAnalysis;
 
@@ -41,10 +42,10 @@ public class HighlightingTest {
     runProjectAnalysis(orchestrator, "highlighting/xoo-sample-with-highlighting-v2");
 
     // SONAR-3893 & SONAR-4247
-    tester.runHtmlTests("/sourceCode/HighlightingTest/syntax-highlighting.html");
+    Selenese.runSelenese(orchestrator, "/sourceCode/HighlightingTest/syntax-highlighting.html");
 
     // SONAR-4249 & SONAR-4250
-    tester.runHtmlTests("/sourceCode/HighlightingTest/symbol-usages-highlighting.html");
+    Selenese.runSelenese(orchestrator, "/sourceCode/HighlightingTest/symbol-usages-highlighting.html");
   }
 
   // Check that E/S index is updated when file content is unchanged but plugin generates different syntax/symbol highlighting
@@ -52,11 +53,11 @@ public class HighlightingTest {
   public void update_highlighting_even_when_code_unchanged() {
     runProjectAnalysis(orchestrator, "highlighting/xoo-sample-with-highlighting-v1");
 
-    tester.runHtmlTests("/sourceCode/HighlightingTest/syntax-highlighting-v1.html");
+    Selenese.runSelenese(orchestrator, "/sourceCode/HighlightingTest/syntax-highlighting-v1.html");
 
     runProjectAnalysis(orchestrator, "highlighting/xoo-sample-with-highlighting-v2");
 
-    tester.runHtmlTests("/sourceCode/HighlightingTest/syntax-highlighting-v2.html");
-    tester.runHtmlTests("/sourceCode/HighlightingTest/symbol-usages-highlighting.html");
+    Selenese.runSelenese(orchestrator, "/sourceCode/HighlightingTest/syntax-highlighting-v2.html");
+    Selenese.runSelenese(orchestrator, "/sourceCode/HighlightingTest/symbol-usages-highlighting.html");
   }
 }
index 9318569d05f6397984d5eb4ff61a478d472f4b6a..0ee1c7ee0af85c83c7d821dd7b79f030f17afff8 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.tests.Category1Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsProjects.CreateWsResponse.Project;
 
 import static util.ItUtils.projectDir;
index fbffa558d1597d69cdb2578ffe29bc4a8564800f..1e95f664ec3fbc4fa5b7a0c4eb0050d357f4af6f 100644 (file)
@@ -33,8 +33,8 @@ import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TemporaryFolder;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
-import org.sonarqube.tests.LogsTailer;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.LogsTailer;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsUsers;
 import org.sonarqube.ws.client.user.SearchRequest;
 
index 98830cebbdc8dc6dfac649f5abb06e4940d85db6..00343e022391c166723b12a09107e19bb267c5e8 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.client.GetRequest;
 
 import static org.assertj.core.api.Assertions.assertThat;
index 1680429d0b0b8d489897bb14b4d573acadc1c2a4..fb38e03cc326c998ef8803d6727c7b38e25e3c47 100644 (file)
@@ -32,7 +32,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.skyscreamer.jsonassert.JSONAssert;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static util.ItUtils.getMeasuresAsDoubleByMetricKey;
index f6dd9b953550fa13baf145cebb086363c188894b..c1a9545b55b6e7fc20729c1586bdbe54a26fbf80 100644 (file)
@@ -29,7 +29,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.skyscreamer.jsonassert.JSONAssert;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 
 import static util.ItUtils.projectDir;
 
index f12064e8c2831fd1cbaade234af4b83f2b16c70c..be96edbe2c2530a5fa7abc6d66c076672719a2e6 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.openqa.selenium.By;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 
index f3215b096bc545a9d1a9e366437dfae2b3e59ef0..4a8bbfe31da5f42278a465cccdd6a4ccf8b63129 100644 (file)
@@ -25,11 +25,12 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.openqa.selenium.By;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsProjects;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 import org.sonarqube.ws.client.project.CreateRequest;
 import util.ItUtils;
+import util.selenium.Selenese;
 
 import static com.codeborne.selenide.Condition.text;
 import static com.codeborne.selenide.Selenide.$;
@@ -46,7 +47,7 @@ public class UiExtensionsTest {
 
   @Test
   public void test_static_files() {
-    tester.runHtmlTests("/ui/UiExtensionsTest/static-files.html");
+    Selenese.runSelenese(orchestrator, "/ui/UiExtensionsTest/static-files.html");
   }
 
   @Test
index 7d731b7b773ef3619ec7af09e1a929207cc53510..d09aa11028838b99e4fd0d3035367bd7b38ac38d 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.PostRequest;
index 8dc84a3ad2e4c0a0ac18067ee2c221c29db8f17c..30203f58e6a860b854e260d53c6056934d580445 100644 (file)
@@ -26,10 +26,10 @@ import org.junit.After;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.qa.util.pageobjects.LoginPage;
 import org.sonarqube.qa.util.pageobjects.Navigation;
 import org.sonarqube.tests.Category4Suite;
-import org.sonarqube.tests.Tester;
 import org.sonarqube.ws.WsUserTokens;
 import org.sonarqube.ws.WsUsers;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
@@ -44,6 +44,7 @@ import org.sonarqube.ws.client.usertoken.GenerateWsRequest;
 import org.sonarqube.ws.client.usertoken.RevokeWsRequest;
 import org.sonarqube.ws.client.usertoken.SearchWsRequest;
 import org.sonarqube.ws.client.usertoken.UserTokensService;
+import util.selenium.Selenese;
 
 import static java.lang.String.format;
 import static java.util.Arrays.asList;
@@ -162,7 +163,7 @@ public class LocalAuthenticationTest {
   public void test_authentication_in_ui() {
     tester.users().generate(u -> u.setLogin("simple-user").setPassword("password"));
     tester.users().generateAdministrator(u -> u.setLogin("admin-user").setPassword("admin-user"));
-    tester.runHtmlTests(
+    Selenese.runSelenese(orchestrator,
       "/user/LocalAuthenticationTest/login_successful.html",
       "/user/LocalAuthenticationTest/login_wrong_password.html",
       "/user/LocalAuthenticationTest/should_not_be_unlogged_when_going_to_login_page.html");
@@ -172,8 +173,8 @@ public class LocalAuthenticationTest {
   public void test_authentication_redirects_in_ui() {
     tester.users().generate(u -> u.setLogin("simple-user").setPassword("password"));
     tester.users().generateAdministrator(u -> u.setLogin("admin-user").setPassword("admin-user"));
-    tester.runHtmlTests(
-    "/user/LocalAuthenticationTest/redirect_to_login_when_not_enough_privilege.html",
+    Selenese.runSelenese(orchestrator,
+      "/user/LocalAuthenticationTest/redirect_to_login_when_not_enough_privilege.html",
       // SONAR-2132
       "/user/LocalAuthenticationTest/redirect_to_original_url_after_direct_login.html",
       "/user/LocalAuthenticationTest/redirect_to_original_url_with_parameters_after_direct_login.html",
@@ -187,7 +188,7 @@ public class LocalAuthenticationTest {
     tester.users().generateAdministrator(u -> u.setLogin("admin-user").setPassword("admin-user"));
     setServerProperty(orchestrator, "sonar.forceAuthentication", "true");
 
-    tester.runHtmlTests(
+    Selenese.runSelenese(orchestrator,
       // SONAR-3473
       "/user/LocalAuthenticationTest/force-authentication.html");
   }
index 58877d221e269a925eadd6afbfd7b6f3c0d95ca5..ec0961811d357ad36b07d47e8c9400080ceab486 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.qa.util.pageobjects.Navigation;
 import org.sonarqube.tests.Category4Suite;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 import org.sonarqube.ws.client.PostRequest;
 
index 62eb79412c2a2d223f46a78f2a12c5e600c981dc..740fd28835ce8777acac981bb742ad4c6d1b56d1 100644 (file)
@@ -32,14 +32,15 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.qa.util.pageobjects.Navigation;
 import org.sonarqube.tests.Category4Suite;
-import org.sonarqube.tests.Tester;
 import org.sonarqube.ws.WsUsers.SearchWsResponse.User;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.WsResponse;
 import org.sonarqube.ws.client.permission.AddUserWsRequest;
 import org.sonarqube.ws.client.user.CreateRequest;
+import util.selenium.Selenese;
 
 import static com.codeborne.selenide.Condition.visible;
 import static com.codeborne.selenide.Selenide.$;
@@ -146,7 +147,7 @@ public class OAuth2IdentityProviderTest {
     // As this property is null, the plugin will throw an exception
     tester.settings().setGlobalSettings("sonar.auth.fake-oauth2-id-provider.user", null);
 
-    tester.runHtmlTests("/user/OAuth2IdentityProviderTest/display_unauthorized_page_when_authentication_failed.html");
+    Selenese.runSelenese(orchestrator, "/user/OAuth2IdentityProviderTest/display_unauthorized_page_when_authentication_failed.html");
 
     assertThatUserDoesNotExist(USER_LOGIN);
   }
@@ -157,7 +158,7 @@ public class OAuth2IdentityProviderTest {
     enablePlugin();
     tester.settings().setGlobalSettings("sonar.auth.fake-oauth2-id-provider.allowsUsersToSignUp", "false");
 
-    tester.runHtmlTests("/user/OAuth2IdentityProviderTest/fail_to_authenticate_when_not_allowed_to_sign_up.html");
+    Selenese.runSelenese(orchestrator, "/user/OAuth2IdentityProviderTest/fail_to_authenticate_when_not_allowed_to_sign_up.html");
 
     assertThatUserDoesNotExist(USER_LOGIN);
   }
@@ -168,7 +169,7 @@ public class OAuth2IdentityProviderTest {
     enablePlugin();
     tester.settings().setGlobalSettings("sonar.auth.fake-oauth2-id-provider.throwUnauthorizedMessage", "true");
 
-    tester.runHtmlTests("/user/OAuth2IdentityProviderTest/display_message_in_ui_but_not_in_log_when_unauthorized_exception.html");
+    Selenese.runSelenese(orchestrator, "/user/OAuth2IdentityProviderTest/display_message_in_ui_but_not_in_log_when_unauthorized_exception.html");
 
     File logFile = orchestrator.getServer().getWebLogs();
     assertThat(FileUtils.readFileToString(logFile)).doesNotContain("A functional error has happened");
@@ -183,7 +184,7 @@ public class OAuth2IdentityProviderTest {
     enablePlugin();
     tester.users().generate(u -> u.setLogin("another").setName("Another").setEmail(USER_EMAIL).setPassword("another"));
 
-    tester.runHtmlTests("/user/OAuth2IdentityProviderTest/fail_when_email_already_exists.html");
+    Selenese.runSelenese(orchestrator, "/user/OAuth2IdentityProviderTest/fail_when_email_already_exists.html");
 
     File logFile = orchestrator.getServer().getWebLogs();
     assertThat(FileUtils.readFileToString(logFile))
index 205e17d10abe7d2ff6ef555945941b2cdba98831..f0f9c614629147831c5f81418eef43b8f39dbb4c 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 import org.sonarqube.ws.client.WsClient;
 import util.ItUtils;
index 767c76f70db24e0bab617408a604969751b9e933..22e1dee4984e4f4a81b618429d5d94bb8f4476c4 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsUserGroups.Group;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 import org.sonarqube.ws.client.GetRequest;
index f1ed633686cba3ec448b72198e33cebe65218d24..aee0917c8f8a9a4cdbccec26627c718277e8b9b9 100644 (file)
@@ -37,7 +37,7 @@ import org.sonar.wsclient.connectors.HttpClient4Connector;
 import org.sonar.wsclient.services.AuthenticationQuery;
 import org.sonar.wsclient.user.UserParameters;
 import org.sonarqube.qa.util.pageobjects.SystemInfoPage;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.WsResponse;
 import org.sonarqube.ws.client.user.CreateRequest;
index 3f2d69fe898c00311900df776bf7b4fb0d5ee13c..7aa50328352b7b77662994f056bdb73e4a32e87b 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
 import org.sonarqube.tests.Byteman;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
 import org.sonarqube.ws.client.user.SearchRequest;
 import org.sonarqube.ws.client.user.UpdateRequest;
index e11e55d4d358f6c0b5238b3cf422cadbd0667504..b10257c2c533dbf59ade48bbfa7856d7d898869d 100644 (file)
@@ -61,7 +61,8 @@ 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.tests.Tester;
+import org.sonarqube.qa.util.SettingTester;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.WsComponents.Component;
 import org.sonarqube.ws.WsMeasures;
 import org.sonarqube.ws.WsMeasures.Measure;
@@ -253,7 +254,7 @@ public class ItUtils {
   }
 
   /**
-   * @deprecated replaced by {@link org.sonarqube.tests.SettingTester#setGlobalSetting(String, String)}
+   * @deprecated replaced by {@link SettingTester#setGlobalSetting(String, String)}
    */
   @Deprecated
   public static void setServerProperty(Orchestrator orchestrator, String key, @Nullable String value) {
@@ -261,7 +262,7 @@ public class ItUtils {
   }
 
   /**
-   * @deprecated replaced by {@link org.sonarqube.tests.SettingTester#setProjectSetting(String, String, String)}
+   * @deprecated replaced by {@link SettingTester#setProjectSetting(String, String, String)}
    */
   @Deprecated
   public static void setServerProperty(Orchestrator orchestrator, @Nullable String componentKey, String key, @Nullable String value) {
@@ -273,7 +274,7 @@ public class ItUtils {
   }
 
   /**
-   * @deprecated replaced by {@link org.sonarqube.tests.SettingTester#setGlobalSetting(String, String)} or {@link org.sonarqube.tests.SettingTester#setProjectSettings(String, String...)}
+   * @deprecated replaced by {@link SettingTester#setGlobalSetting(String, String)} or {@link SettingTester#setProjectSettings(String, String...)}
    */
   @Deprecated
   public static void setServerProperties(Orchestrator orchestrator, @Nullable String componentKey, String... properties) {
@@ -283,7 +284,7 @@ public class ItUtils {
   }
 
   /**
-   * @deprecated replaced by {@link org.sonarqube.tests.SettingTester#resetSettings(String...)} 
+   * @deprecated replaced by {@link SettingTester#resetSettings(String...)}
    */
   @Deprecated
   public static void resetSettings(Orchestrator orchestrator, @Nullable String componentKey, String... keys) {
index 187e33d902463ea4f5c46b38449ec486c26fb146..ce25edf5f176ecac3c5b8e0b841a866a55d69e8d 100644 (file)
@@ -23,7 +23,7 @@ import com.sonar.orchestrator.Orchestrator;
 import java.io.File;
 import javax.annotation.Nullable;
 import org.apache.commons.io.FileUtils;
-import org.sonarqube.tests.Tester;
+import org.sonarqube.qa.util.Tester;
 
 /**
  * Selenium HTML tests, generally written with Selenium IDE
@@ -43,7 +43,7 @@ public final class Selenese {
   }
 
   /**
-   * @deprecated replaced by {@link Tester#runHtmlTests(String...)}
+   * Replaced by Selenide
    */
   @Deprecated
   public static void runSelenese(Orchestrator orchestrator, String... htmlFiles) {
index 41b362f3e0a984b96181049df6b6baf1987b1f73..609a20f65bcc74ac9cd9be919b0dcbdfe68d66ea 100644 (file)
@@ -22,9 +22,10 @@ package util.user;
 import java.util.List;
 import java.util.Optional;
 import javax.annotation.Nullable;
+import org.sonarqube.qa.util.Tester;
 
 /**
- * @deprecated replaced by {@link org.sonarqube.tests.Tester}
+ * @deprecated replaced by {@link Tester}
  */
 @Deprecated
 public interface GroupManagement {
index 7b87547bc17c850bf18610fa1d8f996d61754066..8aa1f63c869f1ea06b6bd1c7608f2281dfb8221d 100644 (file)
@@ -21,9 +21,10 @@ package util.user;
 
 import com.google.gson.Gson;
 import java.util.List;
+import org.sonarqube.qa.util.Tester;
 
 /**
- * @deprecated replaced by {@link org.sonarqube.tests.Tester}
+ * @deprecated replaced by {@link Tester}
  */
 @Deprecated
 
index fe93e631c013c33bbae520bd8ff044b3f88f3cae..994e4a0c2e71409a358b36d9081acf1aeb5c01a6 100644 (file)
@@ -30,6 +30,7 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.junit.rules.ExternalResource;
+import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.WsUsers;
 import org.sonarqube.ws.client.GetRequest;
@@ -51,7 +52,7 @@ import static org.assertj.guava.api.Assertions.assertThat;
 import static util.ItUtils.newAdminWsClient;
 
 /**
- * @deprecated replaced by {@link org.sonarqube.tests.Tester}
+ * @deprecated replaced by {@link Tester}
  */
 @Deprecated
 public class UserRule extends ExternalResource implements GroupManagement {