*/
package org.sonar.server.project.ws;
+import java.util.stream.IntStream;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, jdk7);
db.users().insertProjectPermissionOnUser(anotherUser, UserRole.ADMIN, cLang);
- SearchMyProjectsWsResponse result = call_ws();
+ SearchMyProjectsWsResponse result = callWs();
assertThat(result.getProjectsCount()).isEqualTo(1);
assertThat(result.getProjects(0).getId()).isEqualTo(jdk7.uuid());
}
+ @Test
+ public void return_only_first_1000_projects() {
+ OrganizationDto organization = db.organizations().insert();
+ IntStream.range(0, 1_010).forEach(i -> {
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization));
+ db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, project);
+ });
+
+ SearchMyProjectsWsResponse result = callWs();
+
+ assertThat(result.getPaging().getTotal()).isEqualTo(1_000);
+ }
+
@Test
public void sort_projects_by_name() {
OrganizationDto organizationDto = db.organizations().insert();
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, a_project);
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, c_project);
- SearchMyProjectsWsResponse result = call_ws();
+ SearchMyProjectsWsResponse result = callWs();
assertThat(result.getProjectsCount()).isEqualTo(3);
assertThat(result.getProjectsList()).extracting(Project::getId)
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, jdk7);
db.users().insertProjectPermissionOnUser(user, UserRole.ISSUE_ADMIN, clang);
- SearchMyProjectsWsResponse result = call_ws();
+ SearchMyProjectsWsResponse result = callWs();
assertThat(result.getProjectsCount()).isEqualTo(1);
assertThat(result.getProjects(0).getId()).isEqualTo(jdk7.uuid());
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, jdk7);
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, view);
- SearchMyProjectsWsResponse result = call_ws();
+ SearchMyProjectsWsResponse result = callWs();
assertThat(result.getProjectsCount()).isEqualTo(1);
assertThat(result.getProjects(0).getId()).isEqualTo(jdk7.uuid());
ComponentDto branch = db.components().insertProjectBranch(project);
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, project);
- SearchMyProjectsWsResponse result = call_ws();
+ SearchMyProjectsWsResponse result = callWs();
assertThat(result.getProjectsList())
.extracting(Project::getKey)
db.users().insertProjectPermissionOnGroup(group, UserRole.ADMIN, jdk7);
db.users().insertProjectPermissionOnGroup(group, UserRole.USER, cLang);
- SearchMyProjectsWsResponse result = call_ws();
+ SearchMyProjectsWsResponse result = callWs();
assertThat(result.getProjectsCount()).isEqualTo(1);
assertThat(result.getProjects(0).getId()).isEqualTo(jdk7.uuid());
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, sonarqube);
db.users().insertProjectPermissionOnGroup(group, UserRole.ADMIN, sonarqube);
- SearchMyProjectsWsResponse result = call_ws();
+ SearchMyProjectsWsResponse result = callWs();
assertThat(result.getProjectsCount()).isEqualTo(3);
assertThat(result.getProjectsList()).extracting(Project::getId).containsOnly(jdk7.uuid(), cLang.uuid(), sonarqube.uuid());
userSession.anonymous();
expectedException.expect(UnauthorizedException.class);
- call_ws();
+ callWs();
}
private ComponentDto insertClang(OrganizationDto organizationDto) {
.setDbKey("Java"));
}
- private SearchMyProjectsWsResponse call_ws() {
+ private SearchMyProjectsWsResponse callWs() {
return ws.newRequest()
.executeProtobuf(SearchMyProjectsWsResponse.class);
}