]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17195 Installation date in UTC format for telemetry
authoralain <108417558+alain-kermis-sonarsource@users.noreply.github.com>
Tue, 27 Sep 2022 13:31:11 +0000 (15:31 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 27 Sep 2022 20:03:17 +0000 (20:03 +0000)
server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java
server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java

index 690b170f622fa2cade6d91bba281a3a7340e7e44..e8e6e186687fb18a07441cea833f16c88cacb081 100644 (file)
@@ -70,7 +70,7 @@ public class TelemetryDataJsonWriter {
     json.endArray();
 
     if (statistics.getInstallationDate() != null) {
-      json.prop("installationDate", statistics.getInstallationDate());
+      json.prop("installationDate", toUtc(statistics.getInstallationDate()));
     }
     if (statistics.getInstallationVersion() != null) {
       json.prop("installationVersion", statistics.getInstallationVersion());
index edef00103c040d48efc3b0fae402f3f8e6d5d398..31b5edd4601a778eb3243a9fd9f1637c3b07c5d9 100644 (file)
@@ -189,16 +189,15 @@ public class TelemetryDataJsonWriterTest {
   }
 
   @Test
-  public void write_installation_date() {
-    long installationDate = random.nextInt(590);
+  public void write_installation_date_in_utc_format() {
     TelemetryData data = SOME_TELEMETRY_DATA
-      .setInstallationDate(installationDate)
+      .setInstallationDate(1_000L)
       .build();
 
     String json = writeTelemetryData(data);
 
     assertJson(json).isSimilarTo("{" +
-      "  \"installationDate\": " + installationDate +
+      "  \"installationDate\":\"1970-01-01T00:00:01+0000\"," +
       "}");
   }