aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-12-04 15:52:09 +0100
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>2017-12-06 14:40:17 +0100
commit9cba9e0a34bd4b7fa24a7b9c9b8616c0c47273da (patch)
tree9e2eacc6002d403c9bd32976d90003e1edd68646 /tests
parent2259c6808e011a95fa1d0b8e5681f507befdb4e9 (diff)
downloadsonarqube-9cba9e0a34bd4b7fa24a7b9c9b8616c0c47273da.tar.gz
sonarqube-9cba9e0a34bd4b7fa24a7b9c9b8616c0c47273da.zip
Remove deprecated MeasuresService
Diffstat (limited to 'tests')
-rw-r--r--tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java12
-rw-r--r--tests/src/test/java/org/sonarqube/tests/measure/MeasuresWsTest.java10
-rw-r--r--tests/src/test/java/org/sonarqube/tests/measure/TimeMachineTest.java14
-rw-r--r--tests/src/test/java/org/sonarqube/tests/performance/scanner/DuplicationTest.java6
-rw-r--r--tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java30
-rw-r--r--tests/src/test/java/util/ItUtils.java10
6 files changed, 48 insertions, 34 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java b/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java
index f8230246a8e..8bf091cf72a 100644
--- a/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java
@@ -31,9 +31,9 @@ import org.sonarqube.ws.Measures;
import org.sonarqube.ws.client.components.TreeRequest;
import org.sonarqube.ws.client.issues.IssuesService;
import org.sonarqube.ws.client.issues.SearchRequest;
-import org.sonarqube.ws.client.measure.ComponentTreeRequest;
-import org.sonarqube.ws.client.measure.ComponentRequest;
-import org.sonarqube.ws.client.measure.MeasuresService;
+import org.sonarqube.ws.client.measures.ComponentTreeRequest;
+import org.sonarqube.ws.client.measures.ComponentRequest;
+import org.sonarqube.ws.client.measures.MeasuresService;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
@@ -88,15 +88,15 @@ public class LiteTest {
@Test
public void call_measures_ws() {
// project measures
- MeasuresService measuresService = tester.wsClient().measuresOld();
+ MeasuresService measuresService = tester.wsClient().measures();
Measures.ComponentWsResponse component = measuresService.component(new ComponentRequest()
- .setComponentKey(PROJECT_KEY)
+ .setComponent(PROJECT_KEY)
.setMetricKeys(asList("lines", "ncloc", "files")));
assertThat(component.getComponent().getMeasuresCount()).isEqualTo(3);
// file measures
Measures.ComponentTreeWsResponse tree = measuresService.componentTree(new ComponentTreeRequest()
- .setBaseComponentKey(PROJECT_KEY)
+ .setComponent(PROJECT_KEY)
.setQualifiers(singletonList("FIL"))
.setMetricKeys(asList("lines", "ncloc")));
assertThat(tree.getComponentsCount()).isEqualTo(4);
diff --git a/tests/src/test/java/org/sonarqube/tests/measure/MeasuresWsTest.java b/tests/src/test/java/org/sonarqube/tests/measure/MeasuresWsTest.java
index 44a55d60c64..2515b25fec0 100644
--- a/tests/src/test/java/org/sonarqube/tests/measure/MeasuresWsTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/measure/MeasuresWsTest.java
@@ -30,8 +30,8 @@ import org.sonarqube.qa.util.Tester;
import org.sonarqube.ws.Measures;
import org.sonarqube.ws.Measures.ComponentTreeWsResponse;
import org.sonarqube.ws.Measures.ComponentWsResponse;
-import org.sonarqube.ws.client.measure.ComponentTreeRequest;
-import org.sonarqube.ws.client.measure.ComponentRequest;
+import org.sonarqube.ws.client.measures.ComponentTreeRequest;
+import org.sonarqube.ws.client.measures.ComponentRequest;
import static com.google.common.collect.Lists.newArrayList;
import static java.util.Arrays.asList;
@@ -59,7 +59,7 @@ public class MeasuresWsTest {
public void component_tree() {
scanXooSample();
- ComponentTreeWsResponse response = tester.wsClient().measuresOld().componentTree(new ComponentTreeRequest()
+ ComponentTreeWsResponse response = tester.wsClient().measures().componentTree(new ComponentTreeRequest()
.setComponent("sample")
.setMetricKeys(singletonList("ncloc"))
.setAdditionalFields(asList("metrics", "periods")));
@@ -123,7 +123,7 @@ public class MeasuresWsTest {
}
private void verifyComponentTreeWithChildren(String baseComponentKey, String... childKeys) {
- ComponentTreeWsResponse response = tester.wsClient().measuresOld().componentTree(new ComponentTreeRequest()
+ ComponentTreeWsResponse response = tester.wsClient().measures().componentTree(new ComponentTreeRequest()
.setComponent(baseComponentKey)
.setMetricKeys(singletonList("ncloc"))
.setStrategy("children"));
@@ -137,7 +137,7 @@ public class MeasuresWsTest {
public void component() {
scanXooSample();
- ComponentWsResponse response = tester.wsClient().measuresOld().component(new ComponentRequest()
+ ComponentWsResponse response = tester.wsClient().measures().component(new ComponentRequest()
.setComponent("sample")
.setMetricKeys(singletonList("ncloc"))
.setAdditionalFields(newArrayList("metrics", "periods")));
diff --git a/tests/src/test/java/org/sonarqube/tests/measure/TimeMachineTest.java b/tests/src/test/java/org/sonarqube/tests/measure/TimeMachineTest.java
index 9970b0a8470..2dc2d73b7ff 100644
--- a/tests/src/test/java/org/sonarqube/tests/measure/TimeMachineTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/measure/TimeMachineTest.java
@@ -21,7 +21,6 @@ package org.sonarqube.tests.measure;
import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.build.SonarScanner;
-import java.util.Arrays;
import java.util.Date;
import java.util.Map;
import org.junit.BeforeClass;
@@ -32,10 +31,11 @@ import org.sonarqube.qa.util.Tester;
import org.sonarqube.ws.Measures.Measure;
import org.sonarqube.ws.Measures.SearchHistoryResponse;
import org.sonarqube.ws.Measures.SearchHistoryResponse.HistoryValue;
-import org.sonarqube.ws.client.measure.SearchHistoryRequest;
+import org.sonarqube.ws.client.measures.SearchHistoryRequest;
import util.ItUtils;
import util.ItUtils.ComponentNavigation;
+import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.apache.commons.lang.time.DateUtils.addDays;
import static org.assertj.core.api.Assertions.assertThat;
@@ -102,12 +102,11 @@ public class TimeMachineTest {
public void noDataForInterval() {
Date now = new Date();
- SearchHistoryResponse response = tester.wsClient().measuresOld().searchHistory(SearchHistoryRequest.builder()
+ SearchHistoryResponse response = tester.wsClient().measures().searchHistory(new SearchHistoryRequest()
.setComponent(PROJECT_KEY)
.setMetrics(singletonList("lines"))
.setFrom(formatDate(now))
- .setTo(formatDate(now))
- .build());
+ .setTo(formatDate(now)));
assertThat(response.getPaging().getTotal()).isEqualTo(0);
assertThat(response.getMeasures(0).getHistoryList()).isEmpty();
@@ -134,10 +133,9 @@ public class TimeMachineTest {
}
private static SearchHistoryResponse searchHistory(String... metrics) {
- return tester.wsClient().measuresOld().searchHistory(SearchHistoryRequest.builder()
+ return tester.wsClient().measures().searchHistory(new SearchHistoryRequest()
.setComponent(PROJECT_KEY)
- .setMetrics(Arrays.asList(metrics))
- .build());
+ .setMetrics(asList(metrics)));
}
private static void assertHistory(SearchHistoryResponse response, String metric, String... expectedMeasures) {
diff --git a/tests/src/test/java/org/sonarqube/tests/performance/scanner/DuplicationTest.java b/tests/src/test/java/org/sonarqube/tests/performance/scanner/DuplicationTest.java
index f0e6590a6e0..80e1f718f6a 100644
--- a/tests/src/test/java/org/sonarqube/tests/performance/scanner/DuplicationTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/performance/scanner/DuplicationTest.java
@@ -37,7 +37,7 @@ import org.sonarqube.ws.Measures;
import org.sonarqube.ws.client.HttpConnector;
import org.sonarqube.ws.client.WsClient;
import org.sonarqube.ws.client.WsClientFactories;
-import org.sonarqube.ws.client.measure.ComponentRequest;
+import org.sonarqube.ws.client.measures.ComponentRequest;
import static java.lang.Double.parseDouble;
import static java.util.Arrays.asList;
@@ -80,8 +80,8 @@ public class DuplicationTest extends AbstractPerfTest {
}
private Map<String, Double> getMeasures(String key) {
- return newWsClient().measuresOld().component(new ComponentRequest()
- .setComponentKey(key)
+ return newWsClient().measures().component(new ComponentRequest()
+ .setComponent(key)
.setMetricKeys(asList("duplicated_lines", "duplicated_blocks", "duplicated_files", "duplicated_lines_density")))
.getComponent().getMeasuresList()
.stream()
diff --git a/tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java b/tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java
index f929798ec84..a858de6af52 100644
--- a/tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java
@@ -31,22 +31,26 @@ import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
-import java.util.Collections;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Test;
import org.sonarqube.qa.util.SelenideConfig;
+import org.sonarqube.ws.Measures;
import org.sonarqube.ws.Measures.Measure;
+import org.sonarqube.ws.MediaTypes;
+import org.sonarqube.ws.client.BaseService;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.HttpConnector;
+import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsClient;
import org.sonarqube.ws.client.WsClientFactories;
import org.sonarqube.ws.client.WsResponse;
-import org.sonarqube.ws.client.measure.ComponentRequest;
+import org.sonarqube.ws.client.measures.ComponentRequest;
import static com.codeborne.selenide.Condition.hasText;
import static com.codeborne.selenide.Selenide.$;
import static java.lang.Integer.parseInt;
+import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
public class UpgradeTest {
@@ -73,7 +77,7 @@ public class UpgradeTest {
private void testDatabaseUpgrade(Version fromVersion) {
startOldVersionServer(fromVersion, false);
scanProject();
- int files = countFiles(PROJECT_KEY);
+ int files = countFilesOld(PROJECT_KEY);
assertThat(files).isGreaterThan(0);
stopServer();
@@ -83,9 +87,9 @@ public class UpgradeTest {
}
private void verifyAnalysis(int expectedNumberOfFiles) {
- assertThat(countFiles(PROJECT_KEY)).isEqualTo(expectedNumberOfFiles);
+ assertThat(countFilesNew(PROJECT_KEY)).isEqualTo(expectedNumberOfFiles);
scanProject();
- assertThat(countFiles(PROJECT_KEY)).isEqualTo(expectedNumberOfFiles);
+ assertThat(countFilesNew(PROJECT_KEY)).isEqualTo(expectedNumberOfFiles);
browseWebapp();
}
@@ -197,8 +201,20 @@ public class UpgradeTest {
orchestrator.executeBuild(build);
}
- private int countFiles(String key) {
- Measure measure = newWsClient(orchestrator).measuresOld().component(new ComponentRequest().setComponentKey(key).setMetricKeys(Collections.singletonList("files")))
+ private int countFilesOld(String key) {
+ PostRequest httpRequest = new PostRequest("api/measures/component")
+ .setParam("componentKey", key)
+ .setParam("metricKeys", singletonList("files"))
+ .setMediaType(MediaTypes.PROTOBUF);
+ WsResponse response = HttpConnector.newBuilder()
+ .url(orchestrator.getServer().getUrl())
+ .build().call(httpRequest);
+ Measure measure = BaseService.convert(response, Measures.ComponentWsResponse.parser()).getComponent().getMeasures(0);
+ return parseInt(measure.getValue());
+ }
+
+ private int countFilesNew(String key) {
+ Measure measure = newWsClient(orchestrator).measures().component(new ComponentRequest().setComponent(key).setMetricKeys(singletonList("files")))
.getComponent().getMeasures(0);
return parseInt(measure.getValue());
}
diff --git a/tests/src/test/java/util/ItUtils.java b/tests/src/test/java/util/ItUtils.java
index c1dfd54f86e..7700bf120f5 100644
--- a/tests/src/test/java/util/ItUtils.java
+++ b/tests/src/test/java/util/ItUtils.java
@@ -71,7 +71,7 @@ import org.sonarqube.ws.client.HttpConnector;
import org.sonarqube.ws.client.WsClient;
import org.sonarqube.ws.client.WsClientFactories;
import org.sonarqube.ws.client.components.ShowRequest;
-import org.sonarqube.ws.client.measure.ComponentRequest;
+import org.sonarqube.ws.client.measures.ComponentRequest;
import org.sonarqube.ws.client.qualityprofile.RestoreRequest;
import org.sonarqube.ws.client.settings.ResetRequest;
import org.sonarqube.ws.client.settings.SetRequest;
@@ -334,7 +334,7 @@ public class ItUtils {
}
private static Stream<Measure> getStreamMeasures(Orchestrator orchestrator, String componentKey, String... metricKeys) {
- return newWsClient(orchestrator).measuresOld().component(new ComponentRequest()
+ return newWsClient(orchestrator).measures().component(new ComponentRequest()
.setComponent(componentKey)
.setMetricKeys(asList(metricKeys)))
.getComponent().getMeasuresList()
@@ -343,7 +343,7 @@ public class ItUtils {
@CheckForNull
public static Measure getMeasureWithVariation(Orchestrator orchestrator, String componentKey, String metricKey) {
- Measures.ComponentWsResponse response = newWsClient(orchestrator).measuresOld().component(new ComponentRequest()
+ Measures.ComponentWsResponse response = newWsClient(orchestrator).measures().component(new ComponentRequest()
.setComponent(componentKey)
.setMetricKeys(singletonList(metricKey))
.setAdditionalFields(singletonList("periods")));
@@ -353,8 +353,8 @@ public class ItUtils {
@CheckForNull
public static Map<String, Measure> getMeasuresWithVariationsByMetricKey(Orchestrator orchestrator, String componentKey, String... metricKeys) {
- return newWsClient(orchestrator).measuresOld().component(new ComponentRequest()
- .setComponentKey(componentKey)
+ return newWsClient(orchestrator).measures().component(new ComponentRequest()
+ .setComponent(componentKey)
.setMetricKeys(asList(metricKeys))
.setAdditionalFields(singletonList("periods"))).getComponent().getMeasuresList()
.stream()