]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7969 Replace fieldsValue by fieldValues in response
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 31 Aug 2016 08:49:03 +0000 (10:49 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 31 Aug 2016 09:47:23 +0000 (11:47 +0200)
it/it-tests/src/test/java/it/settings/PropertySetsTest.java
it/it-tests/src/test/java/it/settings/SettingsTest.java
server/sonar-server/src/main/java/org/sonar/server/setting/ws/ValuesAction.java
server/sonar-server/src/main/resources/org/sonar/server/setting/ws/values-example.json
server/sonar-server/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java
sonar-ws/src/main/protobuf/ws-settings.proto

index ea55aa7c17cfc28ba66edd7fbd033b43be3f6e22..ea57024ab392b9fefc532cae00f94bd92cebac76 100644 (file)
@@ -120,9 +120,9 @@ public class PropertySetsTest {
 
   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++;
     }
index d49fafd15fb57e8355c4f5fe8d81ac1cfd8ce41c..6fc55ded699c4f4fd218ddd194f1990a642767a1 100644 (file)
@@ -26,6 +26,7 @@ import java.io.IOException;
 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;
@@ -49,6 +50,13 @@ public class SettingsTest {
   @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);
@@ -80,7 +88,7 @@ public class SettingsTest {
 
   @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");
@@ -88,17 +96,13 @@ public class SettingsTest {
 
   @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);
index 4b6bc9b824c8a72d0b396756975fe680fece32cd..d6e8862e9e8a9559c8e3eab3e1857db4b544b2ba 100644 (file)
@@ -224,7 +224,7 @@ public class ValuesAction implements SettingsWsAction {
         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 {
index 02d668904ea8098207afb16b3c1090ef347502b0..f6c39e5a6dcf21a3ba31e37f6b85afcaec0d0563 100644 (file)
@@ -16,7 +16,7 @@
     },
     {
       "key": "sonar.demo",
-      "fieldsValues": [
+      "fieldValues": [
         {
           "boolean": "true",
           "text": "foo"
index 6db8874796d880e4e864d5c6cb7520da5f0b3e5b..59ec14cf1d069c4bdbb5f1100c042bda0c217379 100644 (file)
@@ -105,7 +105,7 @@ public class ValuesActionTest {
     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();
   }
 
@@ -132,13 +132,13 @@ public class ValuesActionTest {
     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
@@ -588,9 +588,9 @@ public class ValuesActionTest {
   }
 
   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++;
     }
index 18298563495fd2762388c5669577ac57ae83ce88..be09b3d1b69f4027204f02153fcbc8475771858a 100644 (file)
@@ -76,7 +76,7 @@ message Setting {
   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;