diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2017-10-02 11:02:12 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk@users.noreply.github.com> | 2017-10-03 14:45:02 +0200 |
commit | 266450099096400d6134cc429a462bb52c198b06 (patch) | |
tree | 8d2ca7f95147213390a78049ee57ffceb29bd169 /tests | |
parent | 3be234a8129229de4f44da012d0a901a026a265d (diff) | |
download | sonarqube-266450099096400d6134cc429a462bb52c198b06.tar.gz sonarqube-266450099096400d6134cc429a462bb52c198b06.zip |
SONAR-9820 update telemetry format - list instead of map
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/test/java/org/sonarqube/tests/telemetry/TelemetryUploadTest.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/telemetry/TelemetryUploadTest.java b/tests/src/test/java/org/sonarqube/tests/telemetry/TelemetryUploadTest.java index 501c864706a..dc4d3c0a9ff 100644 --- a/tests/src/test/java/org/sonarqube/tests/telemetry/TelemetryUploadTest.java +++ b/tests/src/test/java/org/sonarqube/tests/telemetry/TelemetryUploadTest.java @@ -20,7 +20,9 @@ package org.sonarqube.tests.telemetry; import com.sonar.orchestrator.Orchestrator; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import javax.ws.rs.core.HttpHeaders; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; @@ -32,6 +34,7 @@ import org.sonarqube.ws.client.GetRequest; import util.ItUtils; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; import static util.ItUtils.jsonToMap; import static util.ItUtils.runProjectAnalysis; import static util.ItUtils.setServerProperty; @@ -80,15 +83,16 @@ public class TelemetryUploadTest { Map<String, Object> json = jsonToMap(request.getBody().readUtf8()); assertThat(json.get("id")).isEqualTo(serverId()); assertThat(getInteger(json.get("userCount"))).isEqualTo(1); - assertThat(((Map) json.get("plugins")).keySet()).contains("xoo"); + List<String> plugins = ((List<Map<String, String>>) json.get("plugins")).stream().map(p -> p.get("name")).collect(Collectors.toList()); + assertThat(plugins).contains("xoo"); assertThat(getInteger(json.get("ncloc"))).isEqualTo(13 * 2 + 7); assertThat(getInteger(json.get("lines"))).isEqualTo(17 * 3); - Map projectCountByLanguage = (Map) json.get("projectCountByLanguage"); - assertThat(getInteger(projectCountByLanguage.get("xoo"))).isEqualTo(2); - assertThat(getInteger(projectCountByLanguage.get("xoo2"))).isEqualTo(1); - Map nclocByLanguage = (Map) json.get("nclocByLanguage"); - assertThat(getInteger(nclocByLanguage.get("xoo"))).isEqualTo(13 * 2); - assertThat(getInteger(nclocByLanguage.get("xoo2"))).isEqualTo(7); + List<Map<String, String>> projectCountByLanguage = (List<Map<String,String>>) json.get("projectCountByLanguage"); + assertThat(projectCountByLanguage).extracting(p -> p.get("language"), p -> getInteger(p.get("count"))) + .contains(tuple("xoo", 2), tuple("xoo2", 1)); + List<Map<String, String>> nclocByLanguage = (List<Map<String,String>>) json.get("nclocByLanguage"); + assertThat(nclocByLanguage).extracting(p -> p.get("language"), p -> getInteger(p.get("ncloc"))) + .contains(tuple("xoo", 13 * 2), tuple("xoo2", 7)); } private String serverId() { |