.setSince("5.3")
.setHandler(this)
.setChangelog(
+ new Change("10.0", "The field 'periods' in the response is removed"),
new Change("9.9", "'caycStatus' field is added to the response"),
new Change("9.5", "The 'Execute Analysis' permission also allows to access the endpoint"),
new Change("8.5", "The field 'periods' in the response is deprecated. Use 'period' instead"),
import org.sonar.server.qualitygate.QualityGateCaycStatus;
import org.sonarqube.ws.Qualitygates.ProjectStatusResponse;
import org.sonarqube.ws.Qualitygates.ProjectStatusResponse.NewCodePeriod;
-import org.sonarqube.ws.Qualitygates.ProjectStatusResponse.Period;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.sonar.api.utils.DateUtils.formatDateTime;
return;
}
- Period.Builder periodsBuilder = Period.newBuilder();
NewCodePeriod.Builder periodBuilder = NewCodePeriod.newBuilder();
SnapshotDto snapshot = this.optionalSnapshot.get();
if (isNullOrEmpty(snapshot.getPeriodMode())) {
return;
}
- periodsBuilder.setIndex(1);
- periodsBuilder.setMode(snapshot.getPeriodMode());
+
periodBuilder.setMode(snapshot.getPeriodMode());
Long periodDate = snapshot.getPeriodDate();
if (periodDate != null) {
String formattedDateTime = formatDateTime(periodDate);
- periodsBuilder.setDate(formattedDateTime);
periodBuilder.setDate(formattedDateTime);
}
String periodModeParameter = snapshot.getPeriodModeParameter();
if (!isNullOrEmpty(periodModeParameter)) {
- periodsBuilder.setParameter(periodModeParameter);
+
periodBuilder.setParameter(periodModeParameter);
}
- projectStatusBuilder.addPeriods(periodsBuilder);
+
projectStatusBuilder.setPeriod(periodBuilder);
}
"actualValue": "0"
}
],
- "periods": [
- {
- "index": 1,
- "mode": "last_version",
- "date": "2000-04-27T00:45:23+0200",
- "parameter": "2015-12-07"
- }
- ],
"period": {
"mode": "last_version",
"date": "2000-04-27T00:45:23+0200",
private QualityGateDetailsFormatter underTest;
@Test
- public void map_level_conditions_and_periods() throws IOException {
+ public void map_level_conditions_and_period() throws IOException {
String measureData = IOUtils.toString(getClass().getResource("QualityGateDetailsFormatterTest/quality_gate_details.json"));
SnapshotDto snapshot = new SnapshotDto()
.setPeriodMode("last_version")
assertThat(conditions).extracting("errorThreshold").containsOnly("85", "0", "0");
assertThat(conditions).extracting("actualValue").containsExactly("82.2985024398452", "1", "0");
- // check periods
- assertThat(result.getPeriodsCount()).isOne();
- List<ProjectStatusResponse.Period> periods = result.getPeriodsList();
- assertThat(periods).extracting("index").containsExactly(1);
- assertThat(periods).extracting("mode").containsExactly("last_version");
- assertThat(periods).extracting("parameter").containsExactly("2015-12-07");
- assertThat(periods.get(0).getDate()).isEqualTo(formatDateTime(snapshot.getPeriodDate()));
+ // check period
+ ProjectStatusResponse.NewCodePeriod period = result.getPeriod();
+ assertThat(period).extracting("mode").isEqualTo("last_version");
+ assertThat(period).extracting("parameter").isEqualTo("2015-12-07");
+ assertThat(period.getDate()).isEqualTo(formatDateTime(snapshot.getPeriodDate()));
}
@Test
message ProjectStatus {
optional Status status = 1;
repeated Condition conditions = 2;
- repeated Period periods = 3;
+ reserved 3; //drop periods
optional bool ignoredConditions = 4;
optional NewCodePeriod period = 5;
optional string caycStatus = 6;
optional string parameter = 3;
}
- message Period {
- optional int32 index = 1;
- optional string mode = 2;
- optional string date = 3;
- optional string parameter = 4;
- }
-
enum Status {
OK = 1;
WARN = 2;