From: alain <108417558+alain-kermis-sonarsource@users.noreply.github.com> Date: Tue, 27 Sep 2022 13:31:11 +0000 (+0200) Subject: SONAR-17195 Installation date in UTC format for telemetry X-Git-Tag: 9.7.0.61563~159 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5e7e46a917b4cf4f301701e5bb4455e98c9b4775;p=sonarqube.git SONAR-17195 Installation date in UTC format for telemetry --- 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 690b170f622..e8e6e186687 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 @@ -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()); 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 edef00103c0..31b5edd4601 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 @@ -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\"," + "}"); }