From c0487171c393547539f458b0d1b9ca7904112fdb Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Mon, 18 Jun 2018 16:47:35 +0200 Subject: [PATCH] merge sonar-qa-util into private/it-common --- server/sonar-qa-util/build.gradle | 16 - .../org/sonarqube/qa/util/Elasticsearch.java | 83 ----- .../org/sonarqube/qa/util/GroupTester.java | 105 ------ .../org/sonarqube/qa/util/LogsTailer.java | 200 ----------- .../sonarqube/qa/util/OrganizationTester.java | 143 -------- .../sonarqube/qa/util/PermissionTester.java | 99 ------ .../org/sonarqube/qa/util/ProjectTester.java | 82 ----- .../org/sonarqube/qa/util/QGateTester.java | 138 -------- .../org/sonarqube/qa/util/QModelTester.java | 55 --- .../org/sonarqube/qa/util/QProfileTester.java | 147 -------- .../org/sonarqube/qa/util/SelenideConfig.java | 71 ---- .../org/sonarqube/qa/util/SettingTester.java | 98 ------ .../java/org/sonarqube/qa/util/Tester.java | 283 --------------- .../org/sonarqube/qa/util/TesterSession.java | 48 --- .../org/sonarqube/qa/util/UserTester.java | 134 ------- .../org/sonarqube/qa/util/WebhookTester.java | 120 ------- .../sonarqube/qa/util/XooProjectBuilder.java | 96 ----- .../org/sonarqube/qa/util/package-info.java | 23 -- .../util/pageobjects/BackgroundTaskItem.java | 65 ---- .../util/pageobjects/BackgroundTasksPage.java | 45 --- .../util/pageobjects/DocumentationPage.java | 45 --- .../pageobjects/EmailAlreadyExistsPage.java | 48 --- .../qa/util/pageobjects/EncryptionPage.java | 51 --- .../qa/util/pageobjects/LoginPage.java | 71 ---- .../qa/util/pageobjects/MarketplacePage.java | 60 ---- .../qa/util/pageobjects/Navigation.java | 333 ------------------ .../util/pageobjects/NotificationsPage.java | 118 ------- .../util/pageobjects/ProjectActivityPage.java | 60 ---- .../util/pageobjects/ProjectAnalysisItem.java | 102 ------ .../qa/util/pageobjects/ProjectCodePage.java | 64 ---- .../pageobjects/ProjectDashboardPage.java | 106 ------ .../qa/util/pageobjects/ProjectKeyPage.java | 106 ------ .../qa/util/pageobjects/ProjectLinkItem.java | 52 --- .../qa/util/pageobjects/ProjectLinksPage.java | 44 --- .../pageobjects/ProjectPermissionsPage.java | 59 ---- .../pageobjects/ProjectQualityGatePage.java | 44 --- .../pageobjects/ProjectsManagementPage.java | 58 --- .../qa/util/pageobjects/QualityGatePage.java | 60 ---- .../util/pageobjects/QualityProfilePage.java | 65 ---- .../qa/util/pageobjects/RuleDetails.java | 260 -------------- .../qa/util/pageobjects/RuleItem.java | 50 --- .../qa/util/pageobjects/RulesPage.java | 139 -------- .../qa/util/pageobjects/SourceViewer.java | 54 --- .../qa/util/pageobjects/SystemInfoPage.java | 48 --- .../util/pageobjects/SystemInfoPageItem.java | 85 ----- .../qa/util/pageobjects/UpdateLoginPage.java | 58 --- .../util/pageobjects/UsersManagementItem.java | 98 ------ .../util/pageobjects/UsersManagementPage.java | 52 --- .../qa/util/pageobjects/WebhooksPage.java | 148 -------- .../qa/util/pageobjects/issues/Issue.java | 64 ---- .../util/pageobjects/issues/IssuesPage.java | 82 ----- .../util/pageobjects/issues/package-info.java | 23 -- .../pageobjects/measures/MeasureContent.java | 61 ---- .../pageobjects/measures/MeasuresPage.java | 108 ------ .../pageobjects/measures/package-info.java | 23 -- .../pageobjects/organization/MemberItem.java | 93 ----- .../pageobjects/organization/MembersPage.java | 80 ----- .../organization/package-info.java | 23 -- .../qa/util/pageobjects/package-info.java | 23 -- .../util/pageobjects/projects/FacetItem.java | 49 --- .../pageobjects/projects/ProjectItem.java | 37 -- .../pageobjects/projects/ProjectsPage.java | 116 ------ .../pageobjects/projects/package-info.java | 23 -- .../settings/PropertySetInput.java | 47 --- .../pageobjects/settings/SettingsPage.java | 151 -------- .../pageobjects/settings/package-info.java | 23 -- settings.gradle | 1 - 67 files changed, 5616 deletions(-) delete mode 100644 server/sonar-qa-util/build.gradle delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Elasticsearch.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/GroupTester.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/LogsTailer.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/OrganizationTester.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/PermissionTester.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/ProjectTester.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QGateTester.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QModelTester.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SelenideConfig.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SettingTester.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/TesterSession.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/WebhookTester.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/XooProjectBuilder.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/package-info.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTaskItem.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTasksPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/DocumentationPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/EmailAlreadyExistsPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/EncryptionPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/LoginPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/MarketplacePage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/NotificationsPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectActivityPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectAnalysisItem.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectDashboardPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectKeyPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinkItem.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinksPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectPermissionsPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectQualityGatePage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectsManagementPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityGatePage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityProfilePage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleDetails.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleItem.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RulesPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SourceViewer.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPageItem.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UpdateLoginPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementItem.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/WebhooksPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/Issue.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/IssuesPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/package-info.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasureContent.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasuresPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/package-info.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MemberItem.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MembersPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/package-info.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/package-info.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/FacetItem.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectItem.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectsPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/package-info.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/PropertySetInput.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/SettingsPage.java delete mode 100644 server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/package-info.java diff --git a/server/sonar-qa-util/build.gradle b/server/sonar-qa-util/build.gradle deleted file mode 100644 index 14a6ccd4573..00000000000 --- a/server/sonar-qa-util/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -sonarqube { - skipProject = true -} - -dependencies { - // please keep the list grouped by configuration and ordered by name - - compile 'com.codeborne:selenide:4.8' - // required version 23.0 for selenide - compile 'com.google.guava:guava:23.0' - compile 'org.assertj:assertj-core' - compile 'org.sonarsource.orchestrator:sonar-orchestrator' - compile project(':sonar-ws') - - compileOnly 'com.google.code.findbugs:jsr305' -} 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 deleted file mode 100644 index 8a14fdb1483..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Elasticsearch.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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 deleted file mode 100644 index 3e1c0cbee85..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/GroupTester.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.UserGroups; -import org.sonarqube.ws.Users; -import org.sonarqube.ws.Users.GroupsWsResponse.Group; -import org.sonarqube.ws.client.usergroups.AddUserRequest; -import org.sonarqube.ws.client.usergroups.CreateRequest; -import org.sonarqube.ws.client.users.GroupsRequest; - -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 UserGroups.Group generate(@Nullable Organizations.Organization organization, Consumer... populators) { - int id = ID_GENERATOR.getAndIncrement(); - CreateRequest request = new CreateRequest() - .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).getGroup(); - } - - @SafeVarargs - public final UserGroups.Group generate(Consumer... populators) { - return generate(null, populators); - } - - public List getGroupsOfUser(@Nullable Organizations.Organization organization, String userLogin) { - GroupsRequest request = new GroupsRequest() - .setOrganization(organization != null ? organization.getKey() : null) - .setLogin(userLogin); - Users.GroupsWsResponse response = session.users().service().groups(request); - return response.getGroupsList(); - } - - public GroupTester addMemberToGroups(@Nullable Organizations.Organization organization, String userLogin, String... groups) { - for (String group : groups) { - AddUserRequest request = new AddUserRequest() - .setLogin(userLogin) - .setOrganization(organization != null ? organization.getKey() : null) - .setName(group); - session.wsClient().userGroups().addUser(request); - } - return this; - } - - public GroupTester assertThatUserIsMemberOf(@Nullable Organizations.Organization organization, String userLogin, String expectedGroup, String... otherExpectedGroups) { - List 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 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 deleted file mode 100644 index 985feb12387..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/LogsTailer.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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 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 files = new ArrayList<>(); - private final List> 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 consumer) { - this.consumers.add(consumer); - return this; - } - - public LogsTailer build() { - return new LogsTailer(this); - } - } - - private static class LogConsumer extends TailerListenerAdapter { - private final List> consumers = Collections.synchronizedList(new ArrayList<>()); - - private LogConsumer(List> consumers) { - this.consumers.addAll(consumers); - } - - @Override - public void handle(String line) { - synchronized (consumers) { - for (Consumer consumer : consumers) { - try { - consumer.accept(line); - } catch (Exception e) { - // do not prevent other consumers to handle the log - e.printStackTrace(); - } - } - } - } - - public void add(Consumer consumer) { - this.consumers.add(consumer); - } - - public void remove(Consumer 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 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 boolean waitForLog(long timeout, TimeUnit timeUnit) throws InterruptedException { - return foundSignal.await(timeout, timeUnit); - } - - public Optional getLog() { - return Optional.ofNullable(log); - } - - @Override - public void close() { - logConsumer.remove(consumer); - } - } - - public static class Content implements Consumer { - private final List 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 deleted file mode 100644 index 9a529ea3051..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/OrganizationTester.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.Collections; -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.Users; -import org.sonarqube.ws.client.HttpException; -import org.sonarqube.ws.client.PostRequest; -import org.sonarqube.ws.client.organizations.AddMemberRequest; -import org.sonarqube.ws.client.organizations.CreateRequest; -import org.sonarqube.ws.client.organizations.DeleteRequest; -import org.sonarqube.ws.client.organizations.OrganizationsService; -import org.sonarqube.ws.client.organizations.SearchMembersRequest; -import org.sonarqube.ws.client.organizations.SearchRequest; -import org.sonarqube.ws.client.users.GroupsRequest; - -import static java.util.Arrays.stream; - -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(new SearchRequest()).getOrganizationsList() - .stream() - .filter(o -> !o.getKey().equals("default-organization")) - .forEach(organization -> service().delete(new DeleteRequest().setOrganization(organization.getKey()))); - } - - @SafeVarargs - public final Organizations.Organization generate(Consumer... populators) { - int id = ID_GENERATOR.getAndIncrement(); - CreateRequest request = new CreateRequest() - .setKey("org" + id) - .setName("Org " + id) - .setDescription("Description " + id) - .setUrl("http://test" + id); - stream(populators).forEach(p -> p.accept(request)); - return service().create(request).getOrganization(); - } - - public OrganizationTester addMember(Organizations.Organization organization, Users.CreateWsResponse.User user) { - service().addMember(new AddMemberRequest().setOrganization(organization.getKey()).setLogin(user.getLogin())); - return this; - } - - public Organizations.Organization getDefaultOrganization() { - return service().search(new SearchRequest()).getOrganizationsList() - .stream() - .filter(o -> o.getKey().equals("default-organization")) - .findFirst().orElseThrow(() -> new IllegalStateException("Can't find default organization")); - } - - public OrganizationTester assertThatOrganizationDoesNotExist(String organizationKey) { - SearchRequest request = new SearchRequest().setOrganizations(Collections.singletonList(organizationKey)); - Organizations.SearchWsResponse searchWsResponse = service().search(request); - Assertions.assertThat(searchWsResponse.getOrganizationsList()).isEmpty(); - return this; - } - - public OrganizationTester assertThatMemberOf(Organizations.Organization organization, Users.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, Users.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 users = service().searchMembers(new SearchMembersRequest() - .setQ(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 groups = session.wsClient().users().groups(new GroupsRequest() - .setLogin(userLogin) - .setOrganization(organization != null ? organization.getKey() : null) - .setQ("Members") - .setSelected("selected")) - .getGroupsList(); - Assertions.assertThat(groups).hasSize(isMember ? 1 : 0); - } - - public OrganizationsService service() { - return session.wsClient().organizations(); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/PermissionTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/PermissionTester.java deleted file mode 100644 index 380371b2311..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/PermissionTester.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.Permissions.PermissionTemplate; -import org.sonarqube.ws.Projects.CreateWsResponse.Project; -import org.sonarqube.ws.Users; -import org.sonarqube.ws.client.permissions.AddUserToTemplateRequest; -import org.sonarqube.ws.client.permissions.ApplyTemplateRequest; -import org.sonarqube.ws.client.permissions.CreateTemplateRequest; -import org.sonarqube.ws.client.permissions.PermissionsService; - -import static com.sonar.orchestrator.container.Server.ADMIN_LOGIN; -import static java.util.Arrays.stream; - -public class PermissionTester { - - private static final AtomicInteger ID_GENERATOR = new AtomicInteger(); - - private final TesterSession session; - - PermissionTester(TesterSession session) { - this.session = session; - } - - @SafeVarargs - public final PermissionTemplate generateTemplate(Consumer... populators) { - return generateTemplate(null, populators); - } - - @SafeVarargs - public final PermissionTemplate generateTemplate(@Nullable Organizations.Organization organization, Consumer... populators) { - int id = ID_GENERATOR.getAndIncrement(); - String name = "template" + id; - CreateTemplateRequest request = new CreateTemplateRequest() - .setName(name) - .setOrganization(organization != null ? organization.getKey() : null); - stream(populators).forEach(p -> p.accept(request)); - PermissionTemplate template = service().createTemplate(request).getPermissionTemplate(); - // Give browse and admin permissions to admin in order to allow admin wsclient to perform any operation on created projects - addUserToTemplate(organization, ADMIN_LOGIN, template, "user"); - addUserToTemplate(organization, ADMIN_LOGIN, template, "admin"); - return template; - } - - public void addUserToTemplate(Users.CreateWsResponse.User user, PermissionTemplate template, String permission) { - addUserToTemplate(null, user, template, permission); - } - - public void addUserToTemplate(@Nullable Organizations.Organization organization, Users.CreateWsResponse.User user, PermissionTemplate template, String permission) { - addUserToTemplate(organization, user.getLogin(), template, permission); - } - - private void addUserToTemplate(@Nullable Organizations.Organization organization, String userLogin, PermissionTemplate template, String permission) { - service().addUserToTemplate(new AddUserToTemplateRequest() - .setOrganization(organization != null ? organization.getKey() : null) - .setLogin(userLogin) - .setTemplateName(template.getName()) - .setPermission(permission)); - } - - public void applyTemplate(PermissionTemplate template, Project project) { - applyTemplate(null, template, project); - } - - public void applyTemplate(@Nullable Organizations.Organization organization, PermissionTemplate template, Project project) { - service().applyTemplate( - new ApplyTemplateRequest() - .setOrganization(organization != null ? organization.getKey() : null) - .setTemplateName(template.getName()) - .setProjectKey(project.getKey())); - } - - public PermissionsService service() { - return session.wsClient().permissions(); - } - -} 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 deleted file mode 100644 index 21443871a10..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/ProjectTester.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.Components; -import org.sonarqube.ws.Organizations; -import org.sonarqube.ws.Projects; -import org.sonarqube.ws.client.HttpException; -import org.sonarqube.ws.client.components.ShowRequest; -import org.sonarqube.ws.client.projects.CreateRequest; -import org.sonarqube.ws.client.projects.DeleteRequest; -import org.sonarqube.ws.client.projects.ProjectsService; -import org.sonarqube.ws.client.projects.SearchRequest; - -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(new SearchRequest().setQualifiers(singletonList("TRK"))).getComponentsList().forEach(p -> - service.delete(new DeleteRequest().setProject(p.getKey()))); - } - - @SafeVarargs - public final Projects.CreateWsResponse.Project provision(Consumer... populators) { - return provision(null, populators); - } - - @SafeVarargs - public final Projects.CreateWsResponse.Project provision(@Nullable Organizations.Organization organization, Consumer... populators) { - int id = ID_GENERATOR.getAndIncrement(); - CreateRequest request = new CreateRequest() - .setProject("key" + id) - .setName("Name " + id) - .setOrganization(organization != null ? organization.getKey() : null); - stream(populators).forEach(p -> p.accept(request)); - - return session.wsClient().projects().create(request).getProject(); - } - - public boolean exists(String projectKey) { - try { - Components.ShowWsResponse response = session.wsClient().components().show(new ShowRequest().setComponent(projectKey)); - return response.getComponent() != null; - } catch (HttpException e) { - if (e.code() == 404) { - return false; - } - throw new IllegalStateException(e); - } - } -} 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 deleted file mode 100644 index de6d0d33655..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QGateTester.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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 java.util.function.Consumer; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.sonarqube.ws.Organizations; -import org.sonarqube.ws.Projects.CreateWsResponse.Project; -import org.sonarqube.ws.client.qualitygates.CreateRequest; -import org.sonarqube.ws.client.qualitygates.DestroyRequest; -import org.sonarqube.ws.client.qualitygates.ListRequest; -import org.sonarqube.ws.client.qualitygates.QualitygatesService; -import org.sonarqube.ws.client.qualitygates.SelectRequest; -import org.sonarqube.ws.client.qualitygates.SetAsDefaultRequest; - -import static java.util.Arrays.stream; -import static org.sonarqube.ws.Qualitygates.CreateResponse; -import static org.sonarqube.ws.Qualitygates.ListWsResponse; - -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() { - List builtInQualityGates = session.wsClient().qualitygates().list(new ListRequest()).getQualitygatesList().stream() - .filter(ListWsResponse.QualityGate::getIsBuiltIn) - .collect(Collectors.toList()); - if (builtInQualityGates.size() == 1) { - session.wsClient().qualitygates().setAsDefault(new SetAsDefaultRequest().setId(Long.toString(builtInQualityGates.get(0).getId()))); - } - session.wsClient().qualitygates().list(new ListRequest()).getQualitygatesList().stream() - .filter(qualityGate -> !qualityGate.getIsDefault()) - .filter(qualityGate -> !qualityGate.getIsBuiltIn()) - .forEach(qualityGate -> session.wsClient().qualitygates().destroy(new DestroyRequest().setId(Long.toString(qualityGate.getId())))); - } - - public CreateResponse generate() { - return generate(null); - } - - @SafeVarargs - public final CreateResponse generate(@Nullable Organizations.Organization organization, Consumer... populators) { - int id = ID_GENERATOR.getAndIncrement(); - CreateRequest request = new CreateRequest() - .setName("QualityGate " + id) - .setOrganization(organization != null ? organization.getKey() : null); - stream(populators).forEach(p -> p.accept(request)); - return session.wsClient().qualitygates().create(request); - } - - public void associateProject(CreateResponse qualityGate, Project project) { - associateProject(null, qualityGate, project); - } - - public void associateProject(@Nullable Organizations.Organization organization, CreateResponse qualityGate, Project project) { - service().select(new SelectRequest() - .setOrganization(organization != null ? organization.getKey() : null) - .setGateId(String.valueOf(qualityGate.getId())) - .setProjectKey(project.getKey())); - } - - public static class ListResponse { - - @SerializedName("default") - private final String defaultQGate; - @SerializedName("qualitygates") - private final List qualityGates = new ArrayList<>(); - - public ListResponse(String defaultQGate) { - this.defaultQGate = defaultQGate; - } - - public List 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/QModelTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QModelTester.java deleted file mode 100644 index 49243a18035..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QModelTester.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.base.Joiner; - -import static com.google.common.base.Preconditions.checkState; - -public class QModelTester { - - private static final String DEV_COST_PROPERTY = "sonar.technicalDebt.developmentCost"; - private static final String RATING_GRID_PROPERTY = "sonar.technicalDebt.ratingGrid"; - private static final String DEV_COST_LANGUAGE_PROPERTY = "languageSpecificParameters"; - private static final String DEV_COST_LANGUAGE_NAME_PROPERTY = DEV_COST_LANGUAGE_PROPERTY + ".0.language"; - private static final String DEV_COST_LANGUAGE_COST_PROPERTY = DEV_COST_LANGUAGE_PROPERTY + ".0.man_days"; - private static final Joiner COMMA_JOINER = Joiner.on(","); - - private final TesterSession session; - - QModelTester(TesterSession session) { - this.session = session; - } - - public void updateDevelopmentCost(int developmentCost) { - session.settings().setGlobalSettings(DEV_COST_PROPERTY, Integer.toString(developmentCost)); - } - - public void updateLanguageDevelopmentCost(String language, int developmentCost) { - session.settings().setGlobalSettings(DEV_COST_LANGUAGE_PROPERTY, "0"); - session.settings().setGlobalSettings(DEV_COST_LANGUAGE_NAME_PROPERTY, language); - session.settings().setGlobalSettings(DEV_COST_LANGUAGE_COST_PROPERTY, Integer.toString(developmentCost)); - } - - public void updateRatingGrid(Double... ratingGrid) { - checkState(ratingGrid.length == 4, "Rating grid must contains 4 values"); - session.settings().setGlobalSettings(RATING_GRID_PROPERTY, COMMA_JOINER.join(ratingGrid)); - } -} 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 deleted file mode 100644 index 7378ffd1860..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.Common; -import org.sonarqube.ws.Organizations.Organization; -import org.sonarqube.ws.Projects.CreateWsResponse.Project; -import org.sonarqube.ws.Qualityprofiles.CreateWsResponse.QualityProfile; -import org.sonarqube.ws.Rules; -import org.sonarqube.ws.client.HttpException; -import org.sonarqube.ws.client.qualityprofiles.ActivateRuleRequest; -import org.sonarqube.ws.client.qualityprofiles.AddProjectRequest; -import org.sonarqube.ws.client.qualityprofiles.CreateRequest; -import org.sonarqube.ws.client.qualityprofiles.DeactivateRuleRequest; -import org.sonarqube.ws.client.qualityprofiles.QualityprofilesService; -import org.sonarqube.ws.client.rules.SearchRequest; - -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(Consumer... populators) { - return createXooProfile(null, populators); - } - - @SafeVarargs - public final QualityProfile createXooProfile(@Nullable Organization organization, Consumer... populators) { - int id = ID_GENERATOR.getAndIncrement(); - CreateRequest request = new CreateRequest() - .setOrganization(organization == null ? null : organization.getKey()) - .setLanguage("xoo") - .setName("Profile" + id); - stream(populators).forEach(p -> p.accept(request)); - return service().create(request).getProfile(); - } - - public QProfileTester activateRule(QualityProfile profile, String ruleKey) { - return activateRule(profile.getKey(), ruleKey); - } - - public QProfileTester activateRule(String profileKey, String ruleKey) { - ActivateRuleRequest request = new ActivateRuleRequest() - .setKey(profileKey) - .setRule(ruleKey); - service().activateRule(request); - return this; - } - - public QProfileTester activateRule(QualityProfile profile, String ruleKey, String severity) { - return activateRule(profile.getKey(), ruleKey, severity); - } - - public QProfileTester activateRule(String profileKey, String ruleKey, String severity) { - ActivateRuleRequest request = new ActivateRuleRequest() - .setKey(profileKey) - .setRule(ruleKey) - .setSeverity(severity); - service().activateRule(request); - return this; - } - - public QProfileTester deactivateRule(QualityProfile profile, String ruleKey) { - service().deactivateRule(new DeactivateRuleRequest().setKey(profile.getKey()).setRule(ruleKey)); - return this; - } - - public QProfileTester assignQProfileToProject(QualityProfile profile, Project project) { - service().addProject(new AddProjectRequest() - .setProject(project.getKey()) - .setKey(profile.getKey())); - return this; - } - - public QProfileTester assertThatNumberOfActiveRulesEqualsTo(QualityProfile profile, int expectedActiveRules) { - return assertThatNumberOfActiveRulesEqualsTo(profile.getKey(), expectedActiveRules); - } - - public QProfileTester assertThatNumberOfActiveRulesEqualsTo(String profileKey, int expectedActiveRules) { - try { - List facetIds = asList("active_severities", "repositories", "languages", "severities", "statuses", "types"); - SearchRequest request = new SearchRequest() - .setQprofile(profileKey) - .setActivation("true") - .setFacets(facetIds) - .setF(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/SelenideConfig.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SelenideConfig.java deleted file mode 100644 index 65696d65689..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SelenideConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.codeborne.selenide.Configuration; -import com.codeborne.selenide.WebDriverRunner; -import com.sonar.orchestrator.Orchestrator; -import java.util.Locale; -import java.util.stream.Collectors; -import org.openqa.selenium.WebDriver; - -import static java.util.Arrays.stream; - -public class SelenideConfig { - - private enum Browser { - FIREFOX("(v46 and lower)"), - MARIONETTE("(recent Firefox, require Geckodriver)"), - CHROME("(require Chromedriver)"); - - private final String label; - - Browser(String label) { - this.label = label; - } - - static Browser of(String s) { - try { - return Browser.valueOf(s.toUpperCase(Locale.US)); - } catch (Exception e) { - throw new IllegalArgumentException("Invalid browser: " + s + ". Supported values are " + - stream(values()).map(b -> b.name() + " " + b.label).collect(Collectors.joining(", "))); - } - } - } - - public static WebDriver configure(Orchestrator orchestrator) { - String browserKey = orchestrator.getConfiguration().getString("orchestrator.browser", Browser.FIREFOX.name()); - Browser browser = Browser.of(browserKey); - Configuration.browser = browser.name(); - Configuration.baseUrl = orchestrator.getServer().getUrl(); - Configuration.timeout = 8_000; - Configuration.reportsFolder = "build/screenshots"; - Configuration.screenshots = true; - Configuration.captureJavascriptErrors = true; - Configuration.savePageSource = true; - Configuration.browserSize = "1280x1024"; - return getWebDriver(); - } - - static WebDriver getWebDriver() { - return WebDriverRunner.getWebDriver(); - } -} 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 deleted file mode 100644 index 7bd447d2b39..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SettingTester.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.settings.ListDefinitionsRequest; -import org.sonarqube.ws.client.settings.ResetRequest; -import org.sonarqube.ws.client.settings.SetRequest; -import org.sonarqube.ws.client.settings.SettingsService; - -import static java.util.Arrays.asList; - -public class SettingTester { - - private static final Set 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 settingKeys = Stream.concat( - session.wsClient().settings().listDefinitions(new ListDefinitionsRequest()).getDefinitionsList() - .stream() - .filter(def -> def.getType() != Settings.Type.LICENSE) - .map(Settings.Definition::getKey), - EMAIL_SETTINGS.stream()) - .collect(Collectors.toList()); - session.wsClient().settings().reset(new ResetRequest().setKeys(settingKeys)); - } - - public void resetSettings(String... keys){ - session.wsClient().settings().reset(new ResetRequest().setKeys(asList(keys))); - } - - public void resetProjectSettings(String projectKey, String... keys){ - session.wsClient().settings().reset(new ResetRequest().setComponent(projectKey).setKeys(asList(keys))); - } - - public void setGlobalSetting(String key, @Nullable String value) { - setSetting(null, key, value); - } - - public void setGlobalSettings(String... keyValues) { - for (int i = 0; i < keyValues.length; i += 2) { - setSetting(null, keyValues[i], keyValues[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(new ResetRequest().setKeys(asList(key)).setComponent(componentKey)); - } else { - session.wsClient().settings().set(new SetRequest().setKey(key).setValue(value).setComponent(componentKey)); - } - } - -} 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 deleted file mode 100644 index a3287db9f2f..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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 : - *
    - *
  • enabling the organization feature by default
  • - *
  • clean-up of organizations between tests
  • - *
  • clean-up of users between tests
  • - *
  • clean-up of session when opening a browser (cookies, local storage)
  • - *
  • quick access to {@link WsClient} instances
  • - *
  • clean-up of defined settings. Properties that are not defined by a plugin are not reset.
  • - *
  • helpers to generate organizations and users
  • - *
- * - * 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}. - * - * Not supported: - *
    - *
  • clean-up global settings
  • - *
  • clean-up system administrators/roots
  • - *
  • clean-up default organization
  • - *
  • clean-up the properties that are not defined (no PropertyDefinition)
  • - *
