summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateVerifierTest.java7
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties1
-rw-r--r--sonar-server/src/main/coffee/quality-gate/views/quality-gate-detail-condition-view.coffee2
-rw-r--r--sonar-server/src/main/hbs/quality-gates/quality-gate-detail-condition.hbs4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QgateAppHandler.java9
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java2
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QgateAppHandlerTest.java4
9 files changed, 27 insertions, 10 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java
index f2e5b36bbe2..7515efc5b5a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java
@@ -188,6 +188,10 @@ class ConditionUtils {
return measure.getVariation2();
} else if (period == 3) {
return measure.getVariation3();
+ } else if (period == 4) {
+ return measure.getVariation4();
+ } else if (period == 5) {
+ return measure.getVariation5();
} else {
throw new IllegalStateException("Following index period is not allowed : " + Double.toString(period));
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateVerifierTest.java b/sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateVerifierTest.java
index 21a0550c6ff..1a4be071193 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateVerifierTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateVerifierTest.java
@@ -302,8 +302,8 @@ public class QualityGateVerifierTest {
verify(context).saveMeasure(argThat(hasLevel(measureRatingMetric, Metric.Level.OK)));
}
- @Test(expected = IllegalStateException.class)
- public void shouldAllowOnlyVariationPeriodOneGlobalPeriods() {
+ @Test
+ public void shouldAllowVariationPeriodOnAllPeriods() {
measureClasses.setVariation4(40d);
ArrayList<ResolvedCondition> conditions = Lists.newArrayList(
@@ -312,6 +312,9 @@ public class QualityGateVerifierTest {
when(qualityGate.conditions()).thenReturn(conditions);
verifier.decorate(project, context);
+
+ verify(context).saveMeasure(argThat(matchesMetric(CoreMetrics.ALERT_STATUS, Metric.Level.WARN, null)));
+ verify(context).saveMeasure(argThat(hasLevel(measureClasses, Metric.Level.WARN)));
}
@Test(expected = NotImplementedException.class)
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index fc43b1470e4..e9f2973f509 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -1662,6 +1662,7 @@ quality_gates.delete.confirm.message=Are you sure you want to delete the "{0}" q
quality_gates.delete.confirm.default=Are you sure you want to delete the "{0}" quality gate, which is the default quality gate?
quality_gates.delete_condition=Delete Condition
quality_gates.delete_condition.confirm.message=Are you sure you want to delete the "{0}" condition?
+quality_gates.project_period=over period {0} - defined at project level
#------------------------------------------------------------------------------
diff --git a/sonar-server/src/main/coffee/quality-gate/views/quality-gate-detail-condition-view.coffee b/sonar-server/src/main/coffee/quality-gate/views/quality-gate-detail-condition-view.coffee
index e73343ac80b..bf5af58c8e9 100644
--- a/sonar-server/src/main/coffee/quality-gate/views/quality-gate-detail-condition-view.coffee
+++ b/sonar-server/src/main/coffee/quality-gate/views/quality-gate-detail-condition-view.coffee
@@ -59,7 +59,7 @@ define [
@ui.periodSelect.select2
allowClear: false
minimumResultsForSearch: 999
- width: '200px'
+ width: '100%'
@ui.operatorSelect.select2
allowClear: false
diff --git a/sonar-server/src/main/hbs/quality-gates/quality-gate-detail-condition.hbs b/sonar-server/src/main/hbs/quality-gates/quality-gate-detail-condition.hbs
index 6ec2c6200f1..7acd9800f2a 100644
--- a/sonar-server/src/main/hbs/quality-gates/quality-gate-detail-condition.hbs
+++ b/sonar-server/src/main/hbs/quality-gates/quality-gate-detail-condition.hbs
@@ -4,9 +4,9 @@
<span class="deprecated">{{t 'deprecated'}}</span>
{{/if}}
</td>
-<td width="10%" nowrap>
+<td width="20%" nowrap>
{{#if canEdit}}
- <select name="period">
+ <select name="period" style="width: 100%">
{{#unless isDiffMetric}}<option value="0">{{t 'value'}}</option>{{/unless}}
{{#each periods}}<option value="{{key}}">&Delta; {{text}}</option>{{/each}}
</select>
diff --git a/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java b/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java
index c0682042c09..4d5b8b2a649 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java
@@ -261,8 +261,8 @@ public class QualityGates {
if (metric.getKey().startsWith("new_")) {
validationMessages.add(Message.of("A period must be selected for differential metrics."));
}
- } else if (period < 1 || period > 3) {
- validationMessages.add(Message.of("Valid periods are 1, 2 and 3."));
+ } else if (period < 1 || period > 5) {
+ validationMessages.add(Message.of("Valid periods are integers between 1 and 5 (included)."));
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QgateAppHandler.java b/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QgateAppHandler.java
index bef48100273..a6734e39b67 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QgateAppHandler.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QgateAppHandler.java
@@ -78,6 +78,7 @@ public class QgateAppHandler implements RequestHandler {
"quality_gates.delete.confirm.message",
"quality_gates.delete.confirm.default",
"quality_gates.delete_condition.confirm.message",
+ "quality_gates.project_period",
"rename",
"save",
"set_as_default",
@@ -120,9 +121,17 @@ public class QgateAppHandler implements RequestHandler {
for (int i=0; i < 3; i ++) {
writer.beginObject().prop("key", i + 1).prop("text", periods.label(i + 1)).endObject();
}
+ addProjectPeriod(4, writer);
+ addProjectPeriod(5, writer);
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 addMessages(JsonWriter writer) {
writer.name("messages").beginObject();
for (String message: MESSAGE_KEYS) {
diff --git a/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java b/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java
index 435ed2c0a26..4688136979c 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java
@@ -420,7 +420,7 @@ public class QualityGatesTest {
when(metric.getType()).thenReturn(ValueType.BOOL);
when(metricFinder.findByKey(anyString())).thenReturn(metric);
when(dao.selectById(qGateId)).thenReturn(new QualityGateDto().setId(qGateId));
- qGates.createCondition(qGateId, "alert_status", "EQ", null, "90", 4);
+ qGates.createCondition(qGateId, "alert_status", "EQ", null, "90", 6);
}
@Test
diff --git a/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QgateAppHandlerTest.java b/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QgateAppHandlerTest.java
index bc0334256ed..1e6baad3415 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QgateAppHandlerTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QgateAppHandlerTest.java
@@ -87,9 +87,9 @@ public class QgateAppHandlerTest {
Map responseJson = (Map) JSONValue.parse(json);
assertThat((Boolean) responseJson.get("edit")).isFalse();
Collection<Map> periods = (Collection<Map>) responseJson.get("periods");
- assertThat(periods).hasSize(3);
+ assertThat(periods).hasSize(5);
Map messages = (Map) responseJson.get("messages");
- assertThat(messages).isNotNull().isNotEmpty().hasSize(53);
+ assertThat(messages).isNotNull().isNotEmpty().hasSize(54);
for (Entry message: (Set<Entry>) messages.entrySet()) {
assertThat(message.getKey()).isEqualTo(message.getValue());
}