@@ -96,6 +96,7 @@ public class ProjectStatusAction implements QualityGatesWsAction { | |||
.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"), |
@@ -31,7 +31,6 @@ import org.sonar.db.component.SnapshotDto; | |||
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; | |||
@@ -81,7 +80,6 @@ public class QualityGateDetailsFormatter { | |||
return; | |||
} | |||
Period.Builder periodsBuilder = Period.newBuilder(); | |||
NewCodePeriod.Builder periodBuilder = NewCodePeriod.newBuilder(); | |||
SnapshotDto snapshot = this.optionalSnapshot.get(); | |||
@@ -89,21 +87,19 @@ public class QualityGateDetailsFormatter { | |||
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); | |||
} | |||
@@ -58,14 +58,6 @@ | |||
"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", |
@@ -39,7 +39,7 @@ public class QualityGateDetailsFormatterTest { | |||
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") | |||
@@ -68,13 +68,11 @@ public class QualityGateDetailsFormatterTest { | |||
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 |
@@ -33,7 +33,7 @@ message ProjectStatusResponse { | |||
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; | |||
@@ -55,13 +55,6 @@ message ProjectStatusResponse { | |||
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; |