use of org.sonarqube.ws.Qualitygates.SearchResponse in project sonarqube by SonarSource.
the class SearchActionTest method test_pagination_on_one_page.
@Test
public void test_pagination_on_one_page() {
QualityGateDto qualityGate = db.qualityGates().insertQualityGate();
for (int i = 0; i < 20; i++) {
ProjectDto project = db.components().insertPublicProjectDto();
db.qualityGates().associateProjectToQualityGate(project, qualityGate);
}
userSession.addPermission(ADMINISTER_QUALITY_GATES);
SearchResponse response = ws.newRequest().setParam(PARAM_GATE_ID, valueOf(qualityGate.getUuid())).setParam(PARAM_PAGE_SIZE, valueOf(100)).setParam(PARAM_PAGE, valueOf(1)).executeProtobuf(SearchResponse.class);
assertThat(response).extracting(SearchResponse::getMore, searchResponse -> searchResponse.getPaging().getPageIndex(), searchResponse -> searchResponse.getPaging().getPageSize(), searchResponse -> searchResponse.getPaging().getTotal()).contains(false, 1, 100, 20);
}
use of org.sonarqube.ws.Qualitygates.SearchResponse in project sonarqube by SonarSource.
the class SearchActionTest method return_all_projects.
@Test
public void return_all_projects() {
QualityGateDto qualityGate = db.qualityGates().insertQualityGate();
ProjectDto unassociatedProject = db.components().insertPublicProjectDto();
ProjectDto associatedProject = db.components().insertPublicProjectDto();
db.qualityGates().associateProjectToQualityGate(associatedProject, qualityGate);
SearchResponse response = ws.newRequest().setParam(PARAM_GATE_ID, valueOf(qualityGate.getUuid())).setParam(PARAM_SELECTED, ALL.value()).executeProtobuf(SearchResponse.class);
assertThat(response.getResultsList()).extracting(Result::getName, Result::getKey, Result::getSelected).containsExactlyInAnyOrder(tuple(associatedProject.getName(), associatedProject.getKey(), true), tuple(unassociatedProject.getName(), unassociatedProject.getKey(), false));
}
use of org.sonarqube.ws.Qualitygates.SearchResponse in project sonarqube by SonarSource.
the class SearchActionTest method return_only_associated_project.
@Test
public void return_only_associated_project() {
QualityGateDto qualityGate = db.qualityGates().insertQualityGate();
ProjectDto associatedProject = db.components().insertPublicProjectDto();
ProjectDto unassociatedProject = db.components().insertPublicProjectDto();
db.qualityGates().associateProjectToQualityGate(associatedProject, qualityGate);
SearchResponse response = ws.newRequest().setParam(PARAM_GATE_ID, valueOf(qualityGate.getUuid())).setParam(PARAM_SELECTED, SELECTED.value()).executeProtobuf(SearchResponse.class);
assertThat(response.getResultsList()).extracting(Result::getName, Result::getSelected).containsExactlyInAnyOrder(tuple(associatedProject.getName(), true)).doesNotContain(tuple(unassociatedProject.getName(), false));
}
use of org.sonarqube.ws.Qualitygates.SearchResponse in project sonarqube by SonarSource.
the class SearchActionTest method search_projects_of_a_quality_gate.
@Test
public void search_projects_of_a_quality_gate() {
ComponentDto project = db.components().insertPublicProject();
QualityGateDto qualityGate = db.qualityGates().insertQualityGate();
db.qualityGates().associateProjectToQualityGate(db.components().getProjectDto(project), qualityGate);
SearchResponse response = ws.newRequest().setParam(PARAM_GATE_ID, valueOf(qualityGate.getUuid())).executeProtobuf(SearchResponse.class);
assertThat(response.getResultsList()).extracting(Result::getKey, Result::getName).containsExactlyInAnyOrder(tuple(project.getKey(), project.name()));
}
Aggregations