]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-18219 Change type of telemetry data
authorAntoine Vinot <antoine.vinot@sonarsource.com>
Fri, 27 Jan 2023 09:55:06 +0000 (10:55 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 3 Feb 2023 14:41:20 +0000 (14:41 +0000)
server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java
server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java
server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java

index 9ab24fcde4afbe281303fdb107c18b44fab66d60..c7bc4a0b1d9d76558ea26e1df36f38e7fd326e73 100644 (file)
@@ -294,8 +294,8 @@ public class TelemetryData {
     private final Long bugs;
     private final Long vulnerabilities;
     private final Long securityHotspots;
-    private final Double technicalDebt;
-    private final Double developmentCost;
+    private final Long technicalDebt;
+    private final Long developmentCost;
 
     ProjectStatistics(Builder builder) {
       this.projectUuid = builder.projectUuid;
@@ -352,11 +352,11 @@ public class TelemetryData {
       return Optional.ofNullable(securityHotspots);
     }
 
-    public Optional<Double> getTechnicalDebt() {
+    public Optional<Long> getTechnicalDebt() {
       return Optional.ofNullable(technicalDebt);
     }
 
-    public Optional<Double> getDevelopmentCost() {
+    public Optional<Long> getDevelopmentCost() {
       return Optional.ofNullable(developmentCost);
     }
 
@@ -371,8 +371,8 @@ public class TelemetryData {
       private Long bugs;
       private Long vulnerabilities;
       private Long securityHotspots;
-      private Double technicalDebt;
-      private Double developmentCost;
+      private Long technicalDebt;
+      private Long developmentCost;
 
       public Builder setProjectUuid(String projectUuid) {
         this.projectUuid = projectUuid;
@@ -425,12 +425,12 @@ public class TelemetryData {
       }
 
       public Builder setTechnicalDebt(@Nullable Number technicalDebt) {
-        this.technicalDebt = technicalDebt != null ? technicalDebt.doubleValue() : null;
+        this.technicalDebt = technicalDebt != null ? technicalDebt.longValue() : null;
         return this;
       }
 
       public Builder setDevelopmentCost(@Nullable Number developmentCost) {
-        this.developmentCost = developmentCost != null ? developmentCost.doubleValue() : null;
+        this.developmentCost = developmentCost != null ? developmentCost.longValue() : null;
         return this;
       }
 
index 678140207028087d985d688fcf173a13cacaef0a..cfd2521e969d462fafef74c86d987aa4454c121a 100644 (file)
@@ -364,7 +364,7 @@ public class TelemetryDataJsonWriterTest {
   }
 
   @Test
-  public void writes_all_projects_stats_with_analyzed_languages() {
+  public void writeTelemetryData_whenAnalyzedLanguages_shouldwriteAllProjectsStats() {
     TelemetryData data = telemetryBuilder()
       .setProjectStatistics(attachProjectStatsWithMetrics())
       .build();
@@ -385,8 +385,8 @@ public class TelemetryDataJsonWriterTest {
             "bugs": 2,
             "vulnerabilities": 3,
             "securityHotspots": 4,
-            "technicalDebt": 60.0,
-            "developmentCost": 30.0
+            "technicalDebt": 60,
+            "developmentCost": 30
           },
           {
             "projectUuid": "uuid-1",
@@ -399,8 +399,8 @@ public class TelemetryDataJsonWriterTest {
             "bugs": 4,
             "vulnerabilities": 6,
             "securityHotspots": 8,
-            "technicalDebt": 120.0,
-            "developmentCost": 60.0
+            "technicalDebt": 120,
+            "developmentCost": 60
           },
           {
             "projectUuid": "uuid-2",
@@ -413,8 +413,8 @@ public class TelemetryDataJsonWriterTest {
             "bugs": 6,
             "vulnerabilities": 9,
             "securityHotspots": 12,
-            "technicalDebt": 180.0,
-            "developmentCost": 90.0
+            "technicalDebt": 180,
+            "developmentCost": 90
           }
         ]
       }
index 95b472f58ac80fe7a9f774e936a56bc27c6347fb..ffcbc9f0411de6aae75994f7b831fbcc445e6c6f 100644 (file)
@@ -226,7 +226,7 @@ public class TelemetryDataLoaderImplTest {
         TelemetryData.ProjectStatistics::getBugs, TelemetryData.ProjectStatistics::getVulnerabilities, TelemetryData.ProjectStatistics::getSecurityHotspots,
         TelemetryData.ProjectStatistics::getDevelopmentCost, TelemetryData.ProjectStatistics::getTechnicalDebt)
       .containsExactlyInAnyOrder(
-        tuple(1L, 0L, qualityGate1.getUuid(), "scm-1", "ci-1", "azure_devops_cloud", Optional.of(1L), Optional.of(1L), Optional.of(1L), Optional.of(50.0), Optional.of(5.0)),
+        tuple(1L, 0L, qualityGate1.getUuid(), "scm-1", "ci-1", "azure_devops_cloud", Optional.of(1L), Optional.of(1L), Optional.of(1L), Optional.of(50L), Optional.of(5L)),
         tuple(1L, 0L, builtInDefaultQualityGate.getUuid(), "scm-2", "ci-2", "github_cloud", Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
     assertThat(data.getQualityGates())
       .extracting(TelemetryData.QualityGate::uuid, TelemetryData.QualityGate::isCaycCompliant)