From d1273619390e7dd4e75448cc0110fa63fb2dab43 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Tue, 26 Jan 2016 11:06:07 +0100 Subject: [PATCH] SONAR-7070 WS qualitygates/app returns solely the leak period --- .../sonar/server/qualitygate/ws/AppAction.java | 18 ++++++------------ .../server/qualitygate/ws/AppActionTest.java | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/AppAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/AppAction.java index 01fa28aa9a6..cedc36c18ae 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/AppAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/AppAction.java @@ -19,7 +19,6 @@ */ package org.sonar.server.qualitygate.ws; -import java.util.Locale; import org.apache.commons.lang.BooleanUtils; import org.sonar.api.i18n.I18n; import org.sonar.api.measures.Metric; @@ -30,6 +29,8 @@ import org.sonar.api.utils.text.JsonWriter; import org.sonar.core.timemachine.Periods; import org.sonar.server.qualitygate.QualityGates; +import static java.lang.String.format; + public class AppAction implements QGateWsAction { private final QualityGates qualityGates; @@ -69,20 +70,13 @@ public class AppAction implements QGateWsAction { private void addPeriods(JsonWriter writer) { writer.name("periods").beginArray(); - for (int i = 0; i < 3; i++) { - writer.beginObject().prop("key", (long) i + 1).prop("text", periods.label(i + 1)).endObject(); - } - addProjectPeriod(4, writer); - addProjectPeriod(5, writer); + writer.beginObject() + .prop("key", 1L) + .prop("text", format("over Leak Period (%s)", periods.label(1))) + .endObject(); writer.endArray(); } - private void addProjectPeriod(int periodIndex, JsonWriter writer) { - writer.beginObject().prop("key", periodIndex).prop("text", - i18n.message(Locale.getDefault(), "quality_gates.project_period", "Period " + periodIndex, periodIndex) - ).endObject(); - } - private void addMetrics(JsonWriter writer) { writer.name("metrics").beginArray(); for (Metric metric : qualityGates.gateMetrics()) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/AppActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/AppActionTest.java index 3c5dc2c0d9b..584f5efe471 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/AppActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/AppActionTest.java @@ -94,7 +94,7 @@ public class AppActionTest { Map responseJson = (Map) JSONValue.parse(json); assertThat((Boolean) responseJson.get("edit")).isFalse(); Collection periods = (Collection) responseJson.get("periods"); - assertThat(periods).hasSize(5); + assertThat(periods).hasSize(1); Collection metrics = (Collection) responseJson.get("metrics"); assertThat(metrics).hasSize(1); Map metricMap = metrics.iterator().next(); -- 2.39.5