private void assertPropertySet(String baseSettingKey, List<Map.Entry<String, String>>... fieldsValues) {
Settings.Setting setting = getSetting(baseSettingKey);
- assertThat(setting.getFieldsValues().getFieldValuesList()).hasSize(fieldsValues.length);
+ assertThat(setting.getFieldValues().getFieldValuesList()).hasSize(fieldsValues.length);
int index = 0;
- for (Settings.FieldValues.Value fieldsValue : setting.getFieldsValues().getFieldValuesList()) {
+ for (Settings.FieldValues.Value fieldsValue : setting.getFieldValues().getFieldValuesList()) {
assertThat(fieldsValue.getValue()).containsOnly(fieldsValues[index].toArray(new Map.Entry[] {}));
index++;
}
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.After;
+import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.sonarqube.ws.Settings;
@ClassRule
public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR;
+ static SettingsService SETTINGS;
+
+ @BeforeClass
+ public static void initSettingsService() throws Exception {
+ SETTINGS = newAdminWsClient(orchestrator).settingsService();
+ }
+
@After
public void reset_settings() throws Exception {
setServerProperty(orchestrator, PLUGIN_SETTING_KEY, null);
@Test
public void set_value() throws Exception {
- settingsService().set(SetRequest.builder().setKey(PLUGIN_SETTING_KEY).setValue("some value").build());
+ SETTINGS.set(SetRequest.builder().setKey(PLUGIN_SETTING_KEY).setValue("some value").build());
String value = getSetting(PLUGIN_SETTING_KEY).getValue();
assertThat(value).isEqualTo("some value");
@Test
public void remove_value() throws Exception {
- settingsService().set(SetRequest.builder().setKey(PLUGIN_SETTING_KEY).setValue("some value").build());
- settingsService().reset(ResetRequest.builder().setKey(PLUGIN_SETTING_KEY).build());
+ SETTINGS.set(SetRequest.builder().setKey(PLUGIN_SETTING_KEY).setValue("some value").build());
+ SETTINGS.reset(ResetRequest.builder().setKey(PLUGIN_SETTING_KEY).build());
assertThat(getSetting(PLUGIN_SETTING_KEY).getValue()).isEqualTo("aDefaultValue");
}
- private static SettingsService settingsService() {
- return newAdminWsClient(orchestrator).settingsService();
- }
-
private Settings.Setting getSetting(String key) {
- Settings.ValuesWsResponse response = settingsService().values(ValuesRequest.builder().setKeys(key).build());
+ Settings.ValuesWsResponse response = SETTINGS.values(ValuesRequest.builder().setKeys(key).build());
List<Settings.Setting> settings = response.getSettingsList();
assertThat(settings).hasSize(1);
return settings.get(0);
return;
}
if (definition.type().equals(PROPERTY_SET)) {
- valueBuilder.setFieldsValues(createFieldValuesBuilder(setting.getPropertySets()));
+ valueBuilder.setFieldValues(createFieldValuesBuilder(setting.getPropertySets()));
} else if (definition.multiValues()) {
valueBuilder.setValues(createValuesBuilder(value));
} else {
},
{
"key": "sonar.demo",
- "fieldsValues": [
+ "fieldValues": [
{
"boolean": "true",
"text": "foo"
assertThat(value.getKey()).isEqualTo("foo");
assertThat(value.getValue()).isEqualTo("one");
assertThat(value.hasValues()).isFalse();
- assertThat(value.hasFieldsValues()).isFalse();
+ assertThat(value.hasFieldValues()).isFalse();
assertThat(value.getInherited()).isFalse();
}
assertThat(foo.getKey()).isEqualTo("default");
assertThat(foo.hasValue()).isFalse();
assertThat(foo.getValues().getValuesList()).containsOnly("one", "two");
- assertThat(foo.hasFieldsValues()).isFalse();
+ assertThat(foo.hasFieldValues()).isFalse();
Settings.Setting bar = result.getSettings(1);
assertThat(bar.getKey()).isEqualTo("global");
assertThat(bar.hasValue()).isFalse();
assertThat(bar.getValues().getValuesList()).containsOnly("three", "four");
- assertThat(bar.hasFieldsValues()).isFalse();
+ assertThat(bar.hasFieldValues()).isFalse();
}
@Test
}
private void assertFieldValues(Settings.Setting setting, Map<String, String>... fieldsValues) {
- assertThat(setting.getFieldsValues().getFieldValuesList()).hasSize(fieldsValues.length);
+ assertThat(setting.getFieldValues().getFieldValuesList()).hasSize(fieldsValues.length);
int index = 0;
- for (Settings.FieldValues.Value fieldsValue : setting.getFieldsValues().getFieldValuesList()) {
+ for (Settings.FieldValues.Value fieldsValue : setting.getFieldValues().getFieldValuesList()) {
assertThat(fieldsValue.getValue()).isEqualTo(fieldsValues[index]);
index++;
}
optional string key = 1;
optional string value = 2;
optional Values values = 3;
- optional FieldValues fieldsValues = 4;
+ optional FieldValues fieldValues = 4;
optional bool inherited = 5;
optional string parentValue = 6;
optional Values parentValues = 7;