use of org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse in project sonarqube by SonarSource.
the class SearchMyProjectsActionTest method paginate_projects.
@Test
public void paginate_projects() {
OrganizationDto organizationDto = db.organizations().insert();
for (int i = 0; i < 10; i++) {
ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto).setName("project-" + i));
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, project);
}
SearchMyProjectsWsResponse result = call_ws(ws.newRequest().setParam(Param.PAGE, "2").setParam(Param.PAGE_SIZE, "3"));
assertThat(result.getProjectsCount()).isEqualTo(3);
assertThat(result.getProjectsList()).extracting(Project::getName).containsExactly("project-3", "project-4", "project-5");
}
use of org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse in project sonarqube by SonarSource.
the class SearchMyProjectsActionTest method admin_via_groups_and_users.
@Test
public void admin_via_groups_and_users() {
OrganizationDto org = db.organizations().insert();
ComponentDto jdk7 = insertJdk7(org);
ComponentDto cLang = insertClang(org);
ComponentDto sonarqube = db.components().insertProject(org);
GroupDto group = db.users().insertGroup(org);
db.users().insertMember(group, user);
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, jdk7);
db.users().insertProjectPermissionOnGroup(group, UserRole.ADMIN, cLang);
// admin via group and user
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, sonarqube);
db.users().insertProjectPermissionOnGroup(group, UserRole.ADMIN, sonarqube);
SearchMyProjectsWsResponse result = call_ws();
assertThat(result.getProjectsCount()).isEqualTo(3);
assertThat(result.getProjectsList()).extracting(Project::getId).containsOnly(jdk7.uuid(), cLang.uuid(), sonarqube.uuid());
}
use of org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse in project sonarqube by SonarSource.
the class SearchMyProjectsActionTest method sort_projects_by_name.
@Test
public void sort_projects_by_name() {
OrganizationDto organizationDto = db.organizations().insert();
ComponentDto b_project = db.components().insertComponent(newProjectDto(organizationDto).setName("B_project_name"));
ComponentDto c_project = db.components().insertComponent(newProjectDto(organizationDto).setName("c_project_name"));
ComponentDto a_project = db.components().insertComponent(newProjectDto(organizationDto).setName("A_project_name"));
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, b_project);
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, a_project);
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, c_project);
SearchMyProjectsWsResponse result = call_ws();
assertThat(result.getProjectsCount()).isEqualTo(3);
assertThat(result.getProjectsList()).extracting(Project::getId).containsExactly(a_project.uuid(), b_project.uuid(), c_project.uuid());
}
Aggregations