use of org.sonarqube.ws.Qualitygates.SearchResponse in project sonarqube by SonarSource.
the class SearchActionTest method return_only_unassociated_project.
@Test
public void return_only_unassociated_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, DESELECTED.value()).executeProtobuf(SearchResponse.class);
assertThat(response.getResultsList()).extracting(Result::getName, Result::getSelected).containsExactlyInAnyOrder(tuple(unassociatedProject.getName(), false)).doesNotContain(tuple(associatedProject.getName(), true));
}
use of org.sonarqube.ws.Qualitygates.SearchResponse in project sonarqube by SonarSource.
the class SearchActionTest method return_only_authorized_projects.
@Test
public void return_only_authorized_projects() {
QualityGateDto qualityGate = db.qualityGates().insertQualityGate();
ComponentDto project1 = db.components().insertPrivateProject();
ComponentDto project2 = db.components().insertPrivateProject();
UserDto user = db.users().insertUser();
// User can only see project1 1
db.users().insertProjectPermissionOnUser(user, USER, project1);
userSession.logIn(user);
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).containsExactlyInAnyOrder(project1.name()).doesNotContain(project2.name());
}
use of org.sonarqube.ws.Qualitygates.SearchResponse in project sonarqube by SonarSource.
the class SearchActionTest method root_user.
@Test
public void root_user() {
QualityGateDto qualityGate = db.qualityGates().insertQualityGate();
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().setRoot();
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).containsExactlyInAnyOrder(project.name());
}
use of org.sonarqube.ws.Qualitygates.SearchResponse in project sonarqube by SonarSource.
the class SearchActionTest method test_pagination_on_many_pages.
@Test
public void test_pagination_on_many_pages() {
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(5)).setParam(PARAM_PAGE, valueOf(2)).executeProtobuf(SearchResponse.class);
assertThat(response).extracting(SearchResponse::getMore, searchResponse -> searchResponse.getPaging().getPageIndex(), searchResponse -> searchResponse.getPaging().getPageSize(), searchResponse -> searchResponse.getPaging().getTotal()).contains(true, 2, 5, 20);
}
use of org.sonarqube.ws.Qualitygates.SearchResponse in project sonarqube by SonarSource.
the class SearchActionTest method return_empty_association.
@Test
public void return_empty_association() {
QualityGateDto qualityGate = db.qualityGates().insertQualityGate();
SearchResponse response = ws.newRequest().setParam(PARAM_GATE_ID, valueOf(qualityGate.getUuid())).executeProtobuf(SearchResponse.class);
assertThat(response.getResultsList()).isEmpty();
}
Aggregations