From bb3d825f81eff913d50e7e2773e6773387268233 Mon Sep 17 00:00:00 2001 From: Jacek Date: Tue, 27 Sep 2022 14:04:38 +0200 Subject: [PATCH] SONAR-17195 Use "devopsPlatform" field name instead "alm" in telemetry --- .../java/org/sonar/server/telemetry/TelemetryData.java | 10 +++++----- .../server/telemetry/TelemetryDataJsonWriter.java | 2 +- .../server/telemetry/TelemetryDataJsonWriterTest.java | 8 ++++---- .../server/telemetry/TelemetryDataLoaderImpl.java | 9 ++++----- .../server/telemetry/TelemetryDataLoaderImplTest.java | 7 ++----- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java b/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java index 3f498118e9e..1f4cd508c6d 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java @@ -303,15 +303,15 @@ public class TelemetryData { private final Long pullRequestCount; private final String scm; private final String ci; - private final String alm; + private final String devopsPlatform; - ProjectStatistics(String projectUuid, Long branchCount, Long pullRequestCount, @Nullable String scm, @Nullable String ci, @Nullable String alm) { + ProjectStatistics(String projectUuid, Long branchCount, Long pullRequestCount, @Nullable String scm, @Nullable String ci, @Nullable String devopsPlatform) { this.projectUuid = projectUuid; this.branchCount = branchCount; this.pullRequestCount = pullRequestCount; this.scm = scm; this.ci = ci; - this.alm = alm; + this.devopsPlatform = devopsPlatform; } public String getProjectUuid() { @@ -337,8 +337,8 @@ public class TelemetryData { } @CheckForNull - public String getAlm() { - return alm; + public String getDevopsPlatform() { + return devopsPlatform; } } } diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java b/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java index e8e6e186687..3bd3dda66e4 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java @@ -135,7 +135,7 @@ public class TelemetryDataJsonWriter { json.prop("pullRequestCount", project.getPullRequestCount()); json.prop("scm", project.getScm()); json.prop("ci", project.getCi()); - json.prop("alm", project.getAlm()); + json.prop("devopsPlatform", project.getDevopsPlatform()); json.endObject(); }); json.endArray(); diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java index 31b5edd4601..8782cd1863b 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java @@ -348,7 +348,7 @@ public class TelemetryDataJsonWriterTest { " \"pullRequestCount\": 2," + " \"scm\": \"scm-0\"," + " \"ci\": \"ci-0\"," + - " \"alm\": \"alm-0\"" + + " \"devopsPlatform\": \"devops-0\"" + " }," + " {" + " \"projectUuid\": \"uuid-1\"," + @@ -356,7 +356,7 @@ public class TelemetryDataJsonWriterTest { " \"pullRequestCount\": 4," + " \"scm\": \"scm-1\"," + " \"ci\": \"ci-1\"," + - " \"alm\": \"alm-1\"" + + " \"devopsPlatform\": \"devops-1\"" + " }," + " {" + " \"projectUuid\": \"uuid-2\"," + @@ -364,7 +364,7 @@ public class TelemetryDataJsonWriterTest { " \"pullRequestCount\": 6," + " \"scm\": \"scm-2\"," + " \"ci\": \"ci-2\"," + - " \"alm\": \"alm-2\"" + + " \"devopsPlatform\": \"devops-2\"" + " }" + " ]" + "}"); @@ -381,7 +381,7 @@ public class TelemetryDataJsonWriterTest { } private List getProjectStats() { - return IntStream.range(0, 3).mapToObj(i -> new TelemetryData.ProjectStatistics("uuid-" + i, (i + 1L) * 2L, (i + 1L) * 2L, "scm-" + i, "ci-" + i, "alm-" + i)) + return IntStream.range(0, 3).mapToObj(i -> new TelemetryData.ProjectStatistics("uuid-" + i, (i + 1L) * 2L, (i + 1L) * 2L, "scm-" + i, "ci-" + i, "devops-" + i)) .collect(Collectors.toList()); } diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java index 9952ad298c3..8a91caa4505 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java @@ -45,7 +45,6 @@ import org.sonar.db.alm.setting.ProjectAlmKeyAndProject; import org.sonar.db.component.AnalysisPropertyValuePerProject; import org.sonar.db.component.PrAndBranchCountByProjectDto; import org.sonar.db.measure.ProjectMeasureDto; -import org.sonar.server.measure.index.ProjectMeasuresIndex; import org.sonar.server.platform.DockerSupport; import org.sonar.server.property.InternalProperties; import org.sonar.server.telemetry.TelemetryData.Database; @@ -138,14 +137,14 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader { Long pullRequestCount = Optional.ofNullable(prAndBranchCountByProjects.get(projectUuid)).map(PrAndBranchCountByProjectDto::getPullRequest).orElse(0L); String scm = Optional.ofNullable(scmByProject.get(projectUuid)).orElse(UNDETECTED); String ci = Optional.ofNullable(ciByProject.get(projectUuid)).orElse(UNDETECTED); - String alm = null; + String devopsPlatform = null; if (almAndUrlByProject.containsKey(projectUuid)) { ProjectAlmKeyAndProject projectAlmKeyAndProject = almAndUrlByProject.get(projectUuid); - alm = getAlmName(projectAlmKeyAndProject.getAlmId(), projectAlmKeyAndProject.getUrl()); + devopsPlatform = getAlmName(projectAlmKeyAndProject.getAlmId(), projectAlmKeyAndProject.getUrl()); } - alm = Optional.ofNullable(alm).orElse(UNDETECTED); + devopsPlatform = Optional.ofNullable(devopsPlatform).orElse(UNDETECTED); - projectStatistics.add(new TelemetryData.ProjectStatistics(projectUuid, branchCount, pullRequestCount, scm, ci, alm)); + projectStatistics.add(new TelemetryData.ProjectStatistics(projectUuid, branchCount, pullRequestCount, scm, ci, devopsPlatform)); } data.setProjectStatistics(projectStatistics); diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java index ab59d5c0803..b4fa868a8df 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java @@ -41,9 +41,6 @@ import org.sonar.db.component.SnapshotDto; import org.sonar.db.metric.MetricDto; import org.sonar.db.user.UserDto; import org.sonar.db.user.UserTelemetryDto; -import org.sonar.server.es.EsTester; -import org.sonar.server.measure.index.ProjectMeasuresIndex; -import org.sonar.server.measure.index.ProjectMeasuresIndexer; import org.sonar.server.platform.DockerSupport; import org.sonar.server.property.InternalProperties; import org.sonar.server.property.MapInternalProperties; @@ -176,7 +173,7 @@ public class TelemetryDataLoaderImplTest { tuple(project2.uuid(), "js", 20L, analysisDate)); assertThat(data.getProjectStatistics()) .extracting(TelemetryData.ProjectStatistics::getBranchCount, TelemetryData.ProjectStatistics::getPullRequestCount, - TelemetryData.ProjectStatistics::getScm, TelemetryData.ProjectStatistics::getCi, TelemetryData.ProjectStatistics::getAlm) + TelemetryData.ProjectStatistics::getScm, TelemetryData.ProjectStatistics::getCi, TelemetryData.ProjectStatistics::getDevopsPlatform) .containsExactlyInAnyOrder( tuple(1L, 0L, "scm-1", "ci-1", "azure_devops_cloud"), tuple(1L, 0L, "scm-2", "ci-2", "github_cloud")); @@ -386,7 +383,7 @@ public class TelemetryDataLoaderImplTest { db.components().insertPublicProject(); TelemetryData data = communityUnderTest.load(); assertThat(data.getProjectStatistics()) - .extracting(TelemetryData.ProjectStatistics::getAlm, TelemetryData.ProjectStatistics::getScm, TelemetryData.ProjectStatistics::getCi) + .extracting(TelemetryData.ProjectStatistics::getDevopsPlatform, TelemetryData.ProjectStatistics::getScm, TelemetryData.ProjectStatistics::getCi) .containsExactlyInAnyOrder(tuple("undetected", "undetected", "undetected")); } -- 2.39.5