aboutsummaryrefslogtreecommitdiffstats
path: root/it/it-tests
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-08-03 15:36:53 +0200
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-08-05 14:31:15 +0200
commit645d874eda971f79a0927aa6370adb9489f148b7 (patch)
tree242f65e73652307ae524312427d00722555735a2 /it/it-tests
parent982927e716d5e6a0659c7a7157c3793bef761e76 (diff)
downloadsonarqube-645d874eda971f79a0927aa6370adb9489f148b7.tar.gz
sonarqube-645d874eda971f79a0927aa6370adb9489f148b7.zip
SONAR-7928 SONAR-4770 Create WS api/components/update_key
Diffstat (limited to 'it/it-tests')
-rw-r--r--it/it-tests/src/test/java/it/component/ComponentsWsTest.java23
-rw-r--r--it/it-tests/src/test/java/it/serverSystem/ClusterTest.java3
2 files changed, 25 insertions, 1 deletions
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 4f8593d2646..a137231dc8e 100644
--- a/it/it-tests/src/test/java/it/component/ComponentsWsTest.java
+++ b/it/it-tests/src/test/java/it/component/ComponentsWsTest.java
@@ -24,11 +24,15 @@ import com.sonar.orchestrator.build.SonarScanner;
import it.Category4Suite;
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.client.HttpException;
import org.sonarqube.ws.client.WsClient;
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;
@@ -39,6 +43,11 @@ 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();
+
WsClient wsClient;
@Before
@@ -66,4 +75,18 @@ 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);
+ }
}
diff --git a/it/it-tests/src/test/java/it/serverSystem/ClusterTest.java b/it/it-tests/src/test/java/it/serverSystem/ClusterTest.java
index 8a792854e7e..d7e61642980 100644
--- a/it/it-tests/src/test/java/it/serverSystem/ClusterTest.java
+++ b/it/it-tests/src/test/java/it/serverSystem/ClusterTest.java
@@ -36,6 +36,7 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.sonarqube.ws.Issues;
import org.sonarqube.ws.client.rule.SearchWsRequest;
@@ -140,7 +141,7 @@ public class ClusterTest {
private static void expectLog(Orchestrator orchestrator, String expectedLog) throws IOException {
File logFile = orchestrator.getServer().getLogs();
try (Stream<String> lines = Files.lines(logFile.toPath())) {
- assertThat(lines.anyMatch(s -> containsIgnoreCase(s, expectedLog))).isTrue();
+ assertThat(lines.anyMatch(s -> StringUtils.containsIgnoreCase(s, expectedLog))).isTrue();
}
}