}
public ProjectList searchProjects(String gitlabUrl, String personalAccessToken, @Nullable String projectName,
- int pageNumber, int pageSize) {
- String url = String.format("%s/projects?archived=false&simple=true&membership=true&order_by=name&sort=asc&search=%s&page=%d&per_page=%d",
- gitlabUrl, projectName == null ? "" : urlEncode(projectName), pageNumber, pageSize);
+ @Nullable Integer pageNumber, @Nullable Integer pageSize) {
+ String url = String.format("%s/projects?archived=false&simple=true&membership=true&order_by=name&sort=asc&search=%s%s%s",
+ gitlabUrl,
+ projectName == null ? "" : urlEncode(projectName),
+ pageNumber == null ? "" : String.format("&page=%d", pageNumber),
+ pageSize == null ? "" : String.format("&per_page=%d", pageSize)
+ );
LOG.debug(String.format("get projects : [%s]", url));
Request request = new Request.Builder()
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.tuple;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
.execute();
assertThat(almSetting.getUrl()).isNotNull();
- verify(gitlabPrHttpClient).searchProjects(almSetting.getUrl(), PAT_SECRET, null, 1, 10);
+ verify(gitlabPrHttpClient).searchProjects(almSetting.getUrl(), PAT_SECRET, null, null, null);
}
@Test
@Test
public void fail_when_personal_access_token_is_invalid_for_gitlab() {
- when(gitlabPrHttpClient.searchProjects(any(), any(), any(), anyInt(), anyInt()))
+ when(gitlabPrHttpClient.searchProjects(any(), any(), any(), any(), any()))
.thenThrow(new IllegalArgumentException("Invalid personal access token"));
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(PROVISION_PROJECTS);