Kaynağa Gözat

SONAR-20607 New isDefault flag on api/qualitygates/show endpoint

tags/10.3.0.82913
Zipeng WU 7 ay önce
ebeveyn
işleme
f450cceab1

+ 22
- 0
server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/ShowActionIT.java Dosyayı Görüntüle

@@ -44,6 +44,8 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.AssertionsForClassTypes.tuple;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
@@ -257,6 +259,26 @@ public class ShowActionIT {

}

@Test
public void reponse_should_show_isDefault() {
QualityGateDto defaultQualityGate = db.qualityGates().insertQualityGate();
db.qualityGates().setDefaultQualityGate(defaultQualityGate);

ShowWsResponse response = ws.newRequest()
.setParam("name", defaultQualityGate.getName())
.executeProtobuf(ShowWsResponse.class);

assertTrue(response.getIsDefault());

QualityGateDto nonDefaultQualityGate = db.qualityGates().insertQualityGate();

response = ws.newRequest()
.setParam("name", nonDefaultQualityGate.getName())
.executeProtobuf(ShowWsResponse.class);

assertFalse(response.getIsDefault());
}

@Test
public void fail_when_no_name() {
QualityGateDto qualityGate = db.qualityGates().insertQualityGate();

+ 2
- 0
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java Dosyayı Görüntüle

@@ -66,6 +66,7 @@ public class ShowAction implements QualityGatesWsAction {
.setSince("4.3")
.setResponseExample(Resources.getResource(this.getClass(), "show-example.json"))
.setChangelog(
new Change("10.3", "'isDefault' field is added to the response"),
new Change("10.0", "Field 'id' in the response has been removed"),
new Change("10.0", "Parameter 'id' is removed. Use 'name' instead."),
new Change("9.9", "'caycStatus' field is added to the response"),
@@ -110,6 +111,7 @@ public class ShowAction implements QualityGatesWsAction {
return ShowWsResponse.newBuilder()
.setName(qualityGate.getName())
.setIsBuiltIn(qualityGate.isBuiltIn())
.setIsDefault(qualityGate.getUuid().equals(defaultQualityGate.getUuid()))
.setCaycStatus(caycStatus.toString())
.addAllConditions(conditions.stream()
.map(toWsCondition(metricsByUuid))

+ 1
- 0
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualitygate/ws/show-example.json Dosyayı Görüntüle

@@ -15,6 +15,7 @@
}
],
"isBuiltIn": false,
"isDefault": false,
"actions": {
"rename": true,
"setAsDefault": true,

+ 4
- 3
sonar-ws/src/main/protobuf/ws-qualitygates.proto Dosyayı Görüntüle

@@ -120,11 +120,12 @@ message UpdateConditionResponse {
// GET api/qualitygates/show
message ShowWsResponse {
optional string id = 1;
optional string name = 2;
required string name = 2;
repeated Condition conditions = 3;
optional bool isBuiltIn = 4;
required bool isBuiltIn = 4;
optional Actions actions = 5;
optional string caycStatus = 6;
required string caycStatus = 6;
required bool isDefault = 7;

message Condition {
required string id = 1;

Loading…
İptal
Kaydet