- */ -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()}. - *

- * 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(); - webhooks().deleteAllGlobal(); - } - - 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(); - // /projects is used as on SonarCloud instance, the "/" is redirected to SonarCloud website - return Navigation.create(orchestrator, "/projects"); - } - - 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 QModelTester qModel() { - return rootSession.qModel(); - } - - @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(); - } - - @Override - public WebhookTester webhooks() { - return rootSession.webhooks(); - } - - @Override - public PermissionTester permissions() { - return rootSession.permissions(); - } - - 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 QModelTester qModel() { - return new QModelTester(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); - } - - @Override - public WebhookTester webhooks() { - return new WebhookTester(this); - } - - @Override - public PermissionTester permissions() { - return new PermissionTester(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 deleted file mode 100644 index b3f2fbcbb3c..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/TesterSession.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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(); - - QModelTester qModel(); - - QProfileTester qProfiles(); - - UserTester users(); - - SettingTester settings(); - - QGateTester qGates(); - - WebhookTester webhooks(); - - PermissionTester permissions(); - -} 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 deleted file mode 100644 index c911e9f8076..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.Users; -import org.sonarqube.ws.Users.CreateWsResponse.User; -import org.sonarqube.ws.client.PostRequest; -import org.sonarqube.ws.client.organizations.AddMemberRequest; -import org.sonarqube.ws.client.usergroups.AddUserRequest; -import org.sonarqube.ws.client.users.CreateRequest; -import org.sonarqube.ws.client.users.SearchRequest; -import org.sonarqube.ws.client.users.UsersService; - -import static java.util.Arrays.stream; - -public class UserTester { - - private static final AtomicInteger ID_GENERATOR = new AtomicInteger(); - private static final String DEFAULT_ORGANIZATION_KEY = "default-organization"; - - private final TesterSession session; - - UserTester(TesterSession session) { - this.session = session; - } - - void deleteAll() { - session.wsClient().users().search(new SearchRequest()).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).failIfNotSuccessful(); - }); - } - - @SafeVarargs - public final User generate(Consumer... populators) { - int id = ID_GENERATOR.getAndIncrement(); - String login = "login" + id; - CreateRequest request = new CreateRequest() - .setLogin(login) - .setPassword(login) - .setName("name" + id) - .setEmail(id + "@test.com"); - stream(populators).forEach(p -> p.accept(request)); - return service().create(request).getUser(); - } - - /** - * For standalone mode only - */ - @SafeVarargs - public final User generateAdministrator(Consumer... populators) { - User user = generate(populators); - session.wsClient().permissions().addUser(new org.sonarqube.ws.client.permissions.AddUserRequest().setLogin(user.getLogin()).setPermission("admin")); - session.wsClient().userGroups().addUser(new AddUserRequest().setLogin(user.getLogin()).setName("sonar-administrators")); - return user; - } - - @SafeVarargs - public final User generateAdministrator(Organizations.Organization organization, Consumer... populators) { - String organizationKey = organization.getKey(); - User user = generate(populators); - session.wsClient().organizations().addMember(new AddMemberRequest().setOrganization(organizationKey).setLogin(user.getLogin())); - session.wsClient().userGroups().addUser(new AddUserRequest() - .setOrganization(organizationKey) - .setLogin(user.getLogin()) - .setName("Owners")); - return user; - } - - @SafeVarargs - public final User generateAdministratorOnDefaultOrganization(Consumer... populators) { - User user = generate(populators); - session.wsClient().organizations().addMember(new AddMemberRequest().setOrganization(DEFAULT_ORGANIZATION_KEY).setLogin(user.getLogin())); - session.wsClient().userGroups().addUser(new AddUserRequest() - .setOrganization(DEFAULT_ORGANIZATION_KEY) - .setLogin(user.getLogin()) - .setName("sonar-administrators")); - return user; - } - - @SafeVarargs - public final User generateMember(Organizations.Organization organization, Consumer... populators) { - User user = generate(populators); - session.wsClient().organizations().addMember(new AddMemberRequest().setOrganization(organization.getKey()).setLogin(user.getLogin())); - return user; - } - - public UsersService service() { - return session.wsClient().users(); - } - - public Optional getByLogin(String login) { - List users = session.wsClient().users().search(new SearchRequest().setQ(login)).getUsersList(); - if (users.size() == 1) { - return Optional.of(users.get(0)); - } - return Optional.empty(); - } - - public final String generateLogin() { - int id = ID_GENERATOR.getAndIncrement(); - return "login" + id; - } - - public final String generateProviderId() { - int id = ID_GENERATOR.getAndIncrement(); - return "providerId" + id; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/WebhookTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/WebhookTester.java deleted file mode 100644 index 5b0382051cf..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/WebhookTester.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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 javax.annotation.Nullable; -import org.sonarqube.ws.Organizations.Organization; -import org.sonarqube.ws.Projects.CreateWsResponse.Project; -import org.sonarqube.ws.Webhooks.CreateWsResponse.Webhook; -import org.sonarqube.ws.Webhooks.Delivery; -import org.sonarqube.ws.client.webhooks.CreateRequest; -import org.sonarqube.ws.client.webhooks.DeleteRequest; -import org.sonarqube.ws.client.webhooks.DeliveriesRequest; -import org.sonarqube.ws.client.webhooks.DeliveryRequest; -import org.sonarqube.ws.client.webhooks.ListRequest; -import org.sonarqube.ws.client.webhooks.WebhooksService; - -import static java.util.Arrays.stream; -import static java.util.Objects.requireNonNull; -import static org.assertj.core.api.Assertions.assertThat; - -public class WebhookTester { - private static final AtomicInteger ID_GENERATOR = new AtomicInteger(); - - private final TesterSession session; - - WebhookTester(TesterSession session) { - this.session = session; - } - - public WebhooksService service() { - return session.wsClient().webhooks(); - } - - public Webhook generate(Consumer... populators) { - return generate(null, null, populators); - } - - public Webhook generate(Organization organization, Consumer... populators) { - return generate(organization, null, populators); - } - - public Webhook generate(Project project, Consumer... populators) { - return generate(null, project, populators); - } - - @SafeVarargs - public final Webhook generate( - @Nullable Organization organization, - @Nullable Project project, - Consumer... populators - ) { - int id = ID_GENERATOR.getAndIncrement(); - CreateRequest request = new CreateRequest() - .setName("Webhook " + id) - .setUrl("https://webhook-" + id) - .setProject(project != null ? project.getKey(): null) - .setOrganization(organization != null ? organization.getKey() : null); - stream(populators).forEach(p -> p.accept(request)); - return service().create(request).getWebhook(); - } - - public void deleteAllGlobal() { - service().list(new ListRequest()).getWebhooksList().forEach(p -> - service().delete(new DeleteRequest().setWebhook(p.getKey())) - ); - } - - public List getPersistedDeliveries(Project project) { - DeliveriesRequest deliveriesReq = new DeliveriesRequest().setComponentKey(project.getKey()); - return service().deliveries(deliveriesReq).getDeliveriesList(); - } - - public Delivery getPersistedDeliveryByName(Project project, String webhookName) { - List deliveries = getPersistedDeliveries(project); - Optional delivery = deliveries.stream().filter(d -> d.getName().equals(webhookName)).findFirst(); - assertThat(delivery).isPresent(); - return delivery.get(); - } - - public Delivery getDetailOfPersistedDelivery(Delivery delivery) { - Delivery detail = service().delivery(new DeliveryRequest().setDeliveryId(delivery.getId())).getDelivery(); - return requireNonNull(detail); - } - - public void assertThatPersistedDeliveryIsValid(Delivery delivery, @Nullable Project project, @Nullable String url) { - assertThat(delivery.getId()).isNotEmpty(); - assertThat(delivery.getName()).isNotEmpty(); - assertThat(delivery.hasSuccess()).isTrue(); - assertThat(delivery.getHttpStatus()).isGreaterThanOrEqualTo(200); - assertThat(delivery.getDurationMs()).isGreaterThanOrEqualTo(0); - assertThat(delivery.getAt()).isNotEmpty(); - if (project != null) { - assertThat(delivery.getComponentKey()).isEqualTo(project.getKey()); - } - if (url != null) { - assertThat(delivery.getUrl()).startsWith(url); - } - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/XooProjectBuilder.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/XooProjectBuilder.java deleted file mode 100644 index 36deec644d6..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/XooProjectBuilder.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; - -import static java.util.Arrays.asList; - -public class XooProjectBuilder { - private final String key; - private final List moduleKeys = new ArrayList<>(); - private int filesPerModule = 1; - private Properties projectProperties = new Properties(); - - public XooProjectBuilder(String projectKey) { - this.key = projectKey; - } - - public XooProjectBuilder addModules(String key, String... otherKeys) { - this.moduleKeys.add(key); - this.moduleKeys.addAll(asList(otherKeys)); - return this; - } - - public XooProjectBuilder setFilesPerModule(int i) { - this.filesPerModule = i; - return this; - } - - public XooProjectBuilder addProjectProperties(String... keyValueProperties) { - for (int i = 0; i < keyValueProperties.length; i += 2) { - this.projectProperties.setProperty(keyValueProperties[i], keyValueProperties[i + 1]); - } - return this; - } - - public File build(File dir) { - for (String moduleKey : moduleKeys) { - generateModule(moduleKey, new File(dir, moduleKey), new Properties()); - } - projectProperties.setProperty("sonar.modules", StringUtils.join(moduleKeys, ",")); - generateModule(key, dir, projectProperties); - return dir; - } - - private void generateModule(String key, File dir, Properties additionalProps) { - try { - File sourceDir = new File(dir, "src"); - FileUtils.forceMkdir(sourceDir); - for (int i = 0; i < filesPerModule; i++) { - File sourceFile = new File(sourceDir, "File" + i + ".xoo"); - FileUtils.write(sourceFile, "content of " + sourceFile.getName()); - - File measuresFile = new File(sourceFile + ".measures"); - FileUtils.write(measuresFile, "ncloc:10\n" + - "comment_lines:3\n"); - } - Properties props = new Properties(); - props.setProperty("sonar.projectKey", key); - props.setProperty("sonar.projectName", key); - props.setProperty("sonar.projectVersion", "1.0"); - props.setProperty("sonar.sources", sourceDir.getName()); - props.putAll(additionalProps); - File propsFile = new File(dir, "sonar-project.properties"); - try (OutputStream output = FileUtils.openOutputStream(propsFile)) { - props.store(output, "generated"); - } - } catch (IOException e) { - throw new IllegalStateException(e); - } - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/package-info.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/package-info.java deleted file mode 100644 index 374b92e509e..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTaskItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTaskItem.java deleted file mode 100644 index af001cdcf01..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTaskItem.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; - -public class BackgroundTaskItem { - - private final SelenideElement elt; - - public BackgroundTaskItem(SelenideElement elt) { - this.elt = elt; - } - - public SelenideElement getComponent() { - return elt.$("td:nth-child(2)"); - } - - public BackgroundTaskItem openActions() { - elt.$(".js-task-action > .dropdown-toggle").click(); - elt.$(".js-task-action .menu").shouldBe(Condition.visible); - return this; - } - - public BackgroundTaskItem openScannerContext() { - elt.$(".js-task-show-scanner-context").click(); - Selenide.$(".js-task-scanner-context").shouldBe(Condition.visible); - return this; - } - - public BackgroundTaskItem assertScannerContextContains(String text) { - Selenide.$(".js-task-scanner-context").should(Condition.text(text)); - return this; - } - - public BackgroundTaskItem openErrorStacktrace() { - elt.$(".js-task-show-stacktrace").click(); - Selenide.$(".js-task-stacktrace").shouldBe(Condition.visible); - return this; - } - - public BackgroundTaskItem assertErrorStacktraceContains(String text) { - Selenide.$(".js-task-stacktrace").should(Condition.text(text)); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTasksPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTasksPage.java deleted file mode 100644 index 05d2b3b6865..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTasksPage.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.Selenide; -import java.util.List; -import java.util.stream.Collectors; -import org.openqa.selenium.By; - -public class BackgroundTasksPage { - - public BackgroundTasksPage() { - Selenide.$(By.cssSelector(".background-tasks")).should(Condition.exist); - } - - public ElementsCollection getTasks() { - return Selenide.$$(".background-tasks > tbody > tr"); - } - - public List getTasksAsItems() { - return getTasks() - .stream() - .map(BackgroundTaskItem::new) - .collect(Collectors.toList()); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/DocumentationPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/DocumentationPage.java deleted file mode 100644 index f2d7dab0cf1..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/DocumentationPage.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; - -public class DocumentationPage { - - public DocumentationPage() { - Selenide.$(".markdown").shouldBe(Condition.visible); - } - - public DocumentationPage shouldHaveLinks() { - Selenide.$(".api-documentation-results .list-group .list-group-item").exists(); - return this; - } - - public DocumentationPage selectLink(int index) { - Selenide.$$(".api-documentation-results .list-group .list-group-item").get(index).click(); - return this; - } - - public String getDocumentationContent() { - return Selenide.$(".markdown.cut-margins.boxed-group-inner").getText(); - } - -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/EmailAlreadyExistsPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/EmailAlreadyExistsPage.java deleted file mode 100644 index 2dfdb005d00..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/EmailAlreadyExistsPage.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class EmailAlreadyExistsPage extends Navigation { - - public EmailAlreadyExistsPage shouldHaveExistingAccount(String login) { - $(".js-existing-account").shouldHave(text(login)); - return this; - } - - public EmailAlreadyExistsPage shouldHaveNewAccount(String login) { - $(".js-new-account").shouldHave(text(login)); - return this; - } - - public void clickContinue() { - $(".js-continue").click(); - $(".js-continue").shouldNotBe(visible); - } - - public void clickCancel() { - $(".js-cancel").click(); - $(".js-cancel").shouldNotBe(visible); - } - -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/EncryptionPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/EncryptionPage.java deleted file mode 100644 index b0e80007a47..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/EncryptionPage.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; - -public class EncryptionPage extends Navigation { - - public EncryptionPage() { - Selenide.$("#encryption-page").should(Condition.exist); - } - - public SelenideElement generationForm() { - return Selenide.$("#generate-secret-key-form"); - } - - public SelenideElement newSecretKey() { - return Selenide.$("#secret-key"); - } - - public String encryptValue(String value) { - Selenide.$("#encryption-form-value").val(value); - Selenide.$("#encryption-form").submit(); - return Selenide.$("#encrypted-value").shouldBe(Condition.visible).val(); - } - - public EncryptionPage generateNewKey() { - Selenide.$("#encryption-new-key-form").submit(); - Selenide.$("#generate-secret-key-form").shouldBe(Condition.visible); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/LoginPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/LoginPage.java deleted file mode 100644 index 154386aacb0..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/LoginPage.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; - -public class LoginPage { - - public LoginPage() { - Selenide.$("#login_form").should(Condition.exist); - } - - /** - * The password is the same as the login. - */ - public Navigation submitCredentials(String login) { - return submitCredentials(login, login, Navigation.class); - } - - public Navigation submitCredentials(String login, String password) { - return submitCredentials(login, password, Navigation.class); - } - - public Navigation useOAuth2() { - Selenide.$(".oauth-providers a").click(); - return Selenide.page(Navigation.class); - } - - public Navigation useBaseAuth() { - Selenide.$(".oauth-providers a").click(); - return Selenide.page(Navigation.class); - } - - public LoginPage submitWrongCredentials(String login, String password) { - Selenide.$("#login").val(login); - Selenide.$("#password").val(password); - Selenide.$("[type=submit]").click(); - return Selenide.page(LoginPage.class); - } - - public SelenideElement getErrorMessage() { - return Selenide.$(".process-spinner-failed"); - } - - private static T submitCredentials(String login, String password, Class expectedResultPage) { - Selenide.$("#login").val(login); - Selenide.$("#password").val(password); - Selenide.$("[type=submit]").click(); - Selenide.$("#login").should(Condition.disappear); - return Selenide.page(expectedResultPage); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/MarketplacePage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/MarketplacePage.java deleted file mode 100644 index 220e2631dfe..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/MarketplacePage.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; - -public class MarketplacePage { - - public MarketplacePage() { - Selenide.$("#marketplace-page").should(Condition.exist); - } - - public MarketplacePage hasPendingPlugins(String text) { - Selenide.$(".js-pending").should(Condition.exist).shouldHave(Condition.text(text)); - return this; - } - - public MarketplacePage hasPluginsCount(int count) { - Selenide.$$("#marketplace-plugins>ul>li").shouldHaveSize(count); - return this; - } - - public MarketplacePage hasPluginWithText(String name, String text) { - getPlugin(name).shouldHave(Condition.text(text)); - return this; - } - - public MarketplacePage searchPlugin(String search) { - Selenide.$("#marketplace-search input.search-box-input").should(Condition.exist).sendKeys(search); - return this; - } - - public MarketplacePage uninstallPlugin(String name) { - getPlugin(name).$("button.js-uninstall").click(); - return this; - } - - private static SelenideElement getPlugin(String name) { - return Selenide.$$(".js-plugin-name").findBy(Condition.text(name)).should(Condition.exist).parent().parent().parent(); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java deleted file mode 100644 index 6a26317a11a..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java +++ /dev/null @@ -1,333 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; -import com.codeborne.selenide.WebDriverRunner; -import com.sonar.orchestrator.Orchestrator; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.function.Consumer; -import javax.annotation.Nullable; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.html5.WebStorage; -import org.sonarqube.qa.util.SelenideConfig; -import org.sonarqube.qa.util.pageobjects.issues.IssuesPage; -import org.sonarqube.qa.util.pageobjects.measures.MeasuresPage; -import org.sonarqube.qa.util.pageobjects.organization.MembersPage; -import org.sonarqube.qa.util.pageobjects.projects.ProjectsPage; -import org.sonarqube.qa.util.pageobjects.settings.SettingsPage; - -import static java.lang.String.format; - -public class Navigation { - - public Navigation() { - Selenide.$("#content").shouldBe(Condition.exist); - } - - public static Navigation create(Orchestrator orchestrator) { - return create(orchestrator, "/"); - } - - public static Navigation create(Orchestrator orchestrator, String path) { - WebDriver driver = SelenideConfig.configure(orchestrator); - driver.manage().deleteAllCookies(); - clearStorage(d -> d.getLocalStorage().clear()); - clearStorage(d -> d.getSessionStorage().clear()); - clearBrowserLocalStorage(); - return Selenide.open(path, Navigation.class); - } - - private static void clearStorage(Consumer cleaner) { - try { - cleaner.accept((WebStorage) WebDriverRunner.getWebDriver()); - } catch (Exception e) { - // ignore, it may occur when the first test opens browser. No pages are loaded - // and local/session storages are not available yet. - // Example with Chrome: "Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs." - } - } - - /** - * Do not call {@link #clearStorage(Consumer)} for {@link Selenide#clearBrowserLocalStorage} as it's failing on Firefox 46 - */ - private static void clearBrowserLocalStorage() { - try { - Selenide.clearBrowserLocalStorage(); - } catch (Exception e) { - // ignore, it may occur when the first test opens browser. No pages are loaded - // and local/session storages are not available yet. - // Example with Chrome: "Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs." - } - } - - public Navigation openHome() { - return open("/", Navigation.class); - } - - public DocumentationPage openDocumentation() { - return open("/documentation", DocumentationPage.class); - } - - public ProjectsPage openProjects() { - return open("/projects", ProjectsPage.class); - } - - public ProjectsPage openProjects(String organization) { - return open("/organizations/" + organization + "/projects", ProjectsPage.class); - } - - public ProjectsPage openProjectsWithQuery(String query) { - return open("/projects?" + query, ProjectsPage.class); - } - - public ProjectsPage openExploreProjects() { - return open("/explore/projects", ProjectsPage.class); - } - - public IssuesPage openIssues() { - return open("/issues", IssuesPage.class); - } - - public IssuesPage openExploreIssues() { - return open("/explore/issues", IssuesPage.class); - } - - public IssuesPage openIssues(String organization) { - return open("/organizations/" + organization + "/issues", IssuesPage.class); - } - - public IssuesPage openComponentIssues(String component) { - return open("/component_issues?id=" + component, IssuesPage.class); - } - - public ProjectDashboardPage openProjectDashboard(String projectKey) { - String url = "/dashboard?id=" + escape(projectKey); - return open(url, ProjectDashboardPage.class); - } - - public ProjectLinksPage openProjectLinks(String projectKey) { - String url = "/project/links?id=" + escape(projectKey); - return open(url, ProjectLinksPage.class); - } - - public QualityGatePage openQualityGates() { - String url = "/quality_gates"; - return open(url, QualityGatePage.class); - } - - public QualityGatePage openQualityGates(String organization) { - String url = "/organizations/" + escape(organization) + "/quality_gates"; - return open(url, QualityGatePage.class); - } - - public ProjectQualityGatePage openProjectQualityGate(String projectKey) { - String url = "/project/quality_gate?id=" + escape(projectKey); - return open(url, ProjectQualityGatePage.class); - } - - public ProjectKeyPage openProjectKey(String projectKey) { - String url = "/project/key?id=" + escape(projectKey); - return open(url, ProjectKeyPage.class); - } - - public ProjectActivityPage openProjectActivity(String projectKey) { - String url = "/project/activity?id=" + escape(projectKey); - return open(url, ProjectActivityPage.class); - } - - public MeasuresPage openProjectMeasures(String projectKey) { - String url = "/component_measures?id=" + escape(projectKey); - return open(url, MeasuresPage.class); - } - - public ProjectCodePage openCode(String projectKey) { - String url = "/code?id=" + escape(projectKey); - return open(url, ProjectCodePage.class); - } - - public ProjectCodePage openCode(String projectKey, String selected) { - String url = "/code?id=" + escape(projectKey) + "&selected=" + escape(selected); - return open(url, ProjectCodePage.class); - } - - public MembersPage openOrganizationMembers(String orgKey) { - String url = "/organizations/" + orgKey + "/members"; - return open(url, MembersPage.class); - } - - public QualityProfilePage openQualityProfile(String language, String name, String organization) { - String profileUrl = "/quality_profiles/show?language=" + escape(language) + "&name=" + escape(name); - return open("/organizations/" + organization + profileUrl, QualityProfilePage.class); - } - - public BackgroundTasksPage openBackgroundTasksPage() { - return open("/background_tasks", BackgroundTasksPage.class); - } - - public SettingsPage openSettings(@Nullable String projectKey) { - String url = projectKey != null ? ("/project/settings?id=" + escape(projectKey)) : "/settings"; - return open(url, SettingsPage.class); - } - - public EncryptionPage openEncryption() { - return open("/settings/encryption", EncryptionPage.class); - } - - public SystemInfoPage openSystemInfo() { - return open("/admin/system", SystemInfoPage.class); - } - - public MarketplacePage openMarketplace() { - return open("/admin/marketplace", MarketplacePage.class); - } - - public NotificationsPage openNotifications() { - return open("/account/notifications", NotificationsPage.class); - } - - public UsersManagementPage openUsersManagement() { - return open("/admin/users", UsersManagementPage.class); - } - - public ProjectPermissionsPage openProjectPermissions(String projectKey) { - String url = "/project_roles?id=" + escape(projectKey); - return open(url, ProjectPermissionsPage.class); - } - - public ProjectsManagementPage openProjectsManagement() { - return open("/projects_admin", ProjectsManagementPage.class); - } - - /** - * Should be replaced by an intermediary OrganizationPage - */ - public ProjectsManagementPage openProjectsManagement(String orgKey) { - return open("/organizations/" + orgKey + "/projects_management", ProjectsManagementPage.class); - } - - public WebhooksPage openWebhooks() { - return open("/admin/webhooks", WebhooksPage.class); - } - - public WebhooksPage openOrganizationWebhooks(String orgKey) { - return open("/organizations/" + orgKey + "/webhooks", WebhooksPage.class); - } - - public WebhooksPage openProjectWebhooks(String projectKey) { - return open("/project/webhooks?id=" + projectKey, WebhooksPage.class); - } - - public LoginPage openLogin() { - return open("/sessions/login", LoginPage.class); - } - - public void open(String relativeUrl) { - Selenide.open(relativeUrl); - } - - public

