From 0ce62a09539920b477873c2c26e9a6d2fc62a15e Mon Sep 17 00:00:00 2001 From: Alain Kermis Date: Thu, 18 Jul 2024 10:46:37 +0200 Subject: SONAR-22479 Introduce ADHOC granularity --- .../src/main/java/org/sonar/telemetry/core/Granularity.java | 1 + .../src/main/java/org/sonar/telemetry/core/TelemetryDataProvider.java | 3 ++- .../src/test/java/org/sonar/telemetry/core/GranularityTest.java | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'server/sonar-telemetry-core') diff --git a/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/Granularity.java b/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/Granularity.java index be5cd22bb93..e66b2a83f87 100644 --- a/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/Granularity.java +++ b/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/Granularity.java @@ -27,6 +27,7 @@ import com.fasterxml.jackson.annotation.JsonValue; * Modifying this enum needs to be discussed beforehand with Data Platform team. */ public enum Granularity { + ADHOC("adhoc"), DAILY("daily"), WEEKLY("weekly"), MONTHLY("monthly"); diff --git a/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/TelemetryDataProvider.java b/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/TelemetryDataProvider.java index a464014e767..b29fec4057b 100644 --- a/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/TelemetryDataProvider.java +++ b/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/TelemetryDataProvider.java @@ -20,6 +20,7 @@ package org.sonar.telemetry.core; import java.util.Map; +import java.util.Optional; /** * This interface is used to provide data to the telemetry system. The telemetry system will call the methods of this interface to get the @@ -61,7 +62,7 @@ public interface TelemetryDataProvider { * * @return the value of the data provided by this instance. */ - default T getValue() { + default Optional getValue() { throw new IllegalStateException("Not implemented"); } diff --git a/server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/GranularityTest.java b/server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/GranularityTest.java index a4b01e93305..44ef21c9298 100644 --- a/server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/GranularityTest.java +++ b/server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/GranularityTest.java @@ -30,6 +30,7 @@ class GranularityTest { assertEquals("daily", Granularity.DAILY.getValue()); assertEquals("weekly", Granularity.WEEKLY.getValue()); assertEquals("monthly", Granularity.MONTHLY.getValue()); + assertEquals("adhoc", Granularity.ADHOC.getValue()); } } -- cgit v1.2.3