*/
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;
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;
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()) {
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();