use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class GetByProjectAction method buildResponse.
private static GetByProjectWsResponse buildResponse(Optional<QualityGateData> data) {
if (!data.isPresent()) {
return GetByProjectWsResponse.getDefaultInstance();
}
QualityGateDto qualityGate = data.get().getQualityGate();
GetByProjectWsResponse.Builder response = GetByProjectWsResponse.newBuilder();
response.getQualityGateBuilder().setId(String.valueOf(qualityGate.getId())).setName(qualityGate.getName()).setDefault(data.get().isDefault());
return response.build();
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGatesWsTest method list_with_default.
@Test
public void list_with_default() throws Exception {
QualityGateDto defaultQgate = new QualityGateDto().setId(42L).setName("Golden");
when(qGates.list()).thenReturn(Lists.newArrayList(defaultQgate, new QualityGateDto().setId(43L).setName("Star"), new QualityGateDto().setId(666L).setName("Ninth")));
when(qGates.getDefault()).thenReturn(defaultQgate);
tester.newGetRequest("api/qualitygates", "list").execute().assertJson("{\"qualitygates\":[{\"id\":42,\"name\":\"Golden\"},{\"id\":43,\"name\":\"Star\"},{\"id\":666,\"name\":\"Ninth\"}],\"default\":42}");
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGatesWsTest method rename_nominal.
@Test
public void rename_nominal() throws Exception {
Long id = 42L;
String name = "New QG";
when(qGates.rename(id, name)).thenReturn(new QualityGateDto().setId(id).setName(name));
tester.newPostRequest("api/qualitygates", "rename").setParam("id", id.toString()).setParam("name", name).execute().assertJson("{\"id\":42,\"name\":\"New QG\"}");
;
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGatesWsTest method show_empty.
@Test
public void show_empty() throws Exception {
long gateId = 12345L;
when(qGates.get(gateId)).thenReturn(new QualityGateDto().setId(gateId).setName("Golden"));
tester.newGetRequest("api/qualitygates", "show").setParam("id", Long.toString(gateId)).execute().assertJson("{\"id\":12345,\"name\":\"Golden\"}");
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGatesWsTest method copy_nominal.
@Test
public void copy_nominal() throws Exception {
String name = "Copied QG";
when(qGates.copy(24L, name)).thenReturn(new QualityGateDto().setId(42L).setName(name));
tester.newPostRequest("api/qualitygates", "copy").setParam("id", "24").setParam("name", name).execute().assertJson("{\"id\":42,\"name\":\"Copied QG\"}");
}
Aggregations