public class ValuesAction implements SettingsWsAction {
private static final Splitter COMMA_SPLITTER = Splitter.on(",");
+ private static final String COMMA_ENCODED_VALUE = "%2C";
private final DbClient dbClient;
private final ComponentFinder componentFinder;
}
valueBuilder.setFieldsValues(builder);
} else if (definition.multiValues()) {
- valueBuilder.setValues(Settings.Values.newBuilder().addAllValues(COMMA_SPLITTER.split(value)));
+ List<String> values = COMMA_SPLITTER.splitToList(value).stream().map(v -> v.replace(COMMA_ENCODED_VALUE, ",")).collect(Collectors.toList());
+ valueBuilder.setValues(Settings.Values.newBuilder().addAllValues(values));
} else {
valueBuilder.setValue(value);
}
assertThat(bar.hasFieldsValues()).isFalse();
}
+ @Test
+ public void return_multi_value_with_coma() throws Exception {
+ setUserAsSystemAdmin();
+ propertyDefinitions.addComponent(PropertyDefinition.builder("global").multiValues(true).build());
+ insertProperties(newGlobalPropertyDto().setKey("global").setValue("three,four%2Cfive"));
+
+ ValuesWsResponse result = executeRequestForGlobalProperties("global");
+
+ assertThat(result.getSettingsList()).hasSize(1);
+ Settings.Setting setting = result.getSettings(0);
+ assertThat(setting.getKey()).isEqualTo("global");
+ assertThat(setting.getValues().getValuesList()).containsOnly("three", "four,five");
+ }
+
@Test
public void return_property_set() throws Exception {
setUserAsSystemAdmin();