diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-01-04 10:12:01 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-01-05 17:30:17 +0100 |
commit | de4bd7cf6c5ac9dba12040b19635ab4305ce2bde (patch) | |
tree | 478f5732b6470741991507e2822d757adc2c65de /it | |
parent | 094521fd01f0f37ad98e2b28217a3f569be14609 (diff) | |
download | sonarqube-de4bd7cf6c5ac9dba12040b19635ab4305ce2bde.tar.gz sonarqube-de4bd7cf6c5ac9dba12040b19635ab4305ce2bde.zip |
SONAR-7131 WS components/show show one component and its ancestors
Diffstat (limited to 'it')
-rw-r--r-- | it/it-tests/src/test/java/it/Category4Suite.java | 6 | ||||
-rw-r--r-- | it/it-tests/src/test/java/it/component/ComponentsWsTest.java | 70 | ||||
-rw-r--r-- | it/it-tests/src/test/java/it/component/ProjectSearchTest.java (renamed from it/it-tests/src/test/java/it/componentSearch/ProjectSearchTest.java) | 2 |
3 files changed, 75 insertions, 3 deletions
diff --git a/it/it-tests/src/test/java/it/Category4Suite.java b/it/it-tests/src/test/java/it/Category4Suite.java index c1460fc9218..620f4379cab 100644 --- a/it/it-tests/src/test/java/it/Category4Suite.java +++ b/it/it-tests/src/test/java/it/Category4Suite.java @@ -22,7 +22,8 @@ package it; import com.sonar.orchestrator.Orchestrator; import it.analysisExclusion.FileExclusionsTest; import it.analysisExclusion.IssueExclusionsTest; -import it.componentSearch.ProjectSearchTest; +import it.component.ComponentsWsTest; +import it.component.ProjectSearchTest; import it.dbCleaner.PurgeTest; import it.duplication.CrossProjectDuplicationsOnRemoveFileTest; import it.duplication.CrossProjectDuplicationsTest; @@ -50,8 +51,9 @@ import static util.ItUtils.xooPlugin; // user ForceAuthenticationTest.class, FavouriteTest.class, - // project search + // component search ProjectSearchTest.class, + ComponentsWsTest.class, // update center UpdateCenterTest.class, // analysis exclusion diff --git a/it/it-tests/src/test/java/it/component/ComponentsWsTest.java b/it/it-tests/src/test/java/it/component/ComponentsWsTest.java new file mode 100644 index 00000000000..3a518d41f04 --- /dev/null +++ b/it/it-tests/src/test/java/it/component/ComponentsWsTest.java @@ -0,0 +1,70 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 it.component; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarRunner; +import it.Category4Suite; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import org.sonarqube.ws.WsComponents; +import org.sonarqube.ws.client.WsClient; +import org.sonarqube.ws.client.component.SearchWsRequest; +import org.sonarqube.ws.client.component.ShowWsRequest; +import util.ItUtils; + +import static java.util.Collections.singletonList; +import static org.assertj.core.api.Assertions.assertThat; +import static util.ItUtils.projectDir; + +public class ComponentsWsTest { + @ClassRule + public static final Orchestrator orchestrator = Category4Suite.ORCHESTRATOR; + private static final String FILE_KEY = "sample:src/main/xoo/sample/Sample.xoo"; + WsClient wsClient; + + @Before + public void inspectProject() { + orchestrator.resetData(); + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample"))); + + wsClient = ItUtils.newAdminWsClient(orchestrator); + } + + @Test + public void show() { + WsComponents.ShowWsResponse response = wsClient.components().show(new ShowWsRequest().setKey(FILE_KEY)); + + assertThat(response).isNotNull(); + assertThat(response.getComponent().getKey()).isEqualTo(FILE_KEY); + assertThat(response.getAncestorsList()).isNotEmpty(); + } + + @Test + public void search() { + WsComponents.SearchWsResponse response = wsClient.components().search(new SearchWsRequest() + .setQualifiers(singletonList("FIL"))); + + assertThat(response).isNotNull(); + assertThat(response.getComponents(0).getKey()).isEqualTo(FILE_KEY); + } +} diff --git a/it/it-tests/src/test/java/it/componentSearch/ProjectSearchTest.java b/it/it-tests/src/test/java/it/component/ProjectSearchTest.java index e13068469af..5e5f47fedb7 100644 --- a/it/it-tests/src/test/java/it/componentSearch/ProjectSearchTest.java +++ b/it/it-tests/src/test/java/it/component/ProjectSearchTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package it.componentSearch; +package it.component; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarRunner; |