Search in sources :

Example 6 with SearchMyProjectsWsResponse

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");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) SearchMyProjectsWsResponse(org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 7 with SearchMyProjectsWsResponse

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());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) GroupDto(org.sonar.db.user.GroupDto) SearchMyProjectsWsResponse(org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 8 with SearchMyProjectsWsResponse

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());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) SearchMyProjectsWsResponse(org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Aggregations

SearchMyProjectsWsResponse (org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse)8 Test (org.junit.Test)7 ComponentDto (org.sonar.db.component.ComponentDto)7 OrganizationDto (org.sonar.db.organization.OrganizationDto)7 GroupDto (org.sonar.db.user.GroupDto)2 UserDto (org.sonar.db.user.UserDto)1 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)1