Search in sources :

Example 1 with Value

use of org.sonarqube.ws.Settings.FieldValues.Value in project sonarqube by SonarSource.

the class DefaultSettingsLoaderTest method should_load_global_propertyset_settings.

@Test
public void should_load_global_propertyset_settings() {
    Builder valuesBuilder = Value.newBuilder();
    valuesBuilder.getMutableValue().put("filepattern", "**/*.xml");
    valuesBuilder.getMutableValue().put("rulepattern", "*:S12345");
    Value value1 = valuesBuilder.build();
    valuesBuilder.clear();
    valuesBuilder.getMutableValue().put("filepattern", "**/*.java");
    valuesBuilder.getMutableValue().put("rulepattern", "*:S456");
    Value value2 = valuesBuilder.build();
    assertThat(DefaultSettingsLoader.toMap(asList(Setting.newBuilder().setKey("sonar.issue.exclusions.multicriteria").setFieldValues(FieldValues.newBuilder().addFieldValues(value1).addFieldValues(value2)).build()))).containsOnly(entry("sonar.issue.exclusions.multicriteria", "1,2"), entry("sonar.issue.exclusions.multicriteria.1.filepattern", "**/*.xml"), entry("sonar.issue.exclusions.multicriteria.1.rulepattern", "*:S12345"), entry("sonar.issue.exclusions.multicriteria.2.filepattern", "**/*.java"), entry("sonar.issue.exclusions.multicriteria.2.rulepattern", "*:S456"));
}
Also used : Builder(org.sonarqube.ws.Settings.FieldValues.Value.Builder) Value(org.sonarqube.ws.Settings.FieldValues.Value) Test(org.junit.Test)

Example 2 with Value

use of org.sonarqube.ws.Settings.FieldValues.Value in project sonarqube by SonarSource.

the class DefaultSettingsLoader method convertPropertySetToProps.

private static void convertPropertySetToProps(Map<String, String> result, Setting s) {
    List<String> ids = new ArrayList<>();
    int id = 1;
    for (Value v : s.getFieldValues().getFieldValuesList()) {
        for (Map.Entry<String, String> entry : v.getValue().entrySet()) {
            result.put(s.getKey() + "." + id + "." + entry.getKey(), entry.getValue());
        }
        ids.add(String.valueOf(id));
        id++;
    }
    result.put(s.getKey(), Joiner.on(',').join(ids));
}
Also used : ArrayList(java.util.ArrayList) Value(org.sonarqube.ws.Settings.FieldValues.Value) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

Value (org.sonarqube.ws.Settings.FieldValues.Value)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1 Builder (org.sonarqube.ws.Settings.FieldValues.Value.Builder)1