import org.sonarqube.ws.Qualitygates;
import org.sonarqube.ws.Qualitygates.GetByProjectResponse;
-import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.tuple;
.executeProtobuf(GetByProjectResponse.class);
Qualitygates.QualityGate qualityGate = result.getQualityGate();
- assertThat(qualityGate.getId()).isEqualTo(dbQualityGate.getUuid());
assertThat(qualityGate.getName()).isEqualTo(dbQualityGate.getName());
assertThat(qualityGate.getDefault()).isTrue();
}
.executeProtobuf(ListWsResponse.class);
assertThat(response.getQualitygatesList())
- .extracting(QualityGate::getId, QualityGate::getName, QualityGate::getIsDefault)
+ .extracting(QualityGate::getName, QualityGate::getIsDefault)
.containsExactlyInAnyOrder(
- tuple(defaultQualityGate.getUuid(), defaultQualityGate.getName(), true),
- tuple(otherQualityGate.getUuid(), otherQualityGate.getName(), false));
+ tuple(defaultQualityGate.getName(), true),
+ tuple(otherQualityGate.getName(), false));
}
@Test
.executeProtobuf(ListWsResponse.class);
assertThat(response.getQualitygatesList())
- .extracting(QualityGate::getId, QualityGate::getIsBuiltIn)
+ .extracting(QualityGate::getName, QualityGate::getIsBuiltIn)
.containsExactlyInAnyOrder(
- tuple(qualityGate1.getUuid(), true),
- tuple(qualityGate2.getUuid(), false));
+ tuple(qualityGate1.getName(), true),
+ tuple(qualityGate2.getName(), false));
}
@Test
.executeProtobuf(ListWsResponse.class);
assertThat(response.getQualitygatesList())
- .extracting(QualityGate::getId, QualityGate::getCaycStatus)
+ .extracting(QualityGate::getName, QualityGate::getCaycStatus)
.containsExactlyInAnyOrder(
- tuple(qualityGate1.getUuid(), COMPLIANT.toString()),
- tuple(qualityGate2.getUuid(), NON_COMPLIANT.toString()),
- tuple(qualityGate3.getUuid(), OVER_COMPLIANT.toString()));
+ tuple(qualityGate1.getName(), COMPLIANT.toString()),
+ tuple(qualityGate2.getName(), NON_COMPLIANT.toString()),
+ tuple(qualityGate3.getName(), OVER_COMPLIANT.toString()));
}
@Test
.setParam("name", qualityGate.getName())
.executeProtobuf(ShowWsResponse.class);
- assertThat(response.getId()).isEqualTo(qualityGate.getUuid());
assertThat(response.getName()).isEqualTo(qualityGate.getName());
assertThat(response.getIsBuiltIn()).isFalse();
assertThat(response.getConditionsList()).hasSize(2);
}
@Test
- public void show_by_id() {
+ public void show_by_name() {
QualityGateDto qualityGate = db.qualityGates().insertQualityGate();
db.qualityGates().setDefaultQualityGate(qualityGate);
.setParam("name", qualityGate.getName())
.executeProtobuf(ShowWsResponse.class);
- assertThat(response.getId()).isEqualTo(qualityGate.getUuid());
assertThat(response.getName()).isEqualTo(qualityGate.getName());
}
.setParam("name", qualityGate.getName())
.executeProtobuf(ShowWsResponse.class);
- assertThat(response.getId()).isEqualTo(qualityGate.getUuid());
assertThat(response.getName()).isEqualTo(qualityGate.getName());
assertThat(response.getConditionsList()).isEmpty();
}
assertThat(action.responseExampleAsString()).isNotEmpty();
assertThat(action.params()).hasSize(5);
assertThat(action.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
+ tuple("10.0", "Field 'id' in the response has been removed"),
tuple("10.0", "New parameter 'managed' to optionally search by managed status"),
tuple("10.0", "Response includes 'managed' field."),
tuple("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
loginAsAdmin();
assertThat(call(ws.newRequest()).getGroupsList())
- .extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
- .containsOnly(tuple(true, true, true, true, true));
+ .extracting(Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
+ .containsOnly(tuple(true, true, true, true));
assertThat(call(ws.newRequest().setParam(FIELDS, "")).getGroupsList())
- .extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
- .containsOnly(tuple(true, true, true, true, true));
+ .extracting(Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
+ .containsOnly(tuple(true, true, true, true));
assertThat(call(ws.newRequest().setParam(FIELDS, "name")).getGroupsList())
- .extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
- .containsOnly(tuple(true, true, false, false, false));
+ .extracting(Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
+ .containsOnly(tuple(true, false, false, false));
assertThat(call(ws.newRequest().setParam(FIELDS, "description")).getGroupsList())
- .extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
- .containsOnly(tuple(true, false, true, false, false));
+ .extracting(Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
+ .containsOnly(tuple(false, true, false, false));
assertThat(call(ws.newRequest().setParam(FIELDS, "membersCount")).getGroupsList())
- .extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
- .containsOnly(tuple(true, false, false, true, false));
+ .extracting(Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
+ .containsOnly(tuple(false, false, true, false));
assertThat(call(ws.newRequest().setParam(FIELDS, "managed")).getGroupsList())
- .extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
- .containsOnly(tuple(true, false, false, false, true));
+ .extracting(Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
+ .containsOnly(tuple(false, false, false, true));
}
@Test
.setResponseExample(getClass().getResource("get_by_project-example.json"))
.setHandler(this)
.setChangelog(
+ new Change("10.0", "Field 'id' in the response has been removed"),
new Change("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
new Change("6.6", "The parameter 'projectId' has been removed"),
new Change("6.6", "The parameter 'projectKey' has been renamed to 'project'"),
GetByProjectResponse.Builder response = GetByProjectResponse.newBuilder();
response.getQualityGateBuilder()
- .setId(qg.getUuid())
.setName(qg.getName())
.setDefault(qg.isDefault());
.setSince("4.3")
.setResponseExample(Resources.getResource(this.getClass(), "list-example.json"))
.setChangelog(
+ new Change("10.0", "Field 'id' in the response has been removed"),
new Change("9.9", "'caycStatus' field is added on quality gate"),
new Change("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
new Change("7.0", "'isDefault' field is added on quality gate"),
.setActions(ListWsResponse.RootActions.newBuilder().setCreate(wsSupport.isQualityGateAdmin()))
.addAllQualitygates(qualityGates.stream()
.map(qualityGate -> QualityGate.newBuilder()
- .setId(qualityGate.getUuid())
.setName(qualityGate.getName())
.setIsDefault(qualityGate.getUuid().equals(defaultUuid))
.setIsBuiltIn(qualityGate.isBuiltIn())
.setSince("4.3")
.setResponseExample(Resources.getResource(this.getClass(), "show-example.json"))
.setChangelog(
+ 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"),
new Change("8.4", "Parameter 'id' is deprecated. Format changes from integer to string. Use 'name' instead."),
private ShowWsResponse buildResponse(DbSession dbSession, QualityGateDto qualityGate, QualityGateDto defaultQualityGate, Collection<QualityGateConditionDto> conditions,
Map<String, MetricDto> metricsByUuid, QualityGateCaycStatus caycStatus) {
return ShowWsResponse.newBuilder()
- .setId(qualityGate.getUuid())
.setName(qualityGate.getName())
.setIsBuiltIn(qualityGate.isBuiltIn())
.setCaycStatus(caycStatus.toString())
.addPagingParams(100, MAX_PAGE_SIZE)
.addSearchQuery("sonar-users", "names")
.setChangelog(
+ new Change("10.0", "Field 'id' in the response has been removed"),
new Change("10.0", "New parameter 'managed' to optionally search by managed status"),
new Change("10.0", "Response includes 'managed' field."),
new Change("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
private static Group toWsGroup(GroupDto group, Integer memberCount, Boolean isManaged, Set<String> fields, boolean isDefault) {
Group.Builder groupBuilder = Group.newBuilder()
- .setId(group.getUuid())
.setDefault(isDefault);
if (fields.contains(FIELD_NAME)) {
groupBuilder.setName(group.getName());
},
"groups": [
{
- "id": "AU-Tpxb--iU5OvuD2FLy",
"name": "sonar-users",
"description": "Users",
"membersCount": 17,
"managed": false
},
{
- "id": "AU-Tpxb--iU5OvuD2FLz",
"name": "administrators",
"description": "Administrators",
"membersCount": 2,