return open(url, MembersPage.class);
}
+ public QualityProfilePage openQualityProfile(String language, String name, String organization) {
+ String profileUrl = "/quality_profiles/show?language=" + language + "&name=" + name;
+ return open("/organizations/" + organization + profileUrl , QualityProfilePage.class);
+ }
+
public BackgroundTasksPage openBackgroundTasksPage() {
return open("/background_tasks", BackgroundTasksPage.class);
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonarqube.pageobjects;
+
+import com.codeborne.selenide.Condition;
+
+import static com.codeborne.selenide.Selenide.$;
+import static com.codeborne.selenide.Selenide.page;
+
+public class QualityProfilePage {
+ public QualityProfilePage() {
+ $("#quality-profile").shouldBe(Condition.visible);
+ }
+
+ public QualityProfilePage shouldHaveMissingSonarWayRules(Integer nbRules) {
+ $(".quality-profile-rules-sonarway-missing")
+ .shouldBe(Condition.visible)
+ .$("a").shouldHave(Condition.text(nbRules.toString()));
+ return this;
+ }
+
+ public RulesPage showMissingSonarWayRules() {
+ $(".quality-profile-rules-sonarway-missing")
+ .shouldBe(Condition.visible).$("a").click();
+ $(".coding-rules").shouldBe(Condition.visible);
+ return page(RulesPage.class);
+ }
+}
import com.codeborne.selenide.Condition;
import com.codeborne.selenide.ElementsCollection;
+import com.codeborne.selenide.SelenideElement;
import java.util.List;
import java.util.stream.Collectors;
import org.openqa.selenium.By;
+import static com.codeborne.selenide.Condition.text;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.$$;
// warning - number is localized
return Integer.parseInt($("#coding-rules-total").text());
}
+
+ public ElementsCollection getSelectedFacetItems(String facetName) {
+ SelenideElement facet = $(".search-navigator-facet-box[data-property='"+ facetName+"']").shouldBe(Condition.visible);
+ return facet.$$(".js-facet.active");
+ }
+
+ public RulesPage shouldHaveTotalRules(Integer total) {
+ $("#coding-rules-total").shouldHave(text(total.toString()));
+ return this;
+ }
}
import com.codeborne.selenide.Condition;
import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.build.SonarScanner;
+import org.sonarqube.pageobjects.QualityProfilePage;
+import org.sonarqube.pageobjects.RulesPage;
import org.sonarqube.tests.Category6Suite;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.sonarqube.tests.Tester;
import org.sonarqube.ws.Organizations;
+import org.sonarqube.ws.QualityProfiles;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.qualityprofile.AddProjectRequest;
import org.sonarqube.ws.client.qualityprofile.ChangeParentRequest;
tester.runHtmlTests("/organization/OrganizationQualityProfilesUiTest/should_restore.html");
}
+ @Test
+ public void testSonarWayComparison() {
+ QualityProfiles.CreateWsResponse.QualityProfile xooProfile = tester.qProfiles().createXooProfile(organization);
+ tester.qProfiles().activateRule(xooProfile, "xoo:OneBugIssuePerLine");
+ tester.qProfiles().activateRule(xooProfile, "xoo:OneIssuePerLine");
+ Navigation nav = tester.openBrowser();
+ QualityProfilePage qpPage = nav.openQualityProfile(xooProfile.getLanguage(), xooProfile.getName(), organization.getKey());
+ qpPage.shouldHaveMissingSonarWayRules(2);
+ RulesPage rPage = qpPage.showMissingSonarWayRules();
+ rPage.shouldHaveTotalRules(2);
+ rPage.getSelectedFacetItems("qprofile")
+ .shouldHaveSize(2)
+ .findBy(Condition.cssClass("compare")).has(Condition.text("Sonar way"));
+ }
+
private void createProfile(String language, String name) {
tester.wsClient().wsConnector().call(
new PostRequest("api/qualityprofiles/create")