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));
}
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(
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)
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
#------------------------------------------------------------------------------
@ui.periodSelect.select2
allowClear: false
minimumResultsForSearch: 999
- width: '200px'
+ width: '100%'
@ui.operatorSelect.select2
allowClear: false
<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}}">Δ {{text}}</option>{{/each}}
</select>
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)."));
}
}
"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",
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) {
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
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());
}