From 8d858dd3b7c87e5a39d8031d527a723d5191ba53 Mon Sep 17 00:00:00 2001 From: Alain Kermis Date: Tue, 9 Jul 2024 16:16:42 +0200 Subject: SONAR-22479 Refactored new telemetry model --- .../platform/platformlevel/PlatformLevel4.java | 12 ++--- .../telemetry/TelemetryVersionProvider.java | 8 ++-- .../telemetry/TelemetryVersionProviderTest.java | 52 ++++++++++++++++++++++ .../telemetry/TelemetryVersionProviderTest.java | 50 --------------------- 4 files changed, 62 insertions(+), 60 deletions(-) create mode 100644 server/sonar-webserver/src/test/java/org/sonar/server/platform/telemetry/TelemetryVersionProviderTest.java delete mode 100644 server/sonar-webserver/src/test/java/org/sonar/server/telemetry/TelemetryVersionProviderTest.java (limited to 'server/sonar-webserver/src') diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index 44b54cd1ad1..c37fa753d5e 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -282,12 +282,12 @@ import org.sonar.server.webhook.WebhookQGChangeEventListener; import org.sonar.server.webhook.ws.WebhooksWsModule; import org.sonar.server.ws.WebServiceEngine; import org.sonar.server.ws.ws.WebServicesWsModule; -import org.sonar.telemetry.deprecated.CloudUsageDataProvider; -import org.sonar.telemetry.deprecated.QualityProfileDataProvider; -import org.sonar.telemetry.deprecated.TelemetryClient; -import org.sonar.telemetry.deprecated.TelemetryDaemon; -import org.sonar.telemetry.deprecated.TelemetryDataJsonWriter; -import org.sonar.telemetry.deprecated.TelemetryDataLoaderImpl; +import org.sonar.telemetry.legacy.CloudUsageDataProvider; +import org.sonar.telemetry.legacy.QualityProfileDataProvider; +import org.sonar.telemetry.legacy.TelemetryClient; +import org.sonar.telemetry.legacy.TelemetryDaemon; +import org.sonar.telemetry.legacy.TelemetryDataJsonWriter; +import org.sonar.telemetry.legacy.TelemetryDataLoaderImpl; import static org.sonar.core.extension.CoreExtensionsInstaller.noAdditionalSideFilter; import static org.sonar.core.extension.PlatformLevelPredicates.hasPlatformLevel4OrNone; diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/telemetry/TelemetryVersionProvider.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/telemetry/TelemetryVersionProvider.java index 12b0f40c17a..d76962b7cea 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/telemetry/TelemetryVersionProvider.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/telemetry/TelemetryVersionProvider.java @@ -20,10 +20,10 @@ package org.sonar.server.platform.telemetry; import org.sonar.api.platform.Server; -import org.sonar.server.telemetry.Dimension; -import org.sonar.server.telemetry.Granularity; -import org.sonar.server.telemetry.TelemetryDataProvider; -import org.sonar.server.telemetry.TelemetryDataType; +import org.sonar.telemetry.Dimension; +import org.sonar.telemetry.Granularity; +import org.sonar.telemetry.TelemetryDataProvider; +import org.sonar.telemetry.TelemetryDataType; public class TelemetryVersionProvider implements TelemetryDataProvider { diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/telemetry/TelemetryVersionProviderTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/telemetry/TelemetryVersionProviderTest.java new file mode 100644 index 00000000000..d5ea987eb6d --- /dev/null +++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/telemetry/TelemetryVersionProviderTest.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.telemetry; + +import org.junit.jupiter.api.Test; +import org.sonar.api.platform.Server; +import org.sonar.telemetry.Dimension; +import org.sonar.telemetry.Granularity; +import org.sonar.telemetry.TelemetryDataType; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +class TelemetryVersionProviderTest { + + /** + * To increase coverage :shrug: + */ + @Test + void testGetters() { + Server server = mock(); + when(server.getVersion()).thenReturn("10.6"); + + TelemetryVersionProvider telemetryVersionProvider = new TelemetryVersionProvider(server); + + assertEquals("version", telemetryVersionProvider.getMetricKey()); + assertEquals(Dimension.INSTALLATION, telemetryVersionProvider.getDimension()); + assertEquals(Granularity.DAILY, telemetryVersionProvider.getGranularity()); + assertEquals(TelemetryDataType.STRING, telemetryVersionProvider.getType()); + assertEquals("10.6", telemetryVersionProvider.getValue()); + assertThrows(IllegalStateException.class, telemetryVersionProvider::getUuidValues); + } +} diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/telemetry/TelemetryVersionProviderTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/telemetry/TelemetryVersionProviderTest.java deleted file mode 100644 index 4335f71f9a6..00000000000 --- a/server/sonar-webserver/src/test/java/org/sonar/server/telemetry/TelemetryVersionProviderTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.telemetry; - -import org.junit.jupiter.api.Test; -import org.sonar.api.platform.Server; -import org.sonar.server.platform.telemetry.TelemetryVersionProvider; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -class TelemetryVersionProviderTest { - - /** - * To increase coverage :shrug: - */ - @Test - void testGetters() { - Server server = mock(); - when(server.getVersion()).thenReturn("10.6"); - - TelemetryVersionProvider telemetryVersionProvider = new TelemetryVersionProvider(server); - - assertEquals("version", telemetryVersionProvider.getMetricKey()); - assertEquals(Dimension.INSTALLATION, telemetryVersionProvider.getDimension()); - assertEquals(Granularity.DAILY, telemetryVersionProvider.getGranularity()); - assertEquals(TelemetryDataType.STRING, telemetryVersionProvider.getType()); - assertEquals("10.6", telemetryVersionProvider.getValue()); - assertThrows(IllegalStateException.class, telemetryVersionProvider::getUuidValues); - } -} -- cgit v1.2.3