diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-08-28 13:23:49 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-09-13 15:50:48 +0200 |
commit | c7697d5366690c86f4a772c74fc621ee5d7b3edb (patch) | |
tree | 372b05928ccde7e500d6fae4723db45fe3b671d2 | |
parent | 4ea4aed0658603aa168d900d8c0dbac2dd0752c8 (diff) | |
download | sonarqube-c7697d5366690c86f4a772c74fc621ee5d7b3edb.tar.gz sonarqube-c7697d5366690c86f4a772c74fc621ee5d7b3edb.zip |
Refactor a few integration tests of Quality profiles
3 files changed, 17 insertions, 55 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java index 25c126037bb..a1583020954 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java @@ -22,20 +22,19 @@ package org.sonarqube.tests.qualityProfile; import com.codeborne.selenide.Condition; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import org.sonarqube.tests.Category4Suite; import org.junit.After; import org.junit.Before; import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; +import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.tests.Category4Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.client.PostRequest; -import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.qualityprofile.AddProjectRequest; import org.sonarqube.ws.client.qualityprofile.ChangeParentRequest; import org.sonarqube.ws.client.qualityprofile.CreateRequest; -import org.sonarqube.pageobjects.Navigation; import util.user.UserRule; import static com.codeborne.selenide.Selenide.$; @@ -51,8 +50,6 @@ public class QualityProfilesUiTest { @Rule public UserRule userRule = UserRule.from(orchestrator); - private static WsClient adminWsClient; - @Rule public Tester tester = new Tester(orchestrator).disableOrganizations(); diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java index ed468a40874..9abacf1bf29 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java @@ -32,7 +32,9 @@ import org.sonarqube.ws.QualityProfiles.SearchWsResponse; import org.sonarqube.ws.QualityProfiles.ShowResponse; import org.sonarqube.ws.QualityProfiles.ShowResponse.CompareToSonarWay; import org.sonarqube.ws.QualityProfiles.ShowResponse.QualityProfile; +import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.PostRequest; +import org.sonarqube.ws.client.WsResponse; import org.sonarqube.ws.client.qualityprofile.SearchWsRequest; import org.sonarqube.ws.client.qualityprofile.ShowRequest; @@ -99,8 +101,19 @@ public class QualityProfilesWsTest { assertThat(tester.qProfiles().service().show(new ShowRequest() .setProfile(xooProfile.getKey()) .setCompareToSonarWay(true)).getCompareToSonarWay()) - .extracting(CompareToSonarWay::getProfile, CompareToSonarWay::getProfileName, CompareToSonarWay::getMissingRuleCount) - .containsExactly(sonarWay.getKey(), sonarWay.getName(), 0L); + .extracting(CompareToSonarWay::getProfile, CompareToSonarWay::getProfileName, CompareToSonarWay::getMissingRuleCount) + .containsExactly(sonarWay.getKey(), sonarWay.getName(), 0L); + } + + @Test + public void redirect_profiles_export_to_api_qualityprofiles_export() { + WsResponse response = tester.wsClient().wsConnector().call(new GetRequest("profiles/export?language=xoo&format=XooFakeExporter")); + assertThat(response.isSuccessful()).isTrue(); + assertThat(response.requestUrl()).endsWith("/api/qualityprofiles/export?language=xoo&format=XooFakeExporter"); + assertThat(response.content()).isEqualTo("xoo -> Basic -> 1"); + + // Check 'name' parameter is taken into account + assertThat(tester.wsClient().wsConnector().call(new GetRequest("profiles/export?language=xoo&name=empty&format=XooFakeExporter")).content()).isEqualTo("xoo -> empty -> 0"); } private SearchWsResponse.QualityProfile getProfile(Organization organization, Predicate<SearchWsResponse.QualityProfile> filter) { diff --git a/tests/src/test/java/org/sonarqube/tests/ws/RoutesTest.java b/tests/src/test/java/org/sonarqube/tests/ws/RoutesTest.java deleted file mode 100644 index 6db3a4d30b6..00000000000 --- a/tests/src/test/java/org/sonarqube/tests/ws/RoutesTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.tests.ws; - -import com.sonar.orchestrator.Orchestrator; -import org.sonarqube.tests.Category4Suite; -import org.junit.ClassRule; -import org.junit.Test; -import org.sonarqube.ws.client.GetRequest; -import org.sonarqube.ws.client.WsResponse; - -import static org.assertj.core.api.Assertions.assertThat; -import static util.ItUtils.newWsClient; - -public class RoutesTest { - - @ClassRule - public static final Orchestrator orchestrator = Category4Suite.ORCHESTRATOR; - - @Test - public void redirect_profiles_export_to_api_qualityprofiles_export() { - WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("profiles/export?language=xoo&format=XooFakeExporter")); - assertThat(response.isSuccessful()).isTrue(); - assertThat(response.requestUrl()).endsWith("/api/qualityprofiles/export?language=xoo&format=XooFakeExporter"); - assertThat(response.content()).isEqualTo("xoo -> Basic -> 1"); - - // Check 'name' parameter is taken into account - assertThat(newWsClient(orchestrator).wsConnector().call(new GetRequest("profiles/export?language=xoo&name=empty&format=XooFakeExporter")).content()).isEqualTo("xoo -> empty -> 0"); - } - -} |