]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7986 Accept multiple keys in api/settings/rest 1201/head
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 2 Sep 2016 08:04:35 +0000 (10:04 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 2 Sep 2016 13:50:28 +0000 (15:50 +0200)
it/it-tests/src/test/java/it/settings/PropertySetsTest.java
it/it-tests/src/test/java/it/settings/SettingsTest.java
it/it-tests/src/test/java/util/ItUtils.java

index 57816603844c6ac5019988c37dfd2cbdb96027ee..7cbd1ba9aba77a64b8e84b96f97cb67ced878914 100644 (file)
@@ -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()));
-  }
-
 }
index 36d0eff50003ad8ac32cb9a553585c54d05fc6c7..d44d6c3d92300a79433d076a11e76f986071e5ba 100644 (file)
@@ -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
index 6db0320f6b1e981694b697c2efd5b426b394ee29..50c5a5437ac91812530e87530521af9eed718b75 100644 (file)
@@ -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) {