@Test public void return_settings_definitions_with_deprecated_key() { logIn(); propertyDefinitions.addComponent(PropertyDefinition .builder("foo") .name("Foo") .deprecatedKey("deprecated") .build()); ListDefinitionsWsResponse result = executeRequest(); assertThat(result.getDefinitionsList()).hasSize(1); Definition definition = result.getDefinitions(0); assertThat(definition.getKey()).isEqualTo("foo"); assertThat(definition.getName()).isEqualTo("Foo"); assertThat(definition.getDeprecatedKey()).isEqualTo("deprecated"); }
@Test public void return_value_of_deprecated_key() { logIn(); definitions.addComponent(PropertyDefinition .builder("foo") .deprecatedKey("deprecated") .build()); propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one")); ValuesWsResponse result = executeRequestForGlobalProperties("deprecated"); assertThat(result.getSettingsList()).hasSize(1); Settings.Setting value = result.getSettings(0); assertThat(value.getKey()).isEqualTo("deprecated"); assertThat(value.getValue()).isEqualTo("one"); }
@Test public void get_trims_key_before_looking_for_replacement() { Random random = new Random(); String key = RandomStringUtils.randomAlphanumeric(4); String deprecatedKey = RandomStringUtils.randomAlphanumeric(4); PropertyDefinitions underTest = new PropertyDefinitions(singletonList( PropertyDefinition.builder(key) .deprecatedKey(deprecatedKey) .build())); String untrimmedKey = blank(random) + deprecatedKey + blank(random); assertThat(underTest.get(untrimmedKey).key()) .describedAs("expecting key %s being returned for get(%s)", key, untrimmedKey) .isEqualTo(key); }
"at 30 minutes, then the value of this property would be 30.") .category(CoreProperties.CATEGORY_TECHNICAL_DEBT) .deprecatedKey("workUnitsBySizePoint") .build(), "2,500 LOC will have a technical debt ratio of 24000/(30 * 2,500) = 0.32. That yields a maintainability rating of D.") .category(CoreProperties.CATEGORY_TECHNICAL_DEBT) .deprecatedKey("ratingGrid") .build(), .description("The parameters specified here for a given language will override the general parameters defined in this section.") .category(CoreProperties.CATEGORY_TECHNICAL_DEBT) .deprecatedKey("languageSpecificParameters") .fields( PropertyFieldDefinition.build(CoreProperties.LANGUAGE_SPECIFIC_PARAMETERS_LANGUAGE_KEY)
context.addExtensions( PropertyDefinition.builder(FILE_SUFFIXES_KEY) .deprecatedKey(OLD_FILE_SUFFIXES_KEY) .name("File Suffixes") .description("Comma-separated list of suffixes of PL/SQL files to analyze.") .build(), PropertyDefinition.builder(FORMS_METADATA_KEY) .deprecatedKey(OLD_FORMS_METADATA_KEY) .name("Oracle Forms metadata file") .description("Path to the JSON file with the Oracle Forms metadata.") .build(), PropertyDefinition.builder(ERROR_RECOVERY_KEY) .deprecatedKey(OLD_ERROR_RECOVERY_KEY) .name("Parse error recovery") .description("Defines mode for error handling of parsing errors. 'False' (strict) breaks after an error or 'True' (tolerant, default) continues.")
static PropertyDefinition create(Property annotation) { Builder builder = PropertyDefinition.builder(annotation.key()) .name(annotation.name()) .defaultValue(annotation.defaultValue()) .description(annotation.description()) .category(annotation.category()) .type(annotation.type()) .options(Arrays.asList(annotation.options())) .multiValues(annotation.multiValues()) .propertySetKey(annotation.propertySetKey()) .fields(PropertyFieldDefinition.create(annotation.fields())) .deprecatedKey(annotation.deprecatedKey()); List<String> qualifiers = newArrayList(); if (annotation.project()) { qualifiers.add(Qualifiers.PROJECT); } if (annotation.module()) { qualifiers.add(Qualifiers.MODULE); } if (annotation.global()) { builder.onQualifiers(qualifiers); } else { builder.onlyOnQualifiers(qualifiers); } return builder.build(); }
static PropertyDefinition create(Property annotation) { Builder builder = PropertyDefinition.builder(annotation.key()) .name(annotation.name()) .defaultValue(annotation.defaultValue()) .description(annotation.description()) .category(annotation.category()) .type(annotation.type()) .options(asList(annotation.options())) .multiValues(annotation.multiValues()) .propertySetKey(annotation.propertySetKey()) .fields(PropertyFieldDefinition.create(annotation.fields())) .deprecatedKey(annotation.deprecatedKey()); List<String> qualifiers = new ArrayList<>(); if (annotation.project()) { qualifiers.add(Qualifiers.PROJECT); } if (annotation.module()) { qualifiers.add(Qualifiers.MODULE); } if (annotation.global()) { builder.onQualifiers(qualifiers); } else { builder.onlyOnQualifiers(qualifiers); } return builder.build(); }
private static ImmutableList<PropertyDefinition> pluginProperties() { return ImmutableList.of( PropertyDefinition.builder(HtmlConstants.FILE_EXTENSIONS_PROP_KEY) .name("HTML File suffixes") .description("List of file suffixes that will be scanned.") .category(CATEGORY) .defaultValue(HtmlConstants.FILE_EXTENSIONS_DEF_VALUE) .deprecatedKey("sonar.web.file.suffixes") .onQualifiers(Qualifiers.PROJECT) .multiValues(true) .build(), PropertyDefinition.builder(HtmlConstants.JSP_FILE_EXTENSIONS_PROP_KEY) .name("JSP File suffixes") .description("List of JSP file suffixes that will be scanned.") .category(CATEGORY) .defaultValue(HtmlConstants.JSP_FILE_EXTENSIONS_DEF_VALUE) .onQualifiers(Qualifiers.PROJECT) .multiValues(true) .build() ); } }
public List getExtensions() { return ImmutableList.of( IssuesDensityMetrics.class, HotspotMostViolatedComponentsWidget.class, WeightedIssuesDecorator.class, IssuesDensityDecorator.class, PropertyDefinition.builder(WEIGHTED_ISSUES_PROPERTY) .name("Rules weight") .description("A weight is associated to each severity to emphasize the most critical issues.") .defaultValue(WEIGHTED_ISSUES_DEFAULT_VALUE) .deprecatedKey("sonar.core.rule.weight") .build() ); }
public static ImmutableList<PropertyDefinition> properties() { return ImmutableList.of( PropertyDefinition.builder(REPORT_PATHS_PROPERTY_KEY) .name("Unit tests results report paths") .description("List of comma-separated paths (absolute or relative) containing unit tests results report.") .category(CATEGORY_CODE_COVERAGE) .onQualifiers(Qualifiers.PROJECT) .multiValues(true) .deprecatedKey(OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY) .build()); }
public static ImmutableList<PropertyDefinition> properties() { return ImmutableList.of( PropertyDefinition.builder(REPORT_PATHS_PROPERTY_KEY) .name("Coverage report paths") .description("List of comma-separated paths (absolute or relative) containing coverage report.") .category(CATEGORY_CODE_COVERAGE) .onQualifiers(Qualifiers.PROJECT) .multiValues(true) .deprecatedKey(OLD_COVERAGE_REPORT_PATHS_PROPERTY_KEY) .build()); }
.deprecatedKey("sonar.branding.image") .name("Logo URL") .description("URL to logo image. Any standard format is accepted.") .build(), PropertyDefinition.builder(WebConstants.SONAR_LF_LOGO_WIDTH_PX) .deprecatedKey("sonar.branding.image.width") .name("Width of image in pixels") .description("Width in pixels, given that the height of the the image is constrained to 30px.") .deprecatedKey("sonar.timemachine.period1") .description("Period used to compare measures and track new issues. Values are : " + "<ul class='bullet'><li>Number of days before analysis, for example 5.</li>" +
"at 30 minutes, then the value of this property would be 30.") .category(CoreProperties.CATEGORY_TECHNICAL_DEBT) .deprecatedKey("workUnitsBySizePoint") .build(), "2,500 LOC will have a technical debt ratio of 24000/(30 * 2,500) = 0.32. That yields a maintainability rating of D.") .category(CoreProperties.CATEGORY_TECHNICAL_DEBT) .deprecatedKey("ratingGrid") .build(), .description("The parameters specified here for a given language will override the general parameters defined in this section.") .category(CoreProperties.CATEGORY_TECHNICAL_DEBT) .deprecatedKey("languageSpecificParameters") .fields( PropertyFieldDefinition.build(CoreProperties.LANGUAGE_SPECIFIC_PARAMETERS_LANGUAGE_KEY)
static PropertyDefinition create(Property annotation) { Builder builder = PropertyDefinition.builder(annotation.key()) .name(annotation.name()) .defaultValue(annotation.defaultValue()) .description(annotation.description()) .category(annotation.category()) .type(annotation.type()) .options(asList(annotation.options())) .multiValues(annotation.multiValues()) .propertySetKey(annotation.propertySetKey()) .fields(PropertyFieldDefinition.create(annotation.fields())) .deprecatedKey(annotation.deprecatedKey()); List<String> qualifiers = new ArrayList<>(); if (annotation.project()) { qualifiers.add(Qualifiers.PROJECT); } if (annotation.module()) { qualifiers.add(Qualifiers.MODULE); } if (annotation.global()) { builder.onQualifiers(qualifiers); } else { builder.onlyOnQualifiers(qualifiers); } return builder.build(); }
@Test public void remove_setting_by_deprecated_key() { logInAsSystemAdministrator(); definitions.addComponent(PropertyDefinition.builder("foo").deprecatedKey("old").build()); propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one")); executeRequestOnGlobalSetting("old"); assertGlobalPropertyDoesNotExist("foo"); }
public static ImmutableList<PropertyDefinition> properties() { return ImmutableList.of( PropertyDefinition.builder(REPORT_PATHS_PROPERTY_KEY) .name("Unit tests results report paths") .description("List of comma-separated paths (absolute or relative) containing unit tests results report.") .category(CATEGORY_CODE_COVERAGE) .onQualifiers(Qualifiers.PROJECT) .multiValues(true) .deprecatedKey(OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY) .build()); }
@Test public void persist_global_property_with_deprecated_key() { definitions.addComponent(PropertyDefinition .builder("my.key") .deprecatedKey("my.old.key") .name("foo") .description("desc") .category("cat") .subCategory("subCat") .type(PropertyType.STRING) .defaultValue("default") .build()); callForGlobalSetting("my.old.key", "My Value"); assertGlobalSetting("my.key", "My Value"); }
public static ImmutableList<PropertyDefinition> properties() { return ImmutableList.of( PropertyDefinition.builder(REPORT_PATHS_PROPERTY_KEY) .name("Coverage report paths") .description("List of comma-separated paths (absolute or relative) containing coverage report.") .category(CATEGORY_CODE_COVERAGE) .onQualifiers(Qualifiers.PROJECT) .multiValues(true) .deprecatedKey(OLD_COVERAGE_REPORT_PATHS_PROPERTY_KEY) .build()); }
@Test public void fail_when_deprecated_key_and_new_key_are_used() { logIn(); definitions.addComponent(PropertyDefinition .builder("foo") .deprecatedKey("deprecated") .build()); propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one")); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("'foo' and 'deprecated' cannot be used at the same time as they refer to the same setting"); executeRequestForGlobalProperties("foo", "deprecated"); }
@Test public void does_not_return_value_of_deprecated_key() { logIn(); definitions.addComponent(PropertyDefinition.builder("foo").deprecatedKey("deprecated").build()); propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one")); executeAndVerify(null, "deprecated", "empty.json"); }