aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-01-26 11:06:07 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-01-29 15:59:35 +0100
commitd1273619390e7dd4e75448cc0110fa63fb2dab43 (patch)
tree7abd8069f577c2ffd2d6ac07b4e3a887b928e3ef
parent1c73879c6bd7bb325e7e95acfadbb8431adc39f3 (diff)
downloadsonarqube-d1273619390e7dd4e75448cc0110fa63fb2dab43.tar.gz
sonarqube-d1273619390e7dd4e75448cc0110fa63fb2dab43.zip
SONAR-7070 WS qualitygates/app returns solely the leak period
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/AppAction.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/AppActionTest.java2
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<Map> periods = (Collection<Map>) responseJson.get("periods");
- assertThat(periods).hasSize(5);
+ assertThat(periods).hasSize(1);
Collection<Map> metrics = (Collection<Map>) responseJson.get("metrics");
assertThat(metrics).hasSize(1);
Map metricMap = metrics.iterator().next();