diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2017-08-22 17:42:14 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk@users.noreply.github.com> | 2017-08-30 16:24:53 +0200 |
commit | 4cc72a7766f82af20c6157047156859d06424b02 (patch) | |
tree | f0c2f778a552b005c90e4056421ed2dbe85d567b /sonar-core/src | |
parent | 5c2b4dc4c2467df7885b05f497b7f006c5a23ded (diff) | |
download | sonarqube-4cc72a7766f82af20c6157047156859d06424b02.tar.gz sonarqube-4cc72a7766f82af20c6157047156859d06424b02.zip |
SONAR-9721 Telemetry properties defined in a specific PropertyDefinition class
Diffstat (limited to 'sonar-core/src')
4 files changed, 105 insertions, 1 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java index d1b3dbea6c9..66c270011c6 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java +++ b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java @@ -62,6 +62,7 @@ public class CorePropertyDefinitions { defs.addAll(PurgeProperties.all()); defs.addAll(EmailSettings.definitions()); defs.addAll(WebhookProperties.all()); + defs.addAll(TelemetryProperties.all()); defs.addAll(ImmutableList.of( PropertyDefinition.builder(PROP_PASSWORD) diff --git a/sonar-core/src/main/java/org/sonar/core/config/TelemetryProperties.java b/sonar-core/src/main/java/org/sonar/core/config/TelemetryProperties.java new file mode 100644 index 00000000000..7eaf0b44620 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/config/TelemetryProperties.java @@ -0,0 +1,63 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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.core.config; + +import com.google.common.collect.ImmutableList; +import java.util.List; +import org.sonar.api.PropertyType; +import org.sonar.api.config.PropertyDefinition; + +public class TelemetryProperties { + + public static final String PROP_ENABLE = "sonar.telemetry.enable"; + public static final String PROP_FREQUENCY = "sonar.telemetry.frequencyInSeconds"; + public static final String PROP_URL = "sonar.telemetry.url"; + + private TelemetryProperties() { + // only static stuff + } + + public static List<PropertyDefinition> all() { + return ImmutableList.of( + PropertyDefinition.builder(PROP_ENABLE) + .defaultValue(Boolean.toString(true)) + .type(PropertyType.BOOLEAN) + .name("Share SonarQube statistics") + .description("By sharing anonymous SonarQube statistics, you help us understand how SonarQube is used so we can improve the plugin to work even better for you. " + + "We don't collect source code or IP addresses. And we don't share the data with anyone else.") + .hidden() + .build(), + PropertyDefinition.builder(PROP_FREQUENCY) + // 6 hours in seconds + .defaultValue("21600") + .type(PropertyType.INTEGER) + .name("Frequency of telemetry checks, in seconds") + .hidden() + .build(), + PropertyDefinition.builder(PROP_URL) + .defaultValue("https://telemetry.sonarsource.com/sonarqube") + .type(PropertyType.STRING) + .name("URL where telemetry data is sent") + .hidden() + .build() + ); + + } +} diff --git a/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java b/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java index 50a3028672f..22b04b1f5e4 100644 --- a/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java @@ -33,7 +33,7 @@ public class CorePropertyDefinitionsTest { @Test public void all() { List<PropertyDefinition> defs = CorePropertyDefinitions.all(); - assertThat(defs).hasSize(58); + assertThat(defs).hasSize(61); } @Test diff --git a/sonar-core/src/test/java/org/sonar/core/config/TelemetryPropertiesTest.java b/sonar-core/src/test/java/org/sonar/core/config/TelemetryPropertiesTest.java new file mode 100644 index 00000000000..f66919e8b6c --- /dev/null +++ b/sonar-core/src/test/java/org/sonar/core/config/TelemetryPropertiesTest.java @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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.core.config; + +import org.junit.Test; +import org.sonar.api.config.Configuration; +import org.sonar.api.config.PropertyDefinitions; +import org.sonar.api.config.internal.MapSettings; + +import static org.assertj.core.api.Assertions.assertThat; + +public class TelemetryPropertiesTest { + + private Configuration underTest = new MapSettings(new PropertyDefinitions(TelemetryProperties.all())).asConfig(); + + @Test + public void default_telemetry_properties() { + assertThat(underTest.getBoolean("sonar.telemetry.enable")).hasValue(true); + assertThat(underTest.getInt("sonar.telemetry.frequencyInSeconds")).hasValue(6 * 60 * 60); + assertThat(underTest.get("sonar.telemetry.url")).hasValue("https://telemetry.sonarsource.com/sonarqube"); + } +} |