From 5e7e46a917b4cf4f301701e5bb4455e98c9b4775 Mon Sep 17 00:00:00 2001 From: alain <108417558+alain-kermis-sonarsource@users.noreply.github.com> Date: Tue, 27 Sep 2022 15:31:11 +0200 Subject: [PATCH] SONAR-17195 Installation date in UTC format for telemetry --- .../sonar/server/telemetry/TelemetryDataJsonWriter.java | 2 +- .../server/telemetry/TelemetryDataJsonWriterTest.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) 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\"," + "}"); } -- 2.39.5