From e71ab396b44b4a4f6e03edcba97564b27de6efa9 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 2 Sep 2016 10:04:35 +0200 Subject: [PATCH] SONAR-7986 Accept multiple keys in api/settings/rest --- .../src/test/java/it/settings/PropertySetsTest.java | 11 +++-------- .../src/test/java/it/settings/SettingsTest.java | 4 ++-- it/it-tests/src/test/java/util/ItUtils.java | 5 ++--- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/it/it-tests/src/test/java/it/settings/PropertySetsTest.java b/it/it-tests/src/test/java/it/settings/PropertySetsTest.java index 57816603844..7cbd1ba9aba 100644 --- a/it/it-tests/src/test/java/it/settings/PropertySetsTest.java +++ b/it/it-tests/src/test/java/it/settings/PropertySetsTest.java @@ -30,7 +30,6 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.sonarqube.ws.Settings; -import org.sonarqube.ws.client.setting.ResetRequest; import org.sonarqube.ws.client.setting.SetRequest; import org.sonarqube.ws.client.setting.SettingsService; import org.sonarqube.ws.client.setting.ValuesRequest; @@ -39,10 +38,10 @@ import pageobjects.settings.SettingsPage; import static com.google.common.collect.Lists.newArrayList; import static java.util.Arrays.asList; -import static java.util.Arrays.stream; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; import static util.ItUtils.newAdminWsClient; +import static util.ItUtils.resetSettings; public class PropertySetsTest { @@ -61,7 +60,7 @@ public class PropertySetsTest { @After public void reset_settings() throws Exception { - resetSetting("sonar.demo", "sonar.autogenerated", "sonar.test.jira.servers"); + resetSettings(orchestrator, null, "sonar.demo", "sonar.autogenerated", "sonar.test.jira.servers"); } @Test @@ -119,7 +118,7 @@ public class PropertySetsTest { .setFieldValues(newArrayList("{\"url\":\"http://jira1\"}", "{\"port\":\"12345\"}")) .build()); - resetSetting("sonar.test.jira.servers"); + resetSettings(orchestrator, null, "sonar.test.jira.servers"); assertThat(SETTINGS.values(ValuesRequest.builder().setKeys("sonar.test.jira.servers").build()).getSettingsList()).isEmpty(); } @@ -141,8 +140,4 @@ public class PropertySetsTest { return settings.get(0); } - static void resetSetting(String... keys) { - stream(keys).forEach(key -> SETTINGS.reset(ResetRequest.builder().setKeys(keys).build())); - } - } diff --git a/it/it-tests/src/test/java/it/settings/SettingsTest.java b/it/it-tests/src/test/java/it/settings/SettingsTest.java index 36d0eff5000..d44d6c3d923 100644 --- a/it/it-tests/src/test/java/it/settings/SettingsTest.java +++ b/it/it-tests/src/test/java/it/settings/SettingsTest.java @@ -39,7 +39,7 @@ import util.selenium.SeleneseTest; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.newAdminWsClient; -import static util.ItUtils.setServerProperty; +import static util.ItUtils.resetSettings; public class SettingsTest { @@ -60,7 +60,7 @@ public class SettingsTest { @After public void reset_settings() throws Exception { - setServerProperty(orchestrator, PLUGIN_SETTING_KEY, null); + resetSettings(orchestrator, null, PLUGIN_SETTING_KEY); } // SONAR-4404 diff --git a/it/it-tests/src/test/java/util/ItUtils.java b/it/it-tests/src/test/java/util/ItUtils.java index 6db0320f6b1..50c5a5437ac 100644 --- a/it/it-tests/src/test/java/util/ItUtils.java +++ b/it/it-tests/src/test/java/util/ItUtils.java @@ -55,6 +55,7 @@ import org.sonar.wsclient.services.PropertyUpdateQuery; import org.sonarqube.ws.client.HttpConnector; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsClientFactories; +import org.sonarqube.ws.client.setting.ResetRequest; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.FluentIterable.from; @@ -225,9 +226,7 @@ public class ItUtils { } public static void resetSettings(Orchestrator orchestrator, @Nullable String componentKey, String... keys) { - for (String key : keys) { - setServerProperty(orchestrator, componentKey, key, null); - } + newAdminWsClient(orchestrator).settingsService().reset(ResetRequest.builder().setKeys(keys).setComponentKey(componentKey).build()); } public static void resetPeriods(Orchestrator orchestrator) { -- 2.39.5