From 7d9bc94ca237710ea1cddfdeb956fb6a3f136efd Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Mon, 19 Jan 2015 17:50:54 +0100 Subject: [PATCH] SONAR-6019 Change format of "characteristics" in api/rules/app WS --- .../java/org/sonar/server/rule/ws/AppAction.java | 12 +++++++++--- .../org/sonar/server/rule/ws/AppActionTest/app.json | 8 ++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java index 1e5dd3561ef..7ca17abfd90 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java @@ -135,11 +135,17 @@ public class AppAction implements RequestHandler { DefaultDebtCharacteristic fullCarac = (DefaultDebtCharacteristic) carac; caracById.put(fullCarac.id(), fullCarac); } - json.name("characteristics").beginObject(); + json.name("characteristics").beginArray(); for (DefaultDebtCharacteristic carac : caracById.values()) { - json.prop(carac.key(), carac.isSub() ? caracById.get(carac.parentId()).name() + ": " + carac.name() : carac.name()); + json.beginObject() + .prop("key", carac.key()) + .prop("name", carac.name()); + if (carac.isSub()) { + json.prop("parent", caracById.get(carac.parentId()).key()); + } + json.endObject(); } - json.endObject(); + json.endArray(); } void define(WebService.NewController controller) { diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/AppActionTest/app.json b/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/AppActionTest/app.json index c438dc3f2e5..2fd983ef78c 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/AppActionTest/app.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/AppActionTest/app.json @@ -34,8 +34,8 @@ "DEPRECATED": "rules.status.deprecated", "READY": "rules.status.ready" }, - "characteristics": { - "REUSABILITY": "Reusability", - "MODULARITY": "Reusability: Modularity" - }} + "characteristics": [ + {"key": "REUSABILITY", "name": "Reusability"}, + {"key": "MODULARITY", "name": "Modularity", "parent": "REUSABILITY"} + ]} -- 2.39.5