From ad8aa9a307a5680bea5433540d40cd75a40c94dc Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 24 Aug 2016 12:06:25 +0200 Subject: [PATCH] SONAR-7968 Return field description in /api/settings/list_definitions WS --- .../sonar/server/settings/ws/ListDefinitionsAction.java | 1 + .../server/settings/ws/list_definitions-example.json | 2 ++ .../server/settings/ws/ListDefinitionsActionTest.java | 8 ++++++-- sonar-ws/src/main/protobuf/ws-settings.proto | 7 ++++--- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/settings/ws/ListDefinitionsAction.java b/server/sonar-server/src/main/java/org/sonar/server/settings/ws/ListDefinitionsAction.java index 1475d0ab153..107046420ed 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/settings/ws/ListDefinitionsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/settings/ws/ListDefinitionsAction.java @@ -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()) diff --git a/server/sonar-server/src/main/resources/org/sonar/server/settings/ws/list_definitions-example.json b/server/sonar-server/src/main/resources/org/sonar/server/settings/ws/list_definitions-example.json index 79b4e317ebd..041b22da2e8 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/settings/ws/list_definitions-example.json +++ b/server/sonar-server/src/main/resources/org/sonar/server/settings/ws/list_definitions-example.json @@ -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": [ diff --git a/server/sonar-server/src/test/java/org/sonar/server/settings/ws/ListDefinitionsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/settings/ws/ListDefinitionsActionTest.java index 2365b157c6b..b26687cbb2a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/settings/ws/ListDefinitionsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/settings/ws/ListDefinitionsActionTest.java @@ -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()) diff --git a/sonar-ws/src/main/protobuf/ws-settings.proto b/sonar-ws/src/main/protobuf/ws-settings.proto index f3a38e90b93..76da8a6910c 100644 --- a/sonar-ws/src/main/protobuf/ws-settings.proto +++ b/sonar-ws/src/main/protobuf/ws-settings.proto @@ -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 { -- 2.39.5