aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2017-02-16 17:10:48 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2017-02-22 17:53:38 +0100
commitda6b8dc9f8919b2b80e48dd1c2fa9bd5d5340710 (patch)
tree39e632c6c192d8de7a4879f93e07fc922cb60ff2 /it
parent305be7ad0ece1ff44d6a705d4a6691e8906cdfb0 (diff)
downloadsonarqube-da6b8dc9f8919b2b80e48dd1c2fa9bd5d5340710.tar.gz
sonarqube-da6b8dc9f8919b2b80e48dd1c2fa9bd5d5340710.zip
SONAR-8773 Move WS update_key and bulk_update_key to api/projects
Diffstat (limited to 'it')
-rw-r--r--it/it-tests/src/test/java/it/Category4Suite.java4
-rw-r--r--it/it-tests/src/test/java/it/component/ComponentsWsTest.java37
-rw-r--r--it/it-tests/src/test/java/it/component/ProjectsWsTest.java (renamed from it/it-tests/src/test/java/it/component/ProjectSearchTest.java)53
3 files changed, 54 insertions, 40 deletions
diff --git a/it/it-tests/src/test/java/it/Category4Suite.java b/it/it-tests/src/test/java/it/Category4Suite.java
index 101287d0099..c2705a97589 100644
--- a/it/it-tests/src/test/java/it/Category4Suite.java
+++ b/it/it-tests/src/test/java/it/Category4Suite.java
@@ -23,7 +23,7 @@ import com.sonar.orchestrator.Orchestrator;
import it.analysisExclusion.FileExclusionsTest;
import it.analysisExclusion.IssueExclusionsTest;
import it.component.ComponentsWsTest;
-import it.component.ProjectSearchTest;
+import it.component.ProjectsWsTest;
import it.dbCleaner.PurgeTest;
import it.duplication.CrossProjectDuplicationsOnRemoveFileTest;
import it.duplication.CrossProjectDuplicationsTest;
@@ -69,7 +69,7 @@ import static util.ItUtils.xooPlugin;
BaseIdentityProviderTest.class,
OAuth2IdentityProviderTest.class,
// component search
- ProjectSearchTest.class,
+ ProjectsWsTest.class,
ComponentsWsTest.class,
// analysis exclusion
FileExclusionsTest.class,
diff --git a/it/it-tests/src/test/java/it/component/ComponentsWsTest.java b/it/it-tests/src/test/java/it/component/ComponentsWsTest.java
index 605accaeb0b..4820f670cf8 100644
--- a/it/it-tests/src/test/java/it/component/ComponentsWsTest.java
+++ b/it/it-tests/src/test/java/it/component/ComponentsWsTest.java
@@ -28,12 +28,9 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonarqube.ws.WsComponents;
-import org.sonarqube.ws.WsComponents.BulkUpdateKeyWsResponse.Key;
import org.sonarqube.ws.client.WsClient;
-import org.sonarqube.ws.client.component.BulkUpdateWsRequest;
import org.sonarqube.ws.client.component.SearchWsRequest;
import org.sonarqube.ws.client.component.ShowWsRequest;
-import org.sonarqube.ws.client.component.UpdateWsRequest;
import util.ItUtils;
import static java.util.Collections.singletonList;
@@ -44,7 +41,6 @@ public class ComponentsWsTest {
@ClassRule
public static final Orchestrator orchestrator = Category4Suite.ORCHESTRATOR;
private static final String FILE_KEY = "sample:src/main/xoo/sample/Sample.xoo";
- private static final String PROJECT_KEY = "sample";
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -76,37 +72,4 @@ public class ComponentsWsTest {
assertThat(response).isNotNull();
assertThat(response.getComponents(0).getKey()).isEqualTo(FILE_KEY);
}
-
- @Test
- public void update_key() {
- String newProjectKey = "another_project_key";
- WsComponents.Component project = wsClient.components().show(new ShowWsRequest().setKey(PROJECT_KEY)).getComponent();
- assertThat(project.getKey()).isEqualTo(PROJECT_KEY);
-
- wsClient.components().updateKey(UpdateWsRequest.builder()
- .setKey(PROJECT_KEY)
- .setNewKey(newProjectKey)
- .build());
-
- assertThat(wsClient.components().show(new ShowWsRequest().setId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey);
- }
-
- @Test
- public void bulk_update_key() {
- String newProjectKey = "another_project_key";
- WsComponents.Component project = wsClient.components().show(new ShowWsRequest().setKey(PROJECT_KEY)).getComponent();
- assertThat(project.getKey()).isEqualTo(PROJECT_KEY);
-
- WsComponents.BulkUpdateKeyWsResponse result = wsClient.components().bulkUpdateKey(BulkUpdateWsRequest.builder()
- .setKey(PROJECT_KEY)
- .setFrom(PROJECT_KEY)
- .setTo(newProjectKey)
- .build());
-
- assertThat(wsClient.components().show(new ShowWsRequest().setId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey);
- assertThat(result.getKeysCount()).isEqualTo(1);
- assertThat(result.getKeys(0))
- .extracting(Key::getKey, Key::getNewKey, Key::getDuplicate)
- .containsOnlyOnce(PROJECT_KEY, newProjectKey, false);
- }
}
diff --git a/it/it-tests/src/test/java/it/component/ProjectSearchTest.java b/it/it-tests/src/test/java/it/component/ProjectsWsTest.java
index 48941aa2214..a8f760178d9 100644
--- a/it/it-tests/src/test/java/it/component/ProjectSearchTest.java
+++ b/it/it-tests/src/test/java/it/component/ProjectsWsTest.java
@@ -31,20 +31,38 @@ import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.junit.Before;
import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonarqube.ws.WsComponents;
+import org.sonarqube.ws.WsProjects.BulkUpdateKeyWsResponse;
+import org.sonarqube.ws.WsProjects.BulkUpdateKeyWsResponse.Key;
+import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.ws.client.component.ShowWsRequest;
+import org.sonarqube.ws.client.project.BulkUpdateKeyWsRequest;
+import org.sonarqube.ws.client.project.UpdateKeyWsRequest;
+import util.ItUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static util.ItUtils.projectDir;
-public class ProjectSearchTest {
+public class ProjectsWsTest {
@ClassRule
public static final Orchestrator orchestrator = Category4Suite.ORCHESTRATOR;
+ private static final String PROJECT_KEY = "sample";
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private WsClient wsClient;
@Before
public void inspectProject() {
orchestrator.resetData();
orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")));
+
+ wsClient = ItUtils.newAdminWsClient(orchestrator);
}
/**
@@ -71,4 +89,37 @@ public class ProjectSearchTest {
httpclient.getConnectionManager().shutdown();
}
}
+
+ @Test
+ public void update_key() {
+ String newProjectKey = "another_project_key";
+ WsComponents.Component project = wsClient.components().show(new ShowWsRequest().setKey(PROJECT_KEY)).getComponent();
+ assertThat(project.getKey()).isEqualTo(PROJECT_KEY);
+
+ wsClient.projects().updateKey(UpdateKeyWsRequest.builder()
+ .setKey(PROJECT_KEY)
+ .setNewKey(newProjectKey)
+ .build());
+
+ assertThat(wsClient.components().show(new ShowWsRequest().setId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey);
+ }
+
+ @Test
+ public void bulk_update_key() {
+ String newProjectKey = "another_project_key";
+ WsComponents.Component project = wsClient.components().show(new ShowWsRequest().setKey(PROJECT_KEY)).getComponent();
+ assertThat(project.getKey()).isEqualTo(PROJECT_KEY);
+
+ BulkUpdateKeyWsResponse result = wsClient.projects().bulkUpdateKey(BulkUpdateKeyWsRequest.builder()
+ .setKey(PROJECT_KEY)
+ .setFrom(PROJECT_KEY)
+ .setTo(newProjectKey)
+ .build());
+
+ assertThat(wsClient.components().show(new ShowWsRequest().setId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey);
+ assertThat(result.getKeysCount()).isEqualTo(1);
+ assertThat(result.getKeys(0))
+ .extracting(Key::getKey, Key::getNewKey, Key::getDuplicate)
+ .containsOnlyOnce(PROJECT_KEY, newProjectKey, false);
+ }
}