.setSince("5.3")
.setHandler(this)
.setChangelog(
+ new Change("8.5", "The field 'periods' in the response is deprecated. Use 'period' instead"),
new Change("7.7", "The parameters 'branch' and 'pullRequest' were added"),
- new Change("7.6", "The field 'warning' is deprecated from the response"),
+ new Change("7.6", "The field 'warning' in the response is deprecated"),
new Change("6.4", "The field 'ignoredConditions' is added to the response"));
action.createParam(PARAM_ANALYSIS_ID)
import javax.annotation.Nullable;
import org.sonar.db.component.SnapshotDto;
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;
}
- ProjectStatusResponse.Period.Builder periodBuilder = ProjectStatusResponse.Period.newBuilder();
- periodBuilder.clear();
+ Period.Builder periodsBuilder = Period.newBuilder();
+ NewCodePeriod.Builder periodBuilder = NewCodePeriod.newBuilder();
SnapshotDto snapshot = this.optionalSnapshot.get();
if (isNullOrEmpty(snapshot.getPeriodMode())) {
return;
}
- periodBuilder.setIndex(1);
+ periodsBuilder.setIndex(1);
+ periodsBuilder.setMode(snapshot.getPeriodMode());
periodBuilder.setMode(snapshot.getPeriodMode());
Long periodDate = snapshot.getPeriodDate();
if (periodDate != null) {
- periodBuilder.setDate(formatDateTime(periodDate));
+ 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(periodBuilder);
+ projectStatusBuilder.addPeriods(periodsBuilder);
+ projectStatusBuilder.setPeriod(periodBuilder);
}
private void formatConditions(@Nullable JsonArray jsonConditions) {
package org.sonar.server.qualitygate.ws;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import org.apache.commons.io.IOUtils;
import org.junit.Rule;
import org.junit.Test;
.setPeriodDate(956789123987L));
dbClient.measureDao().insert(dbSession,
newMeasureDto(gateDetailsMetric, project, snapshot)
- .setData(IOUtils.toString(getClass().getResource("ProjectStatusActionTest/measure_data.json"))));
+ .setData(IOUtils.toString(getClass().getResource("ProjectStatusActionTest/measure_data.json"), StandardCharsets.UTF_8)));
dbSession.commit();
String response = ws.newRequest()
repeated Condition conditions = 2;
repeated Period periods = 3;
optional bool ignoredConditions = 4;
+ optional NewCodePeriod period = 5;
}
message Condition {
optional string actualValue = 7;
}
+ message NewCodePeriod {
+ optional string mode = 1;
+ optional string date = 2;
+ optional string parameter = 3;
+ }
+
message Period {
optional int32 index = 1;
optional string mode = 2;