]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7968 Return field description in /api/settings/list_definitions WS
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 24 Aug 2016 10:06:25 +0000 (12:06 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 24 Aug 2016 10:09:41 +0000 (12:09 +0200)
server/sonar-server/src/main/java/org/sonar/server/settings/ws/ListDefinitionsAction.java
server/sonar-server/src/main/resources/org/sonar/server/settings/ws/list_definitions-example.json
server/sonar-server/src/test/java/org/sonar/server/settings/ws/ListDefinitionsActionTest.java
sonar-ws/src/main/protobuf/ws-settings.proto

index 1475d0ab1537a3ece9c5f3d07f839a6cf2ad01a7..107046420eddd7e1383f5c03999873541f00e0ca 100644 (file)
@@ -140,6 +140,7 @@ public class ListDefinitionsAction implements SettingsWsAction {
     builder.addFieldsBuilder()
       .setKey(fieldDefinition.key())
       .setName(fieldDefinition.name())
+      .setDescription(fieldDefinition.description())
       .setType(Settings.Type.valueOf(fieldDefinition.type().name()))
       .setIndicativeSize(fieldDefinition.indicativeSize())
       .addAllOptions(fieldDefinition.options())
index 79b4e317ebd6351614062a23bc1ed8cac007dd35..041b22da2e83d9b0ebe501432243077f58f144b0 100644 (file)
@@ -50,6 +50,7 @@
         {
           "key": "text",
           "name": "Text",
+          "description": "Text field description",
           "type": "TEXT",
           "indicativeSize": 10,
           "options": []
@@ -57,6 +58,7 @@
         {
           "key": "list",
           "name": "List",
+          "description": "List field description",
           "type": "SINGLE_SELECT_LIST",
           "indicativeSize": 20,
           "options": [
index 2365b157c6b90cad207524f1149be2025a026733..b26687cbb2ad8d7c5510aeb0ca308fabe899226b 100644 (file)
@@ -172,8 +172,8 @@ public class ListDefinitionsActionTest {
       .builder("foo")
       .type(PropertyType.PROPERTY_SET)
       .fields(
-        PropertyFieldDefinition.build("boolean").name("Boolean").type(PropertyType.BOOLEAN).indicativeSize(15).build(),
-        PropertyFieldDefinition.build("list").name("List").type(PropertyType.SINGLE_SELECT_LIST).options("one", "two").build())
+        PropertyFieldDefinition.build("boolean").name("Boolean").description("boolean desc").type(PropertyType.BOOLEAN).indicativeSize(15).build(),
+        PropertyFieldDefinition.build("list").name("List").description("list desc").type(PropertyType.SINGLE_SELECT_LIST).options("one", "two").build())
       .build());
 
     ListDefinitionsWsResponse result = newRequest();
@@ -185,12 +185,14 @@ public class ListDefinitionsActionTest {
 
     assertThat(definition.getFields(0).getKey()).isEqualTo("boolean");
     assertThat(definition.getFields(0).getName()).isEqualTo("Boolean");
+    assertThat(definition.getFields(0).getDescription()).isEqualTo("boolean desc");
     assertThat(definition.getFields(0).getType()).isEqualTo(BOOLEAN);
     assertThat(definition.getFields(0).getOptionsCount()).isZero();
     assertThat(definition.getFields(0).getIndicativeSize()).isEqualTo(15);
 
     assertThat(definition.getFields(1).getKey()).isEqualTo("list");
     assertThat(definition.getFields(1).getName()).isEqualTo("List");
+    assertThat(definition.getFields(1).getDescription()).isEqualTo("list desc");
     assertThat(definition.getFields(1).getType()).isEqualTo(SINGLE_SELECT_LIST);
     assertThat(definition.getFields(1).getOptionsList()).containsExactly("one", "two");
     // 20 is the default value
@@ -359,11 +361,13 @@ public class ListDefinitionsActionTest {
         .fields(
           PropertyFieldDefinition.build("text")
             .name("Text")
+            .description("Text field description")
             .type(PropertyType.TEXT)
             .indicativeSize(10)
             .build(),
           PropertyFieldDefinition.build("list")
             .name("List")
+            .description("List field description")
             .type(PropertyType.SINGLE_SELECT_LIST)
             .options("value1", "value2")
             .build())
index f3a38e90b93cfeebdac75630c45e1b7c85c21d01..76da8a6910c4e1fa9a9cd80b56e65e149833e673 100644 (file)
@@ -45,9 +45,10 @@ message Definition {
 message Field {
   optional string key = 1;
   optional string name = 2;
-  optional Type type = 3;
-  optional int32 indicativeSize = 4;
-  repeated string options = 5;
+  optional string description = 3;
+  optional Type type = 4;
+  optional int32 indicativeSize = 5;
+  repeated string options = 6;
 }
 
 enum Type {