P open(String relativeUrl, Class

pageObjectClassClass) { - return Selenide.open(relativeUrl, pageObjectClassClass); - } - - public Navigation shouldBeLoggedIn() { - loggedInDropdown().should(Condition.visible); - return this; - } - - public Navigation shouldNotBeLoggedIn() { - logInLink().should(Condition.visible); - return this; - } - - public LoginPage logIn() { - logInLink().click(); - return Selenide.page(LoginPage.class); - } - - public Navigation logOut() { - SelenideElement dropdown = loggedInDropdown(); - // click must be on the but not on the dropdown

  • - // for compatibility with phantomjs - dropdown.find(".dropdown-toggle").click(); - dropdown.find(By.linkText("Log out")).click(); - return this; - } - - public RulesPage openRules() { - return open("/coding_rules", RulesPage.class); - } - - public SelenideElement clickOnQualityProfiles() { - return Selenide.$(By.linkText("Quality Profiles")); - } - - public SelenideElement getRightBar() { - return Selenide.$("#global-navigation .navbar-right"); - } - - public SelenideElement getFooter() { - return Selenide.$("#footer"); - } - - public SelenideElement getErrorMessage() { - return Selenide.$("#error"); - } - - public EmailAlreadyExistsPage asEmailAlreadyExistsPage() { - return new EmailAlreadyExistsPage(); - } - - public UpdateLoginPage asUpdateLoginPage() { - return new UpdateLoginPage(); - } - - private static SelenideElement logInLink() { - return Selenide.$(By.linkText("Log in")); - } - - private static SelenideElement loggedInDropdown() { - return Selenide.$(".js-user-authenticated"); - } - - /** - * Safe encoding for URL parameters - * - * @param parameter the parameter to escape value - * @return the escaped value of parameter - */ - private static String escape(String parameter) { - try { - return URLEncoder.encode(parameter, "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new IllegalArgumentException(format("Unable to escape [%s]", parameter)); - } - } - - public LoginPage shouldBeRedirectedToLogin() { - Selenide.$("#login_form").should(Condition.visible); - return Selenide.page(LoginPage.class); - } - -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/NotificationsPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/NotificationsPage.java deleted file mode 100644 index cea2d36d02a..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/NotificationsPage.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; - -public class NotificationsPage extends Navigation { - - private static final String EMAIL = "EmailNotificationChannel"; - - public NotificationsPage() { - Selenide.$("#account-page").shouldHave(Condition.text("Overall notifications")); - } - - public NotificationsPage shouldHaveGlobalNotification(String type) { - return shouldHaveGlobalNotification(type, EMAIL); - } - - public NotificationsPage shouldHaveGlobalNotification(String type, String channel) { - return shouldBeChecked(globalCheckboxSelector(type, channel)); - } - - public NotificationsPage shouldNotHaveGlobalNotification(String type) { - return shouldNotHaveGlobalNotification(type, EMAIL); - } - - public NotificationsPage shouldNotHaveGlobalNotification(String type, String channel) { - return shouldNotBeChecked(globalCheckboxSelector(type, channel)); - } - - public NotificationsPage shouldHaveProjectNotification(String project, String type, String channel) { - return shouldBeChecked(projectCheckboxSelector(project, type, channel)); - } - - public NotificationsPage shouldNotHaveProjectNotification(String project, String type, String channel) { - return shouldNotBeChecked(projectCheckboxSelector(project, type, channel)); - } - - public NotificationsPage addGlobalNotification(String type) { - return addGlobalNotification(type, EMAIL); - } - - public NotificationsPage addGlobalNotification(String type, String channel) { - shouldNotHaveGlobalNotification(type, channel); - toggleCheckbox(globalCheckboxSelector(type, channel)); - shouldHaveGlobalNotification(type, channel); - return this; - } - - public NotificationsPage removeGlobalNotification(String type) { - return removeGlobalNotification(type, EMAIL); - } - - public NotificationsPage removeGlobalNotification(String type, String channel) { - shouldHaveGlobalNotification(type, channel); - toggleCheckbox(globalCheckboxSelector(type, channel)); - shouldNotHaveGlobalNotification(type, channel); - return this; - } - - public NotificationsPage addProjectNotification(String project, String type, String channel) { - shouldNotHaveProjectNotification(project, type, channel); - toggleCheckbox(projectCheckboxSelector(project, type, channel)); - shouldHaveProjectNotification(project, type, channel); - return this; - } - - public NotificationsPage removeProjectNotification(String project, String type, String channel) { - shouldHaveProjectNotification(project, type, channel); - toggleCheckbox(projectCheckboxSelector(project, type, channel)); - shouldNotHaveProjectNotification(project, type, channel); - return this; - } - - private static String globalCheckboxSelector(String type, String channel) { - return "#global-notification-" + type + "-" + channel; - } - - private static String projectCheckboxSelector(String project, String type, String channel) { - return "#project-notification-" + project + "-" + type + "-" + channel; - } - - private NotificationsPage shouldBeChecked(String selector) { - Selenide.$(selector) - .shouldBe(Condition.visible) - .shouldHave(Condition.cssClass("icon-checkbox-checked")); - return this; - } - - private NotificationsPage shouldNotBeChecked(String selector) { - Selenide.$(selector) - .shouldBe(Condition.visible) - .shouldNotHave(Condition.cssClass("icon-checkbox-checked")); - return this; - } - - private static void toggleCheckbox(String selector) { - Selenide.$(selector).click(); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectActivityPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectActivityPage.java deleted file mode 100644 index d299e6865f3..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectActivityPage.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.Selenide; -import java.util.List; -import java.util.stream.Collectors; - -public class ProjectActivityPage { - - public ProjectActivityPage() { - Selenide.$("#project-activity").should(Condition.exist); - } - - public ElementsCollection getAnalyses() { - return Selenide.$$(".project-activity-analysis"); - } - - public List getAnalysesAsItems() { - return getAnalyses() - .stream() - .map(ProjectAnalysisItem::new) - .collect(Collectors.toList()); - } - - public ProjectAnalysisItem getLastAnalysis() { - return new ProjectAnalysisItem(Selenide.$(".project-activity-analysis")); - } - - public ProjectAnalysisItem getFirstAnalysis() { - return new ProjectAnalysisItem(Selenide.$$(".project-activity-analysis").last()); - } - - public ProjectActivityPage assertFirstAnalysisOfTheDayHasText(String day, String text) { - Selenide.$("#project-activity") - .find(".project-activity-day[data-day=\"" + day + "\"]") - .find(".project-activity-analysis") - .should(Condition.text(text)); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectAnalysisItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectAnalysisItem.java deleted file mode 100644 index ee333ff9863..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectAnalysisItem.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; - -public class ProjectAnalysisItem { - - private final SelenideElement elt; - - public ProjectAnalysisItem(SelenideElement elt) { - this.elt = elt; - } - - public ProjectAnalysisItem shouldHaveEventWithText(String text) { - elt.find(".project-activity-events").shouldHave(Condition.text(text)); - return this; - } - - public ProjectAnalysisItem shouldHaveDeleteButton() { - elt.find(".js-analysis-actions").click(); - elt.find(".js-delete-analysis").shouldBe(Condition.visible); - return this; - } - - public ProjectAnalysisItem shouldNotHaveDeleteButton() { - elt.find(".js-analysis-actions").click(); - elt.find(".js-delete-analysis").shouldNotBe(Condition.visible); - return this; - } - - public void delete() { - elt.find(".js-analysis-actions").click(); - elt.find(".js-delete-analysis").click(); - - SelenideElement modal = Selenide.$(".modal"); - modal.shouldBe(Condition.visible); - modal.find("button[type=\"submit\"]").click(); - - elt.shouldNotBe(Condition.visible); - } - - public ProjectAnalysisItem addCustomEvent(String name) { - elt.find(".js-analysis-actions").click(); - elt.find(".js-add-event").click(); - - SelenideElement modal = Selenide.$(".modal"); - modal.shouldBe(Condition.visible); - modal.find("input").setValue(name); - modal.find("button[type=\"submit\"]").click(); - - elt.find(".project-activity-event:first-child").shouldHave(Condition.text(name)); - return this; - } - - public ProjectAnalysisItem changeFirstEvent(String newName) { - SelenideElement firstEvent = elt.find(".project-activity-event:first-child"); - firstEvent.find(".js-change-event").click(); - - SelenideElement modal = Selenide.$(".modal"); - modal.shouldBe(Condition.visible); - modal.find("input").setValue(newName); - modal.find("button[type=\"submit\"]").click(); - - firstEvent.shouldHave(Condition.text(newName)); - return this; - } - - public ProjectAnalysisItem deleteFirstEvent() { - int eventsCount = elt.findAll(".project-activity-event").size(); - - SelenideElement firstEvent = elt.find(".project-activity-event:first-child"); - firstEvent.find(".js-delete-event").click(); - - SelenideElement modal = Selenide.$(".modal"); - modal.shouldBe(Condition.visible); - modal.find("button[type=\"submit\"]").click(); - - elt.findAll(".project-activity-event").shouldHaveSize(eventsCount - 1); - - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java deleted file mode 100644 index eab80acfcc2..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; - -import static com.codeborne.selenide.Selenide.$; - -public class ProjectCodePage { - - public ProjectCodePage openFirstComponent() { - Selenide.$$(".code-name-cell a").first().click(); - return this; - } - - public ProjectCodePage search(String query) { - $(".code-search .search-box-input").val(query); - return this; - } - - public ProjectCodePage shouldHaveComponent(String name) { - $(".code-components").shouldHave(Condition.text(name)); - return this; - } - - public ProjectCodePage shouldHaveCode(String code) { - $(".code-components .source-viewer").shouldHave(Condition.text(code)); - return this; - } - - public ProjectCodePage shouldHaveBreadcrumbs(String... breadcrumbs) { - for (String breadcrumb : breadcrumbs) { - $(".code-breadcrumbs").shouldHave(Condition.text(breadcrumb)); - } - return this; - } - - public ProjectCodePage shouldSearchResult(String name) { - $(".code-search-with-results").shouldHave(Condition.text(name)); - return this; - } - - public SourceViewer getSourceViewer() { - return new SourceViewer($(".code-components .source-viewer")); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectDashboardPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectDashboardPage.java deleted file mode 100644 index 8f0eebd853a..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectDashboardPage.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; -import java.util.Arrays; -import org.openqa.selenium.By; - -import static org.assertj.core.api.Assertions.assertThat; - - -public class ProjectDashboardPage { - - public ProjectDashboardPage() { - Selenide.$(".overview").shouldBe(Condition.visible); - } - - public SelenideElement getLinesOfCode() { - SelenideElement element = Selenide.$("#overview-ncloc"); - element.shouldBe(Condition.visible); - return element; - } - - public SelenideElement getLanguageDistribution() { - SelenideElement element = Selenide.$("#overview-language-distribution"); - element.shouldBe(Condition.visible); - return element; - } - - public SelenideElement getOverviewMeasure(String measure) { - ElementsCollection measures = Selenide.$$(".overview-domain-measure"); - return measures.find(Condition.text(measure)).shouldBe(Condition.visible); - } - - private static SelenideElement getTagsMeta() { - SelenideElement element = Selenide.$(".overview-meta-tags"); - element.shouldBe(Condition.visible); - return element; - } - - public ProjectDashboardPage shouldHaveTags(String... tags) { - String tagsList = String.join(", ", Arrays.asList(tags)); - getTagsMeta().$(".tags-list > span").should(Condition.text(tagsList)); - return this; - } - - public ProjectDashboardPage shouldNotBeEditable() { - SelenideElement tagsElem = getTagsMeta(); - tagsElem.$("button").shouldNot(Condition.exist); - tagsElem.$("div.multi-select").shouldNot(Condition.exist); - return this; - } - - public ProjectDashboardPage shouldBeEditable() { - SelenideElement tagsElem = getTagsMeta(); - tagsElem.$("button").shouldBe(Condition.visible); - return this; - } - - public ProjectDashboardPage openTagEditor() { - 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 = getTagsMeta(); - tagsElem.$("div.multi-select").shouldBe(Condition.visible); - return tagsElem.$$("ul.menu a").get(idx); - } - - public ProjectDashboardPage sendKeysToTagsInput(CharSequence... charSequences) { - SelenideElement tagsInput = getTagsMeta().find("input"); - tagsInput.sendKeys(charSequences); - return this; - } - - public ProjectDashboardPage hasQualityGateLink(String name, String link) { - SelenideElement elem = Selenide.$$(".overview-meta-card") - .findBy(Condition.text("Quality Gate")).should(Condition.exist) - .find(By.linkText(name)).should(Condition.exist); - assertThat(elem.attr("href")).endsWith(link); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectKeyPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectKeyPage.java deleted file mode 100644 index e8b5492b3e7..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectKeyPage.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class ProjectKeyPage { - - public ProjectKeyPage() { - $("#project-key").should(Condition.exist); - } - - public ProjectKeyPage assertSimpleUpdate() { - $("#update-key-new-key").shouldBe(visible); - $("#update-key-submit").shouldBe(visible); - return this; - } - - public ProjectKeyPage trySimpleUpdate(String newKey) { - $("#update-key-new-key").val(newKey); - $("#update-key-submit").click(); - $(".modal").shouldBe(visible); - $(".modal button[type=\"submit\"]").click(); - return this; - } - - public ProjectKeyPage openFineGrainedUpdate() { - $("#update-key-tab-fine").click(); - $("#project-key-fine-grained-update").shouldBe(visible); - return this; - } - - public ProjectKeyPage tryFineGrainedUpdate(String key, String newKey) { - SelenideElement form = $(".js-fine-grained-update[data-key=\"" + key + "\"]"); - form.shouldBe(visible); - - form.$("input").val(newKey); - form.$("button").click(); - - $(".modal").shouldBe(visible); - $(".modal button[type=\"submit\"]").click(); - return this; - } - - public ProjectKeyPage assertBulkChange() { - $("#bulk-update-replace").shouldBe(visible); - $("#bulk-update-by").shouldBe(visible); - $("#bulk-update-see-results").shouldBe(visible); - return this; - } - - public ProjectKeyPage simulateBulkChange(String replace, String by) { - $("#bulk-update-replace").val(replace); - $("#bulk-update-by").val(by); - $("#bulk-update-see-results").click(); - - $("#bulk-update-simulation").shouldBe(visible); - return this; - } - - public ProjectKeyPage assertBulkChangeSimulationResult(String oldKey, String newKey) { - SelenideElement row = $("#bulk-update-results").$("[data-key=\"" + oldKey + "\"]"); - row.$(".js-old-key").should(Condition.text(oldKey)); - row.$(".js-new-key").should(Condition.text(newKey)); - return this; - } - - public ProjectKeyPage assertDuplicated(String oldKey) { - SelenideElement row = $("#bulk-update-results").$("[data-key=\"" + oldKey + "\"]"); - row.$(".js-new-key").$(".badge-danger").shouldBe(visible); - return this; - } - - public ProjectKeyPage confirmBulkUpdate() { - $("#bulk-update-confirm").click(); - return this; - } - - public ProjectKeyPage assertSuccessfulBulkUpdate() { - $(".process-spinner") - .shouldBe(visible) - .shouldHave(Condition.text("The key has successfully been updated for all required resources")); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinkItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinkItem.java deleted file mode 100644 index 7b144079c49..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinkItem.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.SelenideElement; -import org.openqa.selenium.NoSuchElementException; - -public class ProjectLinkItem { - - private final SelenideElement elt; - - public ProjectLinkItem(SelenideElement elt) { - this.elt = elt; - } - - public SelenideElement getName() { - return elt.$(".js-name"); - } - - public SelenideElement getType() { - try { - return elt.$(".js-type"); - } catch (NoSuchElementException e) { - return null; - } - } - - public SelenideElement getUrl() { - return elt.$(".js-url"); - } - - public SelenideElement getDeleteButton() { - return elt.$(".js-delete-button"); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinksPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinksPage.java deleted file mode 100644 index fd8bb42438f..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinksPage.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.Selenide; -import java.util.List; -import java.util.stream.Collectors; - -public class ProjectLinksPage { - - public ProjectLinksPage() { - Selenide.$("#project-links").should(Condition.exist); - } - - public ElementsCollection getLinks() { - return Selenide.$$("#project-links tbody tr"); - } - - public List getLinksAsItems() { - return getLinks() - .stream() - .map(ProjectLinkItem::new) - .collect(Collectors.toList()); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectPermissionsPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectPermissionsPage.java deleted file mode 100644 index f5b2e2e0ffe..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectPermissionsPage.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; - -public class ProjectPermissionsPage { - - public ProjectPermissionsPage() { - Selenide.$("#project-permissions-page").should(Condition.exist); - } - - public ProjectPermissionsPage shouldBePublic() { - Selenide.$("#visibility-public .icon-radio.is-checked").shouldBe(Condition.visible); - return this; - } - - public ProjectPermissionsPage shouldBePrivate() { - Selenide.$("#visibility-private .icon-radio.is-checked").shouldBe(Condition.visible); - return this; - } - - public ProjectPermissionsPage turnToPublic() { - Selenide.$("#visibility-public").click(); - Selenide.$("#confirm-turn-to-public").click(); - shouldBePublic(); - return this; - } - - public ProjectPermissionsPage turnToPrivate() { - Selenide.$("#visibility-private").click(); - shouldBePrivate(); - return this; - } - - public ProjectPermissionsPage shouldNotAllowPrivate() { - Selenide.$("#visibility-private").shouldHave(Condition.cssClass("text-muted")); - Selenide.$(".upgrade-organization-box").shouldBe(Condition.visible); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectQualityGatePage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectQualityGatePage.java deleted file mode 100644 index fbf186b6830..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectQualityGatePage.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; - -public class ProjectQualityGatePage { - - public ProjectQualityGatePage() { - Selenide.$("#project-quality-gate").should(Condition.exist); - } - - public SelenideElement getSelectedQualityGate() { - return Selenide.$(".Select-value-label"); - } - - public void assertNotSelected() { - Selenide.$(".Select-placeholder").should(Condition.exist); - Selenide.$(".Select-value-label").shouldNot(Condition.exist); - } - - public void setQualityGate(String name) { - Selenide.$(".Select-input input").val(name).pressEnter(); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectsManagementPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectsManagementPage.java deleted file mode 100644 index ecf7bc4dbda..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectsManagementPage.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; - -public class ProjectsManagementPage { - - public ProjectsManagementPage() { - Selenide.$("#projects-management-page").should(Condition.exist); - } - - public ProjectsManagementPage shouldHaveProjectsCount(int count) { - Selenide.$$("#projects-management-page-projects tbody tr").shouldHaveSize(count); - return this; - } - - public ProjectsManagementPage shouldHaveProject(String key) { - Selenide.$("#projects-management-page-projects").shouldHave(Condition.text(key)); - return this; - } - - public ProjectsManagementPage createProject(String key, String name, String visibility) { - Selenide.$("#create-project").click(); - Selenide.$("#create-project-name").val(key); - Selenide.$("#create-project-key").val(name); - Selenide.$("#visibility-" + visibility).click(); - Selenide.$("#create-project-submit").submit(); - return this; - } - - public ProjectsManagementPage bulkApplyPermissionTemplate(String template) { - Selenide.$(".js-bulk-apply-permission-template").click(); - Selenide.$(".modal .Select-value").click(); - Selenide.$$(".modal .Select-option").findBy(Condition.text(template)).click(); - Selenide.$(".modal-foot button").click(); - Selenide.$(".modal-body .alert-success").shouldBe(Condition.visible); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityGatePage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityGatePage.java deleted file mode 100644 index 6c1ad63a38e..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityGatePage.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class QualityGatePage { - public QualityGatePage() { - $("#quality-gates-page").shouldBe(visible); - } - - public QualityGatePage countQualityGates(Integer count) { - $$("#quality-gates-page .list-group-item").shouldHaveSize(count); - return this; - } - - public QualityGatePage canCreateQG() { - $("#quality-gate-add").should(exist).shouldBe(visible); - return this; - } - - public QualityGatePage createQG(String name) { - $("#quality-gate-add").click(); - $(".modal-head").should(exist).shouldHave(text("Create Quality Gate")); - $("#quality-gate-form-name").sendKeys(name); - $(".modal form").submit(); - return this; - } - - public QualityGatePage canNotCreateQG() { - $("#quality-gate-add").shouldNot(exist); - return this; - } - - public QualityGatePage displayQualityGateDetail(String qualityGateName) { - $(".layout-page-main-header").shouldHave(text(qualityGateName)); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityProfilePage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityProfilePage.java deleted file mode 100644 index 2184ce4a581..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityProfilePage.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; - -public class QualityProfilePage { - public QualityProfilePage() { - Selenide.$("#quality-profile").shouldBe(Condition.visible); - } - - public QualityProfilePage shouldHaveMissingSonarWayRules(Integer nbRules) { - Selenide.$(".quality-profile-rules-sonarway-missing") - .shouldBe(Condition.visible) - .shouldHave(Condition.text(nbRules.toString())); - return this; - } - - public RulesPage showMissingSonarWayRules() { - Selenide.$(".quality-profile-rules-sonarway-missing") - .shouldBe(Condition.visible).$("[data-test=\"rules\"]").click(); - return Selenide.page(RulesPage.class); - } - - public QualityProfilePage shouldHaveAssociatedProject(String projectName) { - Selenide.$(".js-profile-project").shouldHave(Condition.text(projectName)); - return this; - } - - public QualityProfilePage shouldAllowToChangeProjects() { - Selenide.$(".js-change-projects").shouldBe(Condition.visible).click(); - Selenide.$("#profile-projects .select-list-list-container").shouldBe(Condition.visible); - return this; - } - - public QualityProfilePage shouldNotAllowToChangeProjects() { - Selenide.$(".js-change-projects").shouldNot(Condition.exist); - return this; - } - - public QualityProfilePage shouldNotAllowToEdit() { - Selenide.$("button.dropdown-toggle").should(Condition.exist).click(); - Selenide.$("#quality-profile-rename").shouldNot(Condition.exist); - Selenide.$("#quality-profile-activate-more-rules").shouldNot(Condition.exist); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleDetails.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleDetails.java deleted file mode 100644 index dbce1e3f64e..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleDetails.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class RuleDetails { - RuleDetails() { - $(".coding-rule-details").shouldBe(visible); - } - - public RuleDetails shouldHaveType(String type) { - $(".coding-rules-detail-property[data-meta=\"type\"]").shouldHave(text(type)); - return this; - } - - public RuleDetails shouldHaveSeverity(String severity) { - $(".coding-rules-detail-property[data-meta=\"severity\"]").shouldHave(text(severity)); - return this; - } - - public RuleDetails shouldHaveDescription(String description) { - $(".js-rule-description").shouldHave(text(description)); - return this; - } - - public RuleDetails shouldBeActivatedOn(String profileKey) { - $("#coding-rules-detail-quality-profiles [data-profile=\"" + profileKey + "\"]").shouldBe(visible); - return this; - } - - public RuleDetails shouldNotBeActivatedOn(String profileName) { - $("#coding-rules-detail-quality-profiles").shouldNotHave(text(profileName)); - return this; - } - - public RuleDetails shouldHaveTotalIssues(int issues) { - $(".js-rule-issues h3").shouldHave(text(String.valueOf(issues))); - return this; - } - - public RuleDetails shouldHaveIssuesOnProject(String projectName, int issues) { - $(".coding-rules-most-violated-projects").shouldHave( - Condition.and("", text(projectName), text(String.valueOf(issues)))); - return this; - } - - public RuleDetails shouldHaveCustomRule(String ruleKey) { - takeCustomRule(ruleKey).shouldBe(visible); - return this; - } - - public RuleDetails shouldNotHaveCustomRule(String ruleKey) { - takeCustomRule(ruleKey).shouldNotBe(visible); - return this; - } - - public RuleDetails createCustomRule(String ruleName) { - $(".js-create-custom-rule").click(); - modal().shouldBe(visible); - - $("#coding-rules-custom-rule-creation-name").val(ruleName); - $("#coding-rules-custom-rule-creation-html-description").val("description"); - $("#coding-rules-custom-rule-creation-create").click(); - - modal().shouldNotBe(visible); - return this; - } - - public RuleDetails reactivateCustomRule(String ruleName) { - $(".js-create-custom-rule").click(); - modal().shouldBe(visible); - - $("#coding-rules-custom-rule-creation-name").val(ruleName); - $("#coding-rules-custom-rule-creation-html-description").val("description"); - $("#coding-rules-custom-rule-creation-create").click(); - - modal().find(".alert-warning").shouldBe(visible); - $("#coding-rules-custom-rule-creation-reactivate").click(); - - modal().shouldNotBe(visible); - return this; - } - - public RuleDetails deleteCustomRule(String ruleKey) { - takeCustomRule(ruleKey).$(".js-delete-custom-rule").click(); - modal().shouldBe(visible); - modal().find("button").click(); - modal().shouldNotBe(visible); - return this; - } - - public RuleActivation activate() { - $("#coding-rules-quality-profile-activate").click(); - modal().shouldBe(visible); - return new RuleActivation(); - } - - private static SelenideElement modal() { - return $(".modal"); - } - - private static SelenideElement takeCustomRule(String ruleKey) { - return $("#coding-rules-detail-custom-rules tr[data-rule=\"" + ruleKey + "\"]"); - } - - private static SelenideElement getActiveProfileElement(String profileKey) { - return $("#coding-rules-detail-quality-profiles [data-profile=\"" + profileKey + "\"]"); - } - - public ExtendedDescription extendDescription() { - return new ExtendedDescription().start(); - } - - public Tags tags() { - return new Tags(); - } - - public RuleActivation changeActivationOn(String profileKey) { - getActiveProfileElement(profileKey).$(".coding-rules-detail-quality-profile-change").click(); - modal().shouldBe(visible); - return new RuleActivation(); - } - - public RuleDetails activationShouldHaveParameter(String profileKey, String parameter, String value) { - getActiveProfileElement(profileKey).$$(".coding-rules-detail-quality-profile-parameter") - .findBy(Condition.and("", text(parameter), text(value))) - .shouldBe(visible); - return this; - } - - public RuleDetails activationShouldHaveSeverity(String profileKey, String severity) { - getActiveProfileElement(profileKey).$(".coding-rules-detail-quality-profile-severity").shouldHave(text(severity)); - return this; - } - - public RuleDetails revertActivationToParentDefinition(String profileKey) { - getActiveProfileElement(profileKey).$(".coding-rules-detail-quality-profile-revert").click(); - modal().shouldBe(visible); - $(".modal button").click(); - modal().shouldNotBe(visible); - return this; - } - - public static class ExtendedDescription { - public ExtendedDescription start() { - $("#coding-rules-detail-extend-description").click(); - textArea().shouldBe(visible); - return this; - } - - public ExtendedDescription cancel() { - $("#coding-rules-detail-extend-description-cancel").click(); - textArea().shouldNotBe(visible); - return this; - } - - public ExtendedDescription type(String text) { - textArea().val(text); - return this; - } - - public ExtendedDescription submit() { - $("#coding-rules-detail-extend-description-submit").click(); - textArea().shouldNotBe(visible); - return this; - } - - public ExtendedDescription remove() { - $("#coding-rules-detail-extend-description-remove").click(); - modal().shouldBe(visible); - $("#coding-rules-detail-extend-description-remove-submit").click(); - modal().shouldNotBe(visible); - textArea().shouldNotBe(visible); - return this; - } - - private static SelenideElement textArea() { - return $("#coding-rules-detail-extend-description-text"); - } - } - - public static class Tags { - public Tags shouldHaveNoTags() { - element().shouldHave(text("No tags")); - return this; - } - - public Tags shouldHaveTags(String... tags) { - for (String tag : tags) { - element().shouldHave(text(tag)); - } - return this; - } - - public Tags edit() { - element().$("button").click(); - return this; - } - - public Tags select(String tag) { - element().$$(".menu a").findBy(text(tag)).click(); - return this; - } - - public Tags search(String query) { - element().$(".search-box-input").val(query); - return this; - } - - public Tags done() { - element().$(".search-box-input").pressEscape(); - return this; - } - - private static SelenideElement element() { - return $(".coding-rules-detail-property[data-meta=\"tags\"]"); - } - } - - public static class RuleActivation { - public RuleActivation select(String profileKey) { - $(".modal .js-profile .Select-input input").val(profileKey).pressEnter(); - return this; - } - - public RuleActivation fill(String parameter, String value) { - $(".modal-field input[name=\"" + parameter + "\"]").val(value); - return this; - } - - public RuleActivation save() { - $(".modal button").click(); - modal().shouldNotBe(visible); - return this; - } - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleItem.java deleted file mode 100644 index cdff3819744..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleItem.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.visible; - -public class RuleItem { - - private final SelenideElement elt; - - RuleItem(SelenideElement elt) { - this.elt = elt; - } - - public RuleItem filterSimilarRules(String field) { - elt.$(".js-rule-filter").click(); - elt.$(".menu a[data-field=\"" + field + "\"]").click(); - return this; - } - - public RuleDetails open() { - elt.$(".coding-rule-title a").click(); - return new RuleDetails(); - } - - public RuleItem shouldDisplayDeactivate() { - elt.$(".coding-rules-detail-quality-profile-deactivate").shouldBe(visible); - return this; - } - -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RulesPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RulesPage.java deleted file mode 100644 index 1e4e0605bf6..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RulesPage.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class RulesPage extends Navigation { - - public RulesPage() { - $("#coding-rules-page").should(exist); - } - - public int getTotal() { - // warning - number is localized - return Integer.parseInt($("#coding-rules-total").text()); - } - - public ElementsCollection getSelectedFacetItems(String facetName) { - return getFacetElement(facetName).$$(".facet.active"); - } - - public RulesPage shouldHaveTotalRules(Integer total) { - $(".js-page-counter-total").shouldHave(Condition.text(total.toString())); - return this; - } - - public RulesPage shouldDisplayRules(String... ruleKeys) { - for (String key : ruleKeys) { - getRuleElement(key).shouldBe(visible); - } - return this; - } - - public RulesPage shouldNotDisplayRules(String... ruleKeys) { - for (String key : ruleKeys) { - getRuleElement(key).shouldNotBe(visible); - } - return this; - } - - public RulesPage openFacet(String facet) { - getFacetElement(facet).$(".search-navigator-facet-header a").click(); - return this; - } - - public RulesPage selectFacetItem(String facet, String value) { - getFacetElement(facet).$(".facet[data-facet=\"" + value + "\"]").click(); - return this; - } - - public RulesPage selectInactive() { - getFacetElement("profile").$(".active .js-inactive").click(); - return this; - } - - public RulesPage shouldHaveDisabledFacet(String facet) { - $(".search-navigator-facet-box-forbidden[data-property=\"" + facet + "\"]").shouldBe(visible); - return this; - } - - public RulesPage shouldNotHaveDisabledFacet(String facet) { - $(".search-navigator-facet-box-forbidden[data-property=\"" + facet + "\"]").shouldNotBe(visible); - return this; - } - - public RuleDetails openFirstRule() { - $$(".coding-rule-title a").first().click(); - return new RuleDetails(); - } - - public RuleItem takeRule(String ruleKey) { - return new RuleItem(getRuleElement(ruleKey)); - } - - public RulesPage search(String query) { - $("#coding-rules-search .search-box-input").val(query); - return this; - } - - public RulesPage clearAllFilters() { - $("#coding-rules-clear-all-filters").click(); - return this; - } - - public RulesPage closeDetails() { - $(".js-back").click(); - $(".coding-rule-details").shouldNotBe(visible); - return this; - } - - public RulesPage activateRule(String ruleKey) { - getRuleElement(ruleKey).$(".coding-rules-detail-quality-profile-activate").click(); - $(".modal").shouldBe(visible); - $(".modal button").click(); - $(".modal").shouldNotBe(visible); - getRuleElement(ruleKey).$(".coding-rules-detail-quality-profile-activate").shouldNotBe(visible); - return this; - } - - public RulesPage deactivateRule(String ruleKey) { - getRuleElement(ruleKey).$(".coding-rules-detail-quality-profile-deactivate").click(); - $(".modal button").click(); - getRuleElement(ruleKey).$(".coding-rules-detail-quality-profile-deactivate").shouldNotBe(visible); - return this; - } - - private static SelenideElement getRuleElement(String key) { - return $(".coding-rule[data-rule=\"" + key + "\"]"); - } - - private static SelenideElement getFacetElement(String facet) { - return $(".search-navigator-facet-box[data-property=\"" + facet + "\"]"); - } - -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SourceViewer.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SourceViewer.java deleted file mode 100644 index b37270ba014..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SourceViewer.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class SourceViewer { - - private final SelenideElement el; - - SourceViewer(SelenideElement el) { - this.el = el; - } - - public SelenideElement openCoverageDetails(int line) { - this.el.$(".source-line-coverage[data-line-number=\"" + line + "\"").click(); - return $(".popup").shouldBe(visible); - } - - public SourceViewer shouldHaveNewLines(int ...lines) { - for (int line : lines) { - this.el.$(".source-line-filtered[data-line-number=\"" + line + "\"").shouldBe(visible); - } - return this; - } - - public SourceViewer shouldNotHaveNewLines(int ...lines) { - for (int line : lines) { - this.el.$(".source-line-filtered[data-line-number=\"" + line + "\"").shouldNotBe(visible); - } - return this; - } - -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPage.java deleted file mode 100644 index 857153eb517..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPage.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class SystemInfoPage { - public SystemInfoPage() { - $(".page-title").should(Condition.exist).shouldHave(Condition.text("System Info")); - } - - public SystemInfoPage shouldHaveCards(String... titles) { - getHealthCards().shouldHave(CollectionCondition.texts(titles)); - return this; - } - - public SystemInfoPageItem getCardItem(String card) { - SelenideElement cardTitle = getHealthCards().find(Condition.text(card)).should(Condition.exist); - return new SystemInfoPageItem(cardTitle.parent().parent()); - } - - private static ElementsCollection getHealthCards() { - return $$(".boxed-group-accordion-title"); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPageItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPageItem.java deleted file mode 100644 index 33987560d84..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPageItem.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; - -public class SystemInfoPageItem { - private final SelenideElement elt; - - public SystemInfoPageItem(SelenideElement elt) { - this.elt = elt; - } - - public SystemInfoPageItem shouldHaveHealth() { - elt.$(".system-info-health-info .status-indicator").should(Condition.exist); - return this; - } - - public SystemInfoPageItem shouldHaveSection(String section) { - ensureOpen(); - elt.$$("h4").findBy(Condition.text(section)).should(Condition.exist); - return this; - } - - public SystemInfoPageItem shouldNotHaveSection(String section) { - ensureOpen(); - elt.$$("h4").findBy(Condition.text(section)).shouldNot(Condition.exist); - return this; - } - - public SystemInfoPageItem shouldHaveMainSection() { - ensureOpen(); - elt.$$(".system-info-section").get(0).find("h4").shouldNot(Condition.exist); - return this; - } - - public SystemInfoPageItem shouldHaveField(String field) { - ensureOpen(); - elt.$$(".system-info-section-item-name").findBy(Condition.text(field)).should(Condition.exist); - return this; - } - - public SystemInfoPageItem shouldNotHaveField(String field) { - ensureOpen(); - elt.$$(".system-info-section-item-name").findBy(Condition.exactText(field)).shouldNot(Condition.exist); - return this; - } - - public SystemInfoPageItem shouldHaveFieldWithValue(String field, String value) { - ensureOpen(); - SelenideElement fieldElem = elt.$$(".system-info-section-item-name").findBy(Condition.text(field)).should(Condition.exist); - fieldElem.parent().parent().$$("td").shouldHaveSize(2).get(1).shouldHave(Condition.text(value)); - return this; - } - - public SystemInfoPageItem ensureOpen() { - if (!isOpen()) { - elt.click(); - elt.$(".boxed-group-inner").should(Condition.exist); - } - return this; - } - - private boolean isOpen() { - return elt.$(".boxed-group-inner").exists(); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UpdateLoginPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UpdateLoginPage.java deleted file mode 100644 index 2860ad74b4a..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UpdateLoginPage.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class UpdateLoginPage extends Navigation { - - public UpdateLoginPage shouldHaveProviderName(String providerName) { - $(".js-provider-name").shouldHave(text(providerName)); - return this; - } - - public UpdateLoginPage shouldHaveNewAccount(String login) { - $(".js-new-account").shouldHave(text(login)); - return this; - } - - public UpdateLoginPage shouldHaveOldLogin(String oldLogin) { - $(".js-old-login").shouldHave(text(oldLogin)); - return this; - } - - public UpdateLoginPage shouldHaveOldOrganizationKey(String oldOrganizationKey) { - $(".js-old-organization-key").shouldHave(text(oldOrganizationKey)); - return this; - } - - public void clickContinue() { - $(".js-continue").click(); - $(".js-continue").shouldNotBe(visible); - } - - public void clickCancel() { - $(".js-cancel").click(); - $(".js-cancel").shouldNotBe(visible); - } - -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementItem.java deleted file mode 100644 index 29e37b3d335..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementItem.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class UsersManagementItem { - private final SelenideElement elt; - - public UsersManagementItem(SelenideElement elt) { - this.elt = elt; - } - - public UsersManagementItem hasTokensCount(Integer count) { - this.elt.$(".js-user-tokens").should(Condition.exist).parent().shouldHave(Condition.text(count.toString())); - return this; - } - - public UsersManagementItem generateToken(String name) { - this.openTokenModal(); - $(".modal #generate-token-form input").should(Condition.exist).sendKeys(name); - $(".modal #generate-token-form .js-generate-token").should(Condition.exist).click(); - $(".modal code").should(Condition.exist); - getTokenRow(name).should(Condition.exist); - closeModal(); - return this; - } - - public UsersManagementItem revokeToken(String name) { - this.openTokenModal(); - SelenideElement tokenRow = getTokenRow(name).should(Condition.exist); - tokenRow.$("button").should(Condition.exist).shouldHave(Condition.text("Revoke")).click(); - tokenRow.$("button").shouldHave(Condition.text("Sure?")).click(); - getTokenRow(name).shouldNot(Condition.exist); - closeModal(); - return this; - } - - public UsersManagementItem changePassword(String oldPwd, String newPwd) { - this.elt.$("button.dropdown-toggle").should(Condition.exist).click(); - this.elt.$(".js-user-change-password").shouldBe(Condition.visible).click(); - isModalOpen("Change password"); - $(".modal #old-user-password").should(Condition.exist).sendKeys(oldPwd); - $(".modal #user-password").should(Condition.exist).sendKeys(newPwd); - $(".modal #confirm-user-password").should(Condition.exist).sendKeys(newPwd); - $(".modal .js-confirm").click(); - $(".modal").shouldNot(Condition.exist); - return this; - } - - public UsersManagementItem deactivateUser() { - this.elt.$("button.dropdown-toggle").should(Condition.exist).click(); - this.elt.$(".js-user-deactivate").should(Condition.exist).click(); - isModalOpen("Deactivate User"); - $(".modal .js-confirm").should(Condition.exist).click(); - return this; - } - - private void openTokenModal() { - if (!$(".modal").exists()) { - this.elt.$(".js-user-tokens").should(Condition.exist).click(); - } - isModalOpen("Tokens"); - } - - private static void closeModal() { - $(".modal .js-modal-close").should(Condition.exist).click(); - } - - private static void isModalOpen(String title) { - $(".modal .modal-head").should(Condition.exist).shouldHave(Condition.text(title)); - } - - private static SelenideElement getTokenRow(String name) { - return $$(".modal tr").findBy(Condition.text(name)); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementPage.java deleted file mode 100644 index 59ecb3f6ac1..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementPage.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class UsersManagementPage { - public UsersManagementPage() { - $("#users-page").shouldBe(Condition.visible); - } - - public UsersManagementPage hasUsersCount(Integer count) { - $$(".js-user-login").shouldHaveSize(count); - return this; - } - - public UsersManagementItem getUser(String login) { - SelenideElement elt = $$(".js-user-login").findBy(Condition.text(login)).should(Condition.exist); - return new UsersManagementItem(elt.parent().parent().parent()); - } - - public UsersManagementPage createUser(String login) { - $("#users-create").should(Condition.exist).click(); - $(".modal .modal-head").should(Condition.exist).shouldHave(Condition.text("Create User")); - $(".modal #create-user-login").should(Condition.exist).sendKeys(login); - $(".modal #create-user-name").should(Condition.exist).sendKeys("Name of " + login); - $(".modal #create-user-password").should(Condition.exist).sendKeys(login); - $(".modal .js-confirm").should(Condition.exist).click(); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/WebhooksPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/WebhooksPage.java deleted file mode 100644 index 1e5a225cd48..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/WebhooksPage.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects; - -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; -import java.util.Arrays; - -import static com.codeborne.selenide.Condition.cssClass; -import static com.codeborne.selenide.Condition.enabled; -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class WebhooksPage { - - public WebhooksPage() { - $(".page-header .page-title").should(exist).shouldHave(text("Webhooks")); - } - - public WebhooksPage hasWebhook(String text) { - getWebhooks().find(text(text)).should(exist); - return this; - } - - public WebhooksPage hasNoWebhooks() { - $(".boxed-group").shouldHave(text("No webhook defined")); - return this; - } - - public WebhooksPage hasLatestDelivery(String webhookName) { - getWebhook(webhookName).shouldNotHave(text("Never")); - return this; - } - - public WebhooksPage hasNoLatestDelivery(String webhookName) { - getWebhook(webhookName).shouldHave(text("Never")); - return this; - } - - public WebhooksPage countWebhooks(Integer number) { - getWebhooks().shouldHaveSize(number); - return this; - } - - public WebhooksPage createWebhook(String name, String url) { - $(".js-webhook-create").shouldBe(visible).shouldBe(enabled).shouldNotHave(cssClass("disabled")).click(); - modalShouldBeOpen("Create Webhook"); - $("#webhook-name").shouldBe(visible).sendKeys(name); - $("#webhook-url").shouldBe(visible).sendKeys(url); - $("button[type='submit']").shouldBe(visible).click(); - modalShouldBeClosed(); - return this; - } - - public WebhooksPage createIsDisabled() { - $(".js-webhook-create").shouldBe(visible).shouldHave(cssClass("disabled")).click(); - modalShouldBeClosed(); - return this; - } - - public WebhooksPage deleteWebhook(String webhookName) { - SelenideElement webhook = getWebhook(webhookName); - webhook.$(".dropdown-toggle").shouldBe(visible).click(); - webhook.$(".js-webhook-delete").shouldBe(visible).click(); - modalShouldBeOpen("Delete Webhook"); - $("button.button-red").shouldBe(visible).click(); - modalShouldBeClosed(); - return this; - } - - public DeliveriesForm showDeliveries(String webhookName) { - SelenideElement webhook = getWebhook(webhookName); - webhook.$(".dropdown-toggle").shouldBe(visible).click(); - webhook.$(".js-webhook-deliveries").shouldBe(visible).click(); - modalShouldBeOpen("Recent deliveries of " + webhookName); - return new DeliveriesForm($(".modal-body")); - } - - public static class DeliveriesForm { - private final SelenideElement elt; - - public DeliveriesForm(SelenideElement elt) { - this.elt = elt; - } - - public DeliveriesForm countDeliveries(Integer number) { - this.getDeliveries().shouldHaveSize(number); - return this; - } - - public DeliveriesForm isSuccessFull(Integer deliveryIndex) { - this.getDeliveries().get(deliveryIndex).$(".js-success").should(exist); - return this; - } - - public DeliveriesForm payloadContains(Integer deliveryIndex, String... payload) { - SelenideElement delivery = this.getDeliveries().get(deliveryIndex); - SelenideElement header = delivery.$(".boxed-group-header").should(exist); - if (!delivery.$(".boxed-group-inner").exists()) { - header.click(); - } - SelenideElement inner = delivery.$(".boxed-group-inner").shouldBe(visible); - Arrays.stream(payload).forEach(p -> inner.shouldHave(text(p))); - header.click(); - return this; - } - - private ElementsCollection getDeliveries() { - return this.elt.$$(".boxed-group-accordion"); - } - } - - private static SelenideElement getWebhook(String webhookName) { - return getWebhooks().find(text(webhookName)).should(exist); - } - - private static ElementsCollection getWebhooks() { - return $$(".boxed-group tbody tr"); - } - - private static void modalShouldBeOpen(String title) { - $(".modal-head").shouldBe(visible).shouldHave(text(title)); - } - - private static void modalShouldBeClosed() { - $(".modal-head").shouldNot(exist); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/Issue.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/Issue.java deleted file mode 100644 index b5256a93499..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/Issue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects.issues; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; - -public class Issue { - - private final SelenideElement elt; - - public Issue(SelenideElement elt) { - this.elt = elt; - } - - public Issue shouldAllowAssign() { - elt.find(".js-issue-assign").shouldBe(Condition.visible); - return this; - } - - public Issue shouldAllowChangeType() { - elt.find(".js-issue-set-type").shouldBe(Condition.visible); - return this; - } - - public Issue shouldNotAllowAssign() { - elt.find(".js-issue-assign").shouldNotBe(Condition.visible); - return this; - } - - public Issue shouldNotAllowChangeType() { - elt.find(".js-issue-set-type").shouldNotBe(Condition.visible); - return this; - } - - public Issue assigneeSearchResultCount(String query, Integer count) { - SelenideElement assignLink = elt.find(".js-issue-assign"); - assignLink.click(); - SelenideElement popupMenu = Selenide.$(".popup ul.menu").shouldBe(Condition.visible); - Selenide.$(".popup input.search-box-input").shouldBe(Condition.visible).val("").sendKeys(query); - popupMenu.$("li a[data-text='Not assigned']").shouldNot(Condition.exist); - popupMenu.$$("li").shouldHaveSize(count); - assignLink.click(); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/IssuesPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/IssuesPage.java deleted file mode 100644 index 53793043c6f..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/IssuesPage.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects.issues; - -import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.Selenide; -import java.util.List; -import java.util.stream.Collectors; - -public class IssuesPage { - - public IssuesPage() { - Selenide.$(".issues").should(Condition.exist); - } - - public List getIssues() { - return getIssuesElements() - .stream() - .map(Issue::new) - .collect(Collectors.toList()); - } - - public IssuesPage issuesCount(Integer count) { - getIssuesElements().shouldHaveSize(count); - return this; - } - - public Issue getFirstIssue() { - getIssuesElements().shouldHave(CollectionCondition.sizeGreaterThan(0)); - return new Issue(getIssuesElements().first()); - } - - public IssuesPage componentsShouldContain(String path) { - getIssuesPathComponents().forEach(element -> element.shouldHave(Condition.text(path))); - return this; - } - - public IssuesPage componentsShouldNotContain(String path) { - getIssuesPathComponents().forEach(element -> element.shouldNotHave(Condition.text(path))); - return this; - } - - public IssuesPage bulkChangeOpen() { - Selenide.$("#issues-bulk-change").shouldBe(Condition.visible).click(); - Selenide.$("#bulk-change-form").shouldBe(Condition.visible); - return this; - } - - public IssuesPage bulkChangeAssigneeSearchCount(String query, Integer count) { - Selenide.$("#issues-bulk-change-assignee .Select-input input").val(query); - Selenide.$$("#issues-bulk-change-assignee .Select-option").shouldHaveSize(count); - 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 deleted file mode 100644 index a90992b82b7..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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; diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasureContent.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasureContent.java deleted file mode 100644 index 6313f951c21..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasureContent.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects.measures; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; - -public class MeasureContent { - private final SelenideElement elt; - - public MeasureContent(SelenideElement elt) { - this.elt = elt; - } - - public MeasureContent shouldHaveTitle(String title) { - this.elt.$(".measure-details-header .measure-details-metric").should(Condition.exist).shouldHave(Condition.text(title)); - return this; - } - - public MeasureContent shouldHaveHeaderValue(String value) { - this.elt.$(".measure-details-header .measure-details-value").should(Condition.exist).shouldHave(Condition.text(value)); - return this; - } - - public MeasureContent shouldHaveFile(String path) { - this.getFiles().find(Condition.text(path)).should(Condition.exist); - return this; - } - - public MeasureContent drillDown(String item) { - this.getFiles().find(Condition.text(item)).should(Condition.exist).find("a").click(); - return this; - } - - public MeasureContent shouldDisplayCode() { - this.elt.$(".source-line-code").should(Condition.exist); - return this; - } - - private ElementsCollection getFiles() { - return this.elt.$$(".measure-details-component-row"); - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasuresPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasuresPage.java deleted file mode 100644 index b205b53eef2..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasuresPage.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects.measures; - -import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; -import com.codeborne.selenide.WebDriverRunner; -import org.openqa.selenium.Keys; -import org.openqa.selenium.interactions.Actions; - -public class MeasuresPage { - public MeasuresPage() { - Selenide.$("#component-measures").should(Condition.exist); - } - - public MeasuresPage displayBubbleChart(String title) { - SelenideElement bubblechart = Selenide.$("#component-measures .measure-overview-bubble-chart"); - bubblechart.$(".measure-overview-bubble-chart-title").shouldHave(Condition.text(title)); - return this; - } - - public MeasuresPage measureHasValue(String measure, Integer value) { - 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 = getSideBar(); - sidebar.$("#measure-" + measure + "-name").should(Condition.exist); - sidebar.$("#measure-" + measure + "-leak").should(Condition.exist).shouldHave(Condition.text(value.toString())); - return this; - } - - public MeasuresPage breadcrumbsShouldHave(String item) { - Selenide.$(".layout-page-header-panel .measure-breadcrumbs").shouldHave(Condition.text(item)); - return this; - } - - public MeasuresPage breadcrumbsShouldNotHave(String item) { - Selenide.$(".layout-page-header-panel .measure-breadcrumbs").shouldNotHave(Condition.text(item)); - return this; - } - - public MeasuresPage backShortcut() { - SelenideElement panel = Selenide.$(".layout-page-header-panel"); - - // panel.sendKeys(Keys.LEFT) does not work correctly on Chrome - // The workaround is to use Actions - // https://bugs.chromium.org/p/chromedriver/issues/detail?id=35 - Actions actions = new Actions(WebDriverRunner.getWebDriver()); - actions.moveToElement(panel); - actions.click(); - actions.sendKeys(Keys.LEFT); - actions.build().perform(); - return this; - } - - public MeasuresPage switchView(String view) { - SelenideElement select = Selenide.$(".measure-view-select").should(Condition.exist); - select.click(); - select.$(".Select-menu-outer").should(Condition.exist) - .$$(".Select-option").shouldHave(CollectionCondition.sizeGreaterThan(1)) - .find(Condition.text(view)).should(Condition.exist).click(); - return this; - } - - public MeasuresPage openFacet(String facet) { - SelenideElement facetBox = Selenide.$$(".search-navigator-facet-box").find(Condition.text(facet)); - if(!facetBox.find("search-navigator-facet-list").isDisplayed()) { - facetBox.$(".search-navigator-facet-header a").should(Condition.exist).click(); - } - return this; - } - - public MeasureContent openMeasureContent(String measure) { - SelenideElement sidebar = getSideBar(); - SelenideElement facetItem = sidebar.$("#measure-" + measure + "-name"); - facetItem.click(); - MeasureContent content = new MeasureContent(Selenide.$("#component-measures .measure-details-content").should(Condition.exist)); - content.shouldHaveTitle(facetItem.getText()); - return content; - } - - 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 deleted file mode 100644 index c4c26225451..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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; diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MemberItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MemberItem.java deleted file mode 100644 index 466620af52b..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MemberItem.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects.organization; - -import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; - -public class MemberItem { - private final SelenideElement elt; - - public MemberItem(SelenideElement elt) { - this.elt = elt; - } - - public MemberItem shouldBeNamed(String login, String name) { - ElementsCollection tds = this.elt.$$("td"); - tds.get(1).$("strong").shouldHave(Condition.text(name)); - tds.get(1).$("span").shouldHave(Condition.text(login)); - return this; - } - - public MemberItem shouldHaveGroups(Integer groups) { - ElementsCollection tds = this.elt.$$("td"); - tds.get(2).should(Condition.exist); - tds.get(2).shouldHave(Condition.text(groups.toString())); - return this; - } - - public MemberItem shouldNotHaveActions() { - this.elt.$$("td").shouldHave(CollectionCondition.sizeLessThan(3)); - return this; - } - - public MemberItem removeMembership() { - ElementsCollection tds = this.elt.$$("td"); - tds.shouldHave(CollectionCondition.sizeGreaterThan(3)); - SelenideElement actionTd = tds.get(3); - actionTd.$("button").should(Condition.exist).click(); - actionTd.$$(".menu > li > a").get(1).shouldBe(Condition.visible).click(); - SelenideElement modal = getModal("Remove user"); - modal.$("button.button-red").shouldBe(Condition.visible).click(); - return this; - } - - public MemberItem manageGroupsOpen() { - ElementsCollection tds = this.elt.$$("td"); - tds.shouldHave(CollectionCondition.sizeGreaterThan(3)); - SelenideElement actionTd = tds.get(3); - actionTd.$("button").should(Condition.exist).click(); - actionTd.$$(".menu > li > a").get(0).shouldBe(Condition.visible).click(); - getModal("Manage groups"); - return this; - } - - public MemberItem manageGroupsSelect(String group) { - SelenideElement modal = getModal("Manage groups"); - modal.$$("li").find(Condition.text(group)).shouldBe(Condition.visible).click(); - return this; - } - - public MemberItem manageGroupsSave() { - SelenideElement modal = getModal("Manage groups"); - modal.$("button[type='submit']").shouldBe(Condition.visible).click(); - return this; - } - - 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); - return form; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MembersPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MembersPage.java deleted file mode 100644 index 2674775252f..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MembersPage.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects.organization; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; - -public class MembersPage { - - public MembersPage() { - Selenide.$(".navbar-tabs a.active").shouldBe(Condition.visible).shouldHave(Condition.text("Members")); - } - - public ElementsCollection getMembers() { - return Selenide.$$("table.data tr"); - } - - public MemberItem getMembersByIdx(Integer idx) { - return new MemberItem(getMembers().get(idx)); - } - - public MembersPage shouldHaveTotal(int total) { - Selenide.$(".panel-vertical > span > strong").shouldHave(Condition.text(String.valueOf(total))); - return this; - } - - public MembersPage searchForMember(String query) { - Selenide.$(".page .search-box-input").shouldBe(Condition.visible).val("").sendKeys(query); - return this; - } - - public MembersPage canAddMember() { - Selenide.$(".page-actions").shouldBe(Condition.visible); - return this; - } - - public MembersPage canNotAddMember() { - Selenide.$(".page-actions").shouldNot(Condition.exist); - return this; - } - - public MembersPage addMember(String login) { - this.canAddMember(); - Selenide.$(".page-actions button").click(); - - SelenideElement modal = getModal("Add user"); - SelenideElement input = modal.$(".Select-input input"); - input.val(login); - modal.$("div.Select-option.is-focused").should(Condition.exist); - input.pressEnter(); - modal.$("button[type='submit']").click(); - return this; - } - - 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); - return form; - } -} 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 deleted file mode 100644 index 7257b011c3f..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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; diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/package-info.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/package-info.java deleted file mode 100644 index c5ea5a298f0..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/FacetItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/FacetItem.java deleted file mode 100644 index 42e61854354..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/FacetItem.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects.projects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; - -public class FacetItem { - - private final SelenideElement elt; - - public FacetItem(SelenideElement elt) { - this.elt = elt; - } - - public FacetItem shouldHaveValue(String key, String value) { - this.elt.$(".facet[data-key=\"" + key + "\"] .facet-stat").shouldHave(Condition.text(value)); - return this; - } - - public void selectValue(String key) { - this.elt.$(".facet[data-key=\"" + key + "\"]").click(); - } - - public FacetItem selectOptionItem(String value) { - SelenideElement selectInput = this.elt.$(".Select-input input"); - selectInput.val(value); - this.elt.$("div.Select-option.is-focused").should(Condition.exist); - selectInput.pressEnter(); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectItem.java deleted file mode 100644 index dd65fe3ec3d..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectItem.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects.projects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; - -public class ProjectItem { - - private final SelenideElement elt; - - public ProjectItem(SelenideElement elt) { - this.elt = elt; - } - - public ProjectItem shouldHaveMeasure(String metricKey, String value) { - this.elt.$(".project-card-measure[data-key=\"" + metricKey + "\"]").shouldHave(Condition.text(value)); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectsPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectsPage.java deleted file mode 100644 index b3014453aee..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectsPage.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects.projects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; -import com.codeborne.selenide.WebDriverRunner; -import org.assertj.core.api.Assertions; - -public class ProjectsPage { - - public ProjectsPage() { - Selenide.$("#projects-page").shouldBe(Condition.visible); - } - - public ElementsCollection getProjects() { - return Selenide.$$(".projects-list > .boxed-group"); - } - - public ElementsCollection getFacets() { - return Selenide.$$(".search-navigator-facet-box"); - } - - public ProjectItem getProjectByKey(String projectKey) { - SelenideElement element = getProjects().find(Condition.attribute("data-key", projectKey)); - return new ProjectItem(element); - } - - public ProjectItem getProjectByIdx(Integer idx) { - return new ProjectItem(getProjects().get(idx)); - } - - public FacetItem getFacetByProperty(String facetProperty) { - SelenideElement element = getFacets().find(Condition.attribute("data-key", facetProperty)); - return new FacetItem(element); - } - - public ProjectsPage shouldHaveTotal(int total) { - // warning - number is localized - Selenide.$("#projects-total").shouldHave(Condition.text(String.valueOf(total))); - return this; - } - - public ProjectsPage shouldDisplayAllProjects() { - Assertions.assertThat(WebDriverRunner.url()).endsWith("/projects"); - return this; - } - - public ProjectsPage shouldDisplayAllProjectsWidthSort(String sort) { - Assertions.assertThat(WebDriverRunner.url()).endsWith("/projects?sort=" + sort); - return this; - } - - public ProjectsPage shouldDisplayFavoriteProjects() { - Assertions.assertThat(WebDriverRunner.url()).endsWith("/projects/favorite"); - return this; - } - - public ProjectsPage selectAllProjects() { - Selenide.$("#all-projects").click(); - return shouldDisplayAllProjects(); - } - - public ProjectsPage selectFavoriteProjects() { - Selenide.$("#favorite-projects").click(); - return shouldDisplayFavoriteProjects(); - } - - public ProjectsPage searchProject(String search) { - SelenideElement searchInput = Selenide.$(".projects-topbar-item-search input"); - searchInput.setValue("").sendKeys(search); - return this; - } - - public ProjectsPage changePerspective(String perspective) { - SelenideElement sortSelect = getOpenTopBar().$(".js-projects-perspective-select"); - sortSelect.$(".Select-value").should(Condition.exist).click(); - sortSelect.$(".Select-option[title='" + perspective + "']").should(Condition.exist).click(); - return this; - } - - public ProjectsPage sortProjects(String sort) { - SelenideElement sortSelect = getOpenTopBar().$(".js-projects-sorting-select"); - sortSelect.$(".Select-value").should(Condition.exist).click(); - sortSelect.$(".Select-option[title='" + sort + "']").should(Condition.exist).click(); - return this; - } - - public ProjectsPage invertSorting() { - getOpenTopBar().$(".js-projects-sorting-invert").should(Condition.exist).click(); - return this; - } - - 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 deleted file mode 100644 index 420ff76dd6e..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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/PropertySetInput.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/PropertySetInput.java deleted file mode 100644 index 46f1ac6201a..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/PropertySetInput.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects.settings; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; - -public class PropertySetInput { - - private final SelenideElement elt; - - public PropertySetInput(SelenideElement elt) { - this.elt = elt; - } - - public PropertySetInput setFieldValue(int index, String fieldKey, String value) { - elt.findAll("input[name$=\"[" + fieldKey + "]\"]").get(index).val(value); - return this; - } - - public PropertySetInput setFieldValue(String fieldKey, String value) { - return setFieldValue(0, fieldKey, value); - } - - public PropertySetInput save() { - elt.find(".button-success").click(); - elt.find(".button-success").shouldNot(Condition.exist); - return this; - } -} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/SettingsPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/SettingsPage.java deleted file mode 100644 index f55d3edfa9d..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/SettingsPage.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.pageobjects.settings; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; - -import static com.codeborne.selenide.Selectors.byText; - -public class SettingsPage { - - public SettingsPage() { - Selenide.$("#settings-page").shouldBe(Condition.visible); - } - - public SettingsPage assertMenuContains(String categoryName) { - Selenide.$(".side-tabs-menu").$(By.linkText(categoryName)).shouldBe(Condition.visible); - return this; - } - - public SettingsPage assertSettingDisplayed(String settingKey) { - Selenide.$(".settings-definition[data-key='" + settingKey + "']").shouldBe(Condition.visible); - return this; - } - - public SettingsPage assertSettingNotDisplayed(String settingKey) { - Selenide.$(".settings-definition[data-key='" + settingKey + "']").shouldNotBe(Condition.visible); - return this; - } - - public SettingsPage openCategory(String categoryName) { - Selenide.$(".side-tabs-menu").$(By.linkText(categoryName)).click(); - return this; - } - - public SettingsPage assertStringSettingValue(String settingKey, String value) { - Selenide.$("input[name=\"settings[" + settingKey + "]\"]").shouldHave(Condition.exactValue(value)); - return this; - } - - public SettingsPage assertSettingValueIsNotedAsDefault(String settingKey) { - Selenide.$("[data-key=\"" + settingKey + "\"]").find(".spacer-top.note") - .shouldBe(Condition.text("(default)")); - return this; - } - - public SettingsPage assertBooleanSettingValue(String settingKey, boolean value) { - SelenideElement toggle = Selenide.$("button[name=\"settings[" + settingKey + "]\"]"); - if (value) { - toggle.shouldHave(Condition.cssClass("boolean-toggle-on")); - } else { - toggle.shouldNotHave(Condition.cssClass("boolean-toggle-on")); - } - return this; - } - - public SettingsPage assertSettingValueCanBeSaved(String settingKey) { - Selenide.$("[data-key=\"" + settingKey + "\"]").find(byText("Save")) - .should(Condition.exist) - .shouldNotBe(Condition.attribute("disabled")); - return this; - } - - public SettingsPage assertSettingValueCannotBeSaved(String settingKey) { - Selenide.$("[data-key=\"" + settingKey + "\"]").find(byText("Save")) - .should(Condition.exist) - .shouldBe(Condition.attribute("disabled")); - return this; - } - - public SettingsPage assertSettingValueCanBeReset(String settingKey) { - Selenide.$("[data-key=\"" + settingKey + "\"]").find(byText("Reset")) - .should(Condition.exist); - return this; - } - - public SettingsPage assertSettingValueCanBeCanceled(String settingKey) { - Selenide.$("[data-key=\"" + settingKey + "\"]").find(byText("Cancel")) - .should(Condition.exist); - return this; - } - - public SettingsPage assertInputCount(String settingKey, int count) { - Selenide.$("[data-key=\"" + settingKey + "\"]").findAll("input").shouldHaveSize(count); - return this; - } - - public SettingsPage changeSettingValue(String settingKey, String value) { - Selenide.$("[data-key=\"" + settingKey + "\"]").find("input").val(value); - return this; - } - - public SettingsPage changeSettingValue(String settingKey, int index, String value) { - Selenide.$("[data-key=\"" + settingKey + "\"]").findAll("input").get(index).val(value); - return this; - } - - public SettingsPage clickOnCancel(String settingKey) { - click(Selenide.$("[data-key=\"" + settingKey + "\"]").find(byText("Cancel"))); - return this; - } - - public SettingsPage removeFirstValue(String settingKey) { - click(Selenide.$("[data-key=\"" + settingKey + "\"]").find(".js-remove-value")); - return this; - } - - public SettingsPage sendDeleteKeyToSettingField(String settingKey) { - Selenide.$("[data-key=\"" + settingKey + "\"]").find("input").sendKeys(Keys.BACK_SPACE); - return this; - } - - public SettingsPage setStringValue(String settingKey, String value) { - SelenideElement setting = Selenide.$(".settings-definition[data-key=\"" + settingKey + "\"]"); - setting.find("input").val(value); - setting.find(".button-success").click(); - setting.find(".button-success").shouldNot(Condition.exist); - return this; - } - - public PropertySetInput getPropertySetInput(String settingKey) { - SelenideElement setting = Selenide.$(".settings-definition[data-key=\"" + settingKey + "\"]"); - return new PropertySetInput(setting); - } - - private void click(SelenideElement selenideElement){ - // FIXME Temporary fix to correctly scroll in Firefox 46 - Selenide.executeJavaScript("arguments[0].click()", selenideElement); - } - -} 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 deleted file mode 100644 index 60225f5a5fd..00000000000 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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/settings.gradle b/settings.gradle index 89982b9cbb4..85cd824e976 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,7 +11,6 @@ include 'server:sonar-db-migration' include 'server:sonar-main' include 'server:sonar-plugin-bridge' include 'server:sonar-process' -include 'server:sonar-qa-util' include 'server:sonar-server' include 'server:sonar-server-common' include 'server:sonar-vsts' -- 2.39.5