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;
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 {
@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
.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();
}
return settings.get(0);
}
- static void resetSetting(String... keys) {
- stream(keys).forEach(key -> SETTINGS.reset(ResetRequest.builder().setKeys(keys).build()));
- }
-
}
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 {
@After
public void reset_settings() throws Exception {
- setServerProperty(orchestrator, PLUGIN_SETTING_KEY, null);
+ resetSettings(orchestrator, null, PLUGIN_SETTING_KEY);
}
// SONAR-4404
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;
}
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) {