Search in sources :

Example 66 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class SearchAzureReposActionTest method search_repos_with_same_name_and_different_project.

@Test
public void search_repos_with_same_name_and_different_project() {
    mockClient(new GsonAzureRepoList(ImmutableList.of(getGsonAzureRepo("project-1", "repoName-1"), getGsonAzureRepo("project-2", "repoName-1"))));
    AlmSettingDto almSetting = insertAlmSetting();
    ProjectDto projectDto1 = insertProject(almSetting, "repoName-1", "project-1");
    ProjectDto projectDto2 = insertProject(almSetting, "repoName-1", "project-2");
    SearchAzureReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).executeProtobuf(SearchAzureReposWsResponse.class);
    assertThat(response.getRepositoriesCount()).isEqualTo(2);
    assertThat(response.getRepositoriesList()).extracting(AzureRepo::getName, AzureRepo::getProjectName, AzureRepo::getSqProjectKey, AzureRepo::getSqProjectName).containsExactlyInAnyOrder(tuple("repoName-1", "project-1", projectDto1.getKey(), projectDto1.getName()), tuple("repoName-1", "project-2", projectDto2.getKey(), projectDto2.getName()));
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) SearchAzureReposWsResponse(org.sonarqube.ws.AlmIntegrations.SearchAzureReposWsResponse) GsonAzureRepoList(org.sonar.alm.client.azure.GsonAzureRepoList) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 67 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class SearchAzureReposActionTest method return_empty_list_when_there_are_no_azure_repos.

@Test
public void return_empty_list_when_there_are_no_azure_repos() {
    when(azureDevOpsHttpClient.getRepos(any(), any(), any())).thenReturn(new GsonAzureRepoList(emptyList()));
    AlmSettingDto almSetting = insertAlmSetting();
    SearchAzureReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).executeProtobuf(SearchAzureReposWsResponse.class);
    assertThat(response.getRepositoriesList()).isEmpty();
}
Also used : SearchAzureReposWsResponse(org.sonarqube.ws.AlmIntegrations.SearchAzureReposWsResponse) GsonAzureRepoList(org.sonar.alm.client.azure.GsonAzureRepoList) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 68 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class SearchAzureReposActionTest method search_repos_with_project_already_set_up.

@Test
public void search_repos_with_project_already_set_up() {
    AlmSettingDto almSetting = insertAlmSetting();
    ProjectDto projectDto2 = insertProject(almSetting, "repoName-2", "project-2");
    SearchAzureReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).executeProtobuf(SearchAzureReposWsResponse.class);
    assertThat(response.getRepositoriesCount()).isEqualTo(2);
    assertThat(response.getRepositoriesList()).extracting(AzureRepo::getName, AzureRepo::getProjectName, AzureRepo::getSqProjectKey, AzureRepo::getSqProjectName).containsExactlyInAnyOrder(tuple("repoName-1", "project-1", "", ""), tuple("repoName-2", "project-2", projectDto2.getKey(), projectDto2.getName()));
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) SearchAzureReposWsResponse(org.sonarqube.ws.AlmIntegrations.SearchAzureReposWsResponse) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 69 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class SearchAzureReposActionTest method search_and_filter_repos_with_matching_repo_and_project_name.

@Test
public void search_and_filter_repos_with_matching_repo_and_project_name() {
    mockClient(new GsonAzureRepoList(ImmutableList.of(getGsonAzureRepo("big-project", "repo-1"), getGsonAzureRepo("big-project", "repo-2"), getGsonAzureRepo("big-project", "big-repo"), getGsonAzureRepo("project", "big-repo"), getGsonAzureRepo("project", "small-repo"))));
    AlmSettingDto almSetting = insertAlmSetting();
    SearchAzureReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).setParam("searchQuery", "big").executeProtobuf(SearchAzureReposWsResponse.class);
    assertThat(response.getRepositoriesList()).extracting(AzureRepo::getName, AzureRepo::getProjectName).containsExactlyInAnyOrder(tuple("repo-1", "big-project"), tuple("repo-2", "big-project"), tuple("big-repo", "big-project"), tuple("big-repo", "project"));
}
Also used : SearchAzureReposWsResponse(org.sonarqube.ws.AlmIntegrations.SearchAzureReposWsResponse) GsonAzureRepoList(org.sonar.alm.client.azure.GsonAzureRepoList) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 70 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class SearchAzureReposActionTest method search_and_filter_repos_with_repo_name.

@Test
public void search_and_filter_repos_with_repo_name() {
    AlmSettingDto almSetting = insertAlmSetting();
    SearchAzureReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).setParam("searchQuery", "repoName-2").executeProtobuf(SearchAzureReposWsResponse.class);
    assertThat(response.getRepositoriesList()).extracting(AzureRepo::getName, AzureRepo::getProjectName).containsExactlyInAnyOrder(tuple("repoName-2", "project-2"));
}
Also used : SearchAzureReposWsResponse(org.sonarqube.ws.AlmIntegrations.SearchAzureReposWsResponse) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Aggregations

AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)217 Test (org.junit.Test)175 UserDto (org.sonar.db.user.UserDto)113 TestRequest (org.sonar.server.ws.TestRequest)48 ProjectDto (org.sonar.db.project.ProjectDto)40 NotFoundException (org.sonar.server.exceptions.NotFoundException)37 DbSession (org.sonar.db.DbSession)36 WebService (org.sonar.api.server.ws.WebService)31 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)28 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)28 Rule (org.junit.Rule)28 Mockito.mock (org.mockito.Mockito.mock)28 DbTester (org.sonar.db.DbTester)28 UserSessionRule (org.sonar.server.tester.UserSessionRule)28 WsActionTester (org.sonar.server.ws.WsActionTester)28 Encryption (org.sonar.api.config.internal.Encryption)27 ForbiddenException (org.sonar.server.exceptions.ForbiddenException)27 ComponentFinder (org.sonar.server.component.ComponentFinder)26 Tuple.tuple (org.assertj.core.groups.Tuple.tuple)25 ProjectAlmSettingDto (org.sonar.db.alm.setting.ProjectAlmSettingDto